Page 1 of 1

Using a hotkey in KeyWait

Posted: 18 Jul 2017, 07:02
by nathan323
I want to use a mouse button that has proven impossible to register (tried MouseHook, AHKHID). Seems easiest to use other suggestion in docs and define that button as an hotkey in my mouse software, then get the script to trigger from that hotkey. Tried using the example given (Ctrl+F1), but my script uses KeyWait, and KeyWait doesn't like using a hotkey.

Script:

Code: Select all

^F1::
KeyWait, ^F1, T.5
If ErrorLevel
  {
  Send ^!{Tab}
  Send {Ctrl Up}{AltUp}
  }
Else
  {
  Send !{Tab}
  Send {Alt Up}
  }
Return
I know I can use a single key, but I wanted to use at least 1 modifier to keep it unique.

Any way to use a hotkey with KeyWait?

Re: Using a hotkey in KeyWait

Posted: 18 Jul 2017, 08:08
by boiler
Not sure what you mean by KeyWait doesn't like using a hotkey. They are used together all the time. The issue is ^F1 is not a key, it's a key combination. Try using F1 in your KeyWait statement, and it will wait until that key is released.

Re: Using a hotkey in KeyWait

Posted: 18 Jul 2017, 09:21
by nathan323
Ok, stand corrected. So is there a way to make a key combination to work with KeyWait? Like I said I want to stay away from a single key to avoid a conflict.

Re: Using a hotkey in KeyWait

Posted: 18 Jul 2017, 10:20
by boiler
I just told you how. Use F1 in the KeyWait statement. I didn't say you had to change your hotkey from ^F1. It will wait until F1 is released. You can follow it with another for Control if you want to make sure both are released.

Re: Using a hotkey in KeyWait

Posted: 18 Jul 2017, 19:53
by nathan323
Ah I see, thanks.