How to disable/override Windows 10 Hotkeys with C# -
i'm trying register hotkeys, can't because windows defaults.
ctrl+win+1 minimizes current window. i'd else. i'd disable win+left/right. i'm trying handle ctrl+win+arrow in own virtual desktop manager.
this has done using c# , win32 api if necessary. absolutely cannot use autohotkey.
every page find descibes how can done autohotkey.
i'd post code, don't know start. use win32 register hotkeys. assume there way override them, can't find info.
does have idea?
it possible using keyboard hook. hook class can found on codeproject article
using below code prevent win+left or win+right occurring. can use override whichever keys you'd like.
this override hotkeys added via registerhotkey
win api.
once have classes in project can add handlers static hookmanager
class below.
//it's worth noting here if subscribe key_press event break international accent keys. hookmanager.keypress += hookmanager_keypress; hookmanager.keydown += hookmanager_keydown; hookmanager.keyup += hookmanager_keyup;
you can add mouse events, simplicity i'm showing keyboard hook.
i've created generic list know keys down , remove keys list on keyup
event.
public static list<keys> keysdown = new list<keys>(); private static void hookmanager_keydown(object sender, keyeventargs e) { //used overriding windows default hotkeys if(keysdown.contains(e.keycode) == false) { keysdown.add(e.keycode); } if (e.keycode == keys.right && win()) { e.handled = true; //do want when key combination pressed } else if (e.keycode == keys.left && win()) { e.handled = true; //do want when key combination pressed } } private static void hookmanager_keyup(object sender, keyeventargs e) { //used overriding windows default hotkeys while(keysdown.contains(e.keycode)) { keysdown.remove(e.keycode); } } private static void hookmanager_keypress(object sender, keypresseventargs e) { //used overriding windows default hotkeys } public static bool ctrl() { //return keysdown.contains(keys.lshiftkey) if (keysdown.contains(keys.lcontrolkey) || keysdown.contains(keys.rcontrolkey) || keysdown.contains(keys.control) || keysdown.contains(keys.controlkey)) { return true; } else { return false; } } public static bool shift() { //return keysdown.contains(keys.lshiftkey) if (keysdown.contains(keys.lshiftkey) || keysdown.contains(keys.rshiftkey) || keysdown.contains(keys.shift) || keysdown.contains(keys.shiftkey)) { return true; } else { return false; } } public static bool win() { //return keysdown.contains(keys.lshiftkey) if (keysdown.contains(keys.lwin) || keysdown.contains(keys.rwin)) { return true; } else { return false; } } public static bool alt() { //return keysdown.contains(keys.lshiftkey) if (keysdown.contains(keys.alt) || keysdown.contains(keys.lmenu) || keysdown.contains(keys.rmenu)) { return true; } else { return false; } }
Comments
Post a Comment