Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
in exe: wait until no modifier key is pressed
#1
I have a dialog in compiled .exe format.
It has keyboard shortcuts ALT+Z and ALT+X registered to it.

What I want is that the moment the user presses ALT+Z or ALT+X the code waits for the user to release ANY of the modfier keys and then continue execute code.

To make my request more clear, I have the following in my simple dialog code:

Code:
Copy      Help
    case WM_HOTKEY        
        if(wParam=0)sub.user_input
        if(wParam=1)sub.pw_input

If user presses ALT+X the compiled qm exe immediately sends the sendkeys commands defined under the subfunctions.
The problem is that the user could still be pressing ALT, meaning the text "test" is not send but ALT+t , ALT+e, ALt+s, ALT+t.
So I want to wait until the user has released all the modfier keys. (Or released all keys, no keyboard commands beeing send from the user and then send the keyboard commands from the qm exe).

I do not know if it possible in exe.
#2
Function dialog_hotkeys2
Code:
Copy      Help
\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
,if(!t_hk1.Register(hDlg 1 MOD_ALT 'Z')) end "failed to register a hotkey"
,if(!t_hk2.Register(hDlg 2 MOD_ALT 'X')) end "failed to register a hotkey"
,
,case WM_HOTKEY
,sel wParam
,,case 1 sub.WaitNoKeys; out "Alt+Z"
,,case 2 sub.WaitNoKeys; out "Alt+X"
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


#sub WaitNoKeys

;Waits until released Ctrl, Shift, Alt and Win keys of a hotkey.

opt waitmsg 1
rep
,if(!GetMod) break
,0.01
#3
THANK YOU, THIS WORKS!!!!


Forum Jump:


Users browsing this thread: 2 Guest(s)