Random key presses held down

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kyubi85
Posts: 13
Joined: 23 Nov 2022, 06:42

Re: Random key presses held down

Post by kyubi85 » 05 Jun 2023, 07:33

i dont understand those things, if you know how to help then please help

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Random key presses held down

Post by boiler » 05 Jun 2023, 07:39

I don’t see how you can say that. You already created a script that has hotkeys. This would be very similar to that because the suggestion was to add a hotkey, not change an existing one. So first, choose a key. Let’s say it’s the Tab key. So you would create a new line like the one you have for the Escape key. But you would replace esc with the new key name. And you would replace exitapp with the command you were shown that you would use. You can take it from here.

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: Random key presses held down

Post by RussF » 05 Jun 2023, 07:53

@kyubi85 was not the OP on this thread and didn't create the esc hotkey. Here ya go:

Code: Select all

\::
Random, frequency, 100, 3000
Random, afterKeyUp, 500, 3000
SetTimer, PressTheKey, %frequency%
PressTheKey:
SetKeyDelay, afterKeyUp, 500
Random, key,, 1        ; 0 or 1
Send % key ? "q" : "z" ; 0 -> z, 1 -> q
Return

Esc::SetTimer, PressTheKey, Off
Russ
Last edited by RussF on 05 Jun 2023, 08:57, edited 1 time in total.

kyubi85
Posts: 13
Joined: 23 Nov 2022, 06:42

Re: Random key presses held down

Post by kyubi85 » 05 Jun 2023, 08:03

Thanks a lot, one more thing, a want it to have "u" "i" "o" as random keys

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Random key presses held down

Post by boiler » 05 Jun 2023, 08:11

RussF wrote: @kyubi85 was not the OP on this thread and didn't create the esc hotkey.
You’re right. I missed that, but the answers were still there in direct response to his questions including the links to the documentation link, so I still would have preferred to see kyubi85 produce the line, especially after my last post that basically spelled it out.

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: Random key presses held down

Post by RussF » 05 Jun 2023, 08:30

boiler wrote: so I still would have preferred to see kyubi85 produce the line, especially after my last post that basically spelled it out.
I understand your point and don't necessarily disagree, however, it seems clear that @kyubi85 has virtually no coding experience (no disrespect to @kyubi85 intended). Remembering when I first discovered AHK, even with a lifetime of coding experience, the syntax was somewhat confusing. If one has absolutely no understanding of how programming works, but just needs to get something done, it can be daunting. I'm fully in favor of "teaching a person to fish", but sometimes you have to give them a few while they are learning. :)

Code: Select all

\::
Random, frequency, 100, 3000
Random, afterKeyUp, 500, 3000
SetTimer, PressTheKey, %frequency%
PressTheKey:
SetKeyDelay, afterKeyUp, 500
Random, key,, 2        ; 0, 1 or 2
Switch key
{
    Case 0: Send u
    Case 1: Send i
    Case 2: Send o
}
Return

Esc::SetTimer, PressTheKey, Off

F10::ExitApp
Russ

kyubi85
Posts: 13
Joined: 23 Nov 2022, 06:42

Re: Random key presses held down

Post by kyubi85 » 05 Jun 2023, 08:45

Thanks and thats all

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Random key presses held down

Post by boiler » 05 Jun 2023, 09:24

RussF wrote: I understand your point and don't necessarily disagree, however, it seems clear that @kyubi85 has virtually no coding experience (no disrespect to @kyubi85 intended). Remembering when I first discovered AHK, even with a lifetime of coding experience, the syntax was somewhat confusing. If one has absolutely no understanding of how programming works, but just needs to get something done, it can be daunting. I'm fully in favor of "teaching a person to fish", but sometimes you have to give them a few while they are learning. :)
Those are good points, and I agree. If I hadn’t mistakenly thought these questions were coming from the OP, I may have been more sensitive to that, so I will own up to the fact that I should have been better in that regard here. Thank you for pointing that out.

Post Reply

Return to “Ask for Help (v1)”