Registering hot keys, waiting for hotkeys

Functions, classes, components, etc. Only high quality content.

Registering hot keys, waiting for hotkeys

Postby Gintaras on Sat Feb 28, 2009 2:49 pm

Examples.

Function dialog_hotkeys     ?
\Dialog_Editor

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030506 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc
function# hDlg message wParam lParam
__RegisterHotKey- t_hk1 t_hk2
sel message
,case WM_INITDIALOG
,t_hk1.Register(hDlg 1 MOD_CONTROL|MOD_SHIFT VK_F5) ;;Ctrl+Shift+F5
,t_hk2.Register(hDlg 2 MOD_ALT|MOD_WIN 'Q') ;;Alt+Win+Q
,
,case WM_HOTKEY
,sel wParam
,,case 1 out "Ctrl+Shift+F5"
,,case 2 out "Alt+Win+Q"
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1



Macro __RegisterHotKey example     ?
;Shows how to use __RegisterHotKey to use hotkeys in a windowless thread.
;This should be function, not macro, because runs all the time.

__RegisterHotKey hk1.Register(0 1 MOD_CONTROL|MOD_SHIFT VK_F5)
;also can register more hotkeys, for example
__RegisterHotKey hk2.Register(0 2 MOD_CONTROL 'B')
;...

MSG m
rep
,if(GetMessage(&m 0 0 0)<1) break
,sel m.message
,,case WM_HOTKEY
,,sel m.wParam
,,,case 1 ;;Ctrl+Shift+F5 pressed
,,,mac "Function_that_does_something_on_Ctrl_Shift_F5"
,,,
,,,case 2
,,,out "Ctrl+B"
,,,
,,,;...
,,,
,DispatchMessage &m

Gintaras
Site Admin
 
Posts: 10185
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Registering hot keys, waiting for hotkeys

Postby _pi on Tue Jul 01, 2014 7:15 pm

;register hotkey Ctrl+K with id 70

sorry, but for what could be id 70 be used?
_pi
Active Member
 
Posts: 1225
Joined: Tue Mar 11, 2003 12:16 am
Location: Hamburg, Germany

Re: Registering hot keys, waiting for hotkeys

Postby Gintaras on Wed Jul 02, 2014 3:35 am

It is wParam in WM_HOTKEY message. I replaced the old code. Now QM has class __RegisterHotKey, delete class CRegisterHotKey if you have it.
Gintaras
Site Admin
 
Posts: 10185
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania


Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 2 guests

cron