hotkeys - Define application-wide hot key in mixed wpf/win32 app -
i've got wpf (prism) app, uses whole lot of other wpf assemblies , win32 dlls containing other windows (wpf , win32).
when user presses function key (f2-f12) want open spezific program functions.
something this:
routedcommand commandf4 = new routedcommand(); commandf4.inputgestures.add(new keygesture(key.f4)); application.current.mainwindow.commandbindings.add(new commandbinding(commandf4, callcommandf4));
the problem is: work while mainwindow has focus. if open secondary wpf window (or win32 window) keybinding not apply anymore.
is there way add applicationwide global hotkey f4 (or other key)?
or @ least wpf-wide hotkey?
you can try think write hook keyboard , attached hook listen keyboard messages application's thread.
this example inspiration: http://www.codeproject.com/kb/cs/globalhook.aspx.
just take note if use .net 4.0 when use setwindowshookex instead of using
assembly.getexecutingassembly().getmodules()[0]
as hmod param, use:
process.getcurrentprocess().mainmodule.baseaddress
Comments
Post a Comment