Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detect multiple keys
#1
First of all hello to all QM users Smile

Okay guys, I am using QM for a year already, but I didn't use it for more complex stuff. And this time I need your help. Tongue
I am trying to make a macro that reacts on Lshift+some key. But its not just one key and one reaction. It should be like:
Lshift + q = sendkeys "qqq"
Lshift + w = sendkeys "www"
Lshift + e = sendkeys "eee"
...
You get the point..The thing is that I don't even know where to start. I know about -wait for key- function but it doesn't let me use more than one key.I hope you understand my problem,and sorry for my bad English.
Thanks.
#2
Need hotkeys to use in macro instead of QM triggers? Try __RegisterHotKey class.
Examples: run macro in background (activate chrome window on keypress)
#3
Ouch,could you help me out a bit more?
It should look something like this xD
Code:
Copy      Help
__RegisterHotKey hk1.Register(0 1 MOD_SHIFT q) ;;unknown indentifier
__RegisterHotKey hk2.Register(0 2 MOD_SHIFT w)
case WM_HOTKEY ;;case without sel
    case 1
    key "qqq"
    
    case 2
    key "www"
In first line I tried using shift + 1 and it works,I don't know how to use letters instead of other buttons.
And the sel command is kinda blurred to me..
#4
Macro __RegisterHotKey example
Code:
Copy      Help
;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
#5
Hi Gintaras, hi all

what happens if I register an hotkey already owned by windows OS??

like Win+x, CTL-c, CTRL-v etc etc
#6
Register() returns 0.
Ctrl+C etc are not owned.

Macro Macro2297
Code:
Copy      Help
__RegisterHotKey hk;
if(!hk.Register(0 2 MOD_WIN 'R')) end "failed"
#7
It is quite confusing but it works Big Grin
Thank you very much.


Forum Jump:


Users browsing this thread: 1 Guest(s)