Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Register multiple hotkeys based on array
#1
Is it possible to register multiple hotkeys dynamically based on an array for example.
The code I have now is to much to post here, so I extracted the parts which should matter.

It is like this:

Macro Macro25
Code:
Copy      Help
ARRAY(int) all_keys
int i
;.
;.
;.
;array get's filled
;.
;.
;.
all_keys[0]=562
all_keys[1]=564
all_keys[2]=567


for i 0 all_keys.len ;; i also corresponds to hotkey ID
,__RegisterHotKey hk.Register(hDlg i 0 all_keys[i]) ;;all hotkeys don't have mod

;; only first ID (0) get's correctly registered and works, others do not get registered.

edit: array size can vary

I think "hk" can be used for one hotkey? So if 'hk' has "F1" I can not use 'hk' again even if I use a different hotkey id.
with hotkey Id i mean:

function! hWnd hkId mod vk

Is it possible in another way?


EDIT:
I think I got the correct method, I did the "__RegisterHotKey- hk" decleration outside the for loop and I declared it thread global (minus sign). All the keys are now getting registered and seem to work.
#2
The correct way is
ARRAY(__RegisterHotKey) hk.create(all_keys.len)
for...
,hk[i].Register

If used same variable for multiple hotkeys, now many hotkeys are not unregistered. Need to restart QM, maybe even Windows.
#3
oh! ok! Thank you!!


Forum Jump:


Users browsing this thread: 1 Guest(s)