Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Key Down...Key Up.
I've never ever had very good luck with triggering a macro with a key down and then triggering another when key up.

One problem is how to keep the function from running a bunch while waiting for the key to come up.

The other is getting the wait for key up to actually do anything.

I've tried a bunch of different ways over the years and I still haven't gotten something that works....So now I ask for help.

Jimmy Vig
Function macro_on_key_down
Copy      Help
spe -1
out "down"

Function macro_on_key_up
Trigger F8 0x4 //FF_macro_on_key_up     Help - how to add the trigger to the macro
Copy      Help
spe -1
int+ g_macro_key_down=0
out "up"

Function FF_macro_on_key_up
Copy      Help
function# iid FILTER&f

;ignore repeated key down events
int+ g_macro_key_down g_macro_key_time
if(g_macro_key_down and GetTickCount-g_macro_key_time<10000) ret iid
g_macro_key_down=1; g_macro_key_time=GetTickCount

mac "macro_on_key_down" ;;run on key down (now)
ret iid ;;run on key up

;ret iid    ;; run the macro.
;ret macro    ;; run other macro. Here 'macro' is its id or name.
;ret 0        ;; don't run any macros.
;ret -1        ;; don't run any macros but eat the key. Eg if the filter function started a macro using mac.
;ret -2        ;; don't run this macro. Other macros with the same trigger can run.
The last function must be a filter function. Set it in Properties -> Function Properties.
Perfect man! Thanks a whole bunch.

Thank you so much. I never would have thought of any of that.

Jimmy Vig

Forum Jump:

Users browsing this thread: 1 Guest(s)