c# - Call a method when specific key combination is pressed anywhere in the app, as long as application is currently focused window -
my objective allow users of app bringup i'm calling debug console pressing ctrl + f11 on keyboard.
simply put, need call toggledebug();
method, enable debug tracing code , display window. i'd application @ point when ctrl + f11 pressed, regardless of user has focus cursor long application focused window.
my app deployed through click once -- partial trust type environment.
in old vb6 app, had been using wend
loop call doevents()
, windows api call... needless say, i'm hoping there better way now.
you can handle previewkeydown event of window.
public mainwindow() { initializecomponent(); this.previewkeydown += new keyeventhandler(mainwindow_previewkeydown); } void mainwindow_previewkeydown(object sender, keyeventargs e) { if ((e.key == key.f11) && (keyboard.modifiers == modifierkeys.control)) { } }
Comments
Post a Comment