Hi all
I was seraching to find a script which, when pressing a key, lets say "z" for 4 times without any time limit, then the script sends the key "k".
All searches i did with loop keyword, had no luck, and some older script i made, had the sleep command which in this case not helping at all.
Anybody can help?
Thanks in Advance
Key loop
-
- Posts: 11
- Joined: 15 Jun 2019, 06:38
Re: Key loop
Code: Select all
:?*:zzzz::k
-
- Posts: 11
- Joined: 15 Jun 2019, 06:38
Re: Key loop
Thank you. It was quite more simple than i could immagine.
A silly question. If in future want to convert the zzzz into mouse clicks, i have to use the getkeystate command?
A silly question. If in future want to convert the zzzz into mouse clicks, i have to use the getkeystate command?
Re: Key loop
Not necessarily. You can do things like:
or issue any other commands there. The decision between whether to use a hotstring (as here) or a hotkey approach may relate to whether you want to trigger the code regardless of whether you are typing into a form. Hotstrings are used while typing into an edit box of some kind. Hotkeys can be used as triggers anywhere.
If you want to use a hotkey as a trigger, then yes, you would assign one key or key combination as the trigger, and the rest of the key presses would need to be detected in the subsequent code.
Code: Select all
:?*:zzzz::
Click
Return
If you want to use a hotkey as a trigger, then yes, you would assign one key or key combination as the trigger, and the rest of the key presses would need to be detected in the subsequent code.
-
- Posts: 11
- Joined: 15 Jun 2019, 06:38
Re: Key loop
I mean, instead of the zzzz, to activate the same sequence after 4 clicks of RButton.
i tried to use Rbutton, but due to the up and down state, is not working.
i tried to use Rbutton, but due to the up and down state, is not working.
Re: Key loop
RButton would need a hotkey, so you are correct: you would use RButton as the hotkey, and then look for subsequent key presses. Could look at KeyWait as a command of interest. This forum also has lots of examples of using button presses in hotkeys. Example is below.
There could be other ways to do this, such as just counting the clicks and seeing if four of them fall within a certain period. The following may be of interest.
https://autohotkey.com/board/topic/35566-rapidhotkey/
Code: Select all
RButton::
KeyWait, RButton, D ; This button was pressed
KeyWait, RButton ; This button was released
KeyWait, RButton, D T1 ; See whether button is pressed a second time
If ErrorLevel
MsgBox, 48, No, RButton was not pressed again.
Else MsgBox, 64, Yes, RButton was pressed again.
Return
F4::
SoundBeep, 1500, 20
ExitApp
Return
https://autohotkey.com/board/topic/35566-rapidhotkey/
Who is online
Users browsing this forum: Dobbythenerd1 and 300 guests