Press 2 Keys simultaneously

Ask gaming related questions (AHK v1.1 and older)
mephistoajj
Posts: 3
Joined: 23 Mar 2023, 10:24

Press 2 Keys simultaneously

Post by mephistoajj » 23 Mar 2023, 10:37

Need help making a code for pressing 2 keys [F1 and F2] simultaneously.
Press F1 to start <F1 left click F2> with time interval of 65ms then repeat. <F1 left click F2>

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: Press 2 Keys simultaneously

Post by DuckingQuack » 23 Mar 2023, 11:49

So if i understand correctly, you want to press F1 and get a repeating output of F1, LButton, and F2 every 65ms?

That’s not hard, but I’d like to confirm i understand first… would you like me to give you the resources to do it yourself?
Best of Luck,
The Duck

mephistoajj
Posts: 3
Joined: 23 Mar 2023, 10:24

Re: Press 2 Keys simultaneously

Post by mephistoajj » 24 Mar 2023, 01:29

@DuckingQuack
Yes, I've tried a couple of codes from google and youtube, but it seems like I'm doing something wrong and couldn't make it work in a way I wanted it to be.
Yes, I'd like to make one myself and learn from the resource you're about to provide. Thanks! Have a great day.

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Press 2 Keys simultaneously

Post by off » 24 Mar 2023, 06:58

@mephistoajj
Script with F1 act as toggle

Code: Select all

$F1::
Repeat:=!Repeat
If (Repeat)
{
SetTimer, RepeatSub, 65
}
Else
SetTimer, RepeatSub, Off
Return

RepeatSub:
Send, {F1}{LClick 1}{F2}
Return
and without F1 act as toggle

Code: Select all

$F1::
Loop
{
Send, {F1}{LClick 1}{F2}
Sleep, 65
}
Return

Esc::Reload ; since F1 cannot be toggled off, use Esc to reload script and stop current loop
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

mephistoajj
Posts: 3
Joined: 23 Mar 2023, 10:24

Re: Press 2 Keys simultaneously

Post by mephistoajj » 24 Mar 2023, 07:30

@off
Thank you for these, kind sir. Hope you'll have a great day ahead!

User avatar
DuckingQuack
Posts: 219
Joined: 20 Jan 2023, 18:20

Re: Press 2 Keys simultaneously

Post by DuckingQuack » 24 Mar 2023, 07:58

@off
I think the OP wanted to learn how to write their script, but good job! Those are some wonderful examples.

@mephistoajj
Please feel free to ask questions about @off’s scripts if there’s any parts you don’t understand or would like clarification. Also, I would like to suggest upgrading to AHK v2 at some point, but the provided scripts are incompatible with v2, so maybe not right now.
Best of Luck,
The Duck

off
Posts: 176
Joined: 18 Nov 2022, 21:54

Re: Press 2 Keys simultaneously

Post by off » 24 Mar 2023, 20:12

@DuckingQuack
Oh, sorry about that :c i write those and post without thinking, My bad.

@mephistoajj
As DuckingQuack said, feel free to ask, if you dont understand what and how the specific code do
My Creations
IMG2HotString - Send image file easily with your hotstring!
CtrlSend - A small solution for sending keys to window in background that doesn't accept ControlSend's key
ControlProcess

Post Reply

Return to “Gaming Help (v1)”