Sending a key after mouseclick

Ask gaming related questions (AHK v1.1 and older)
TxFvry
Posts: 1
Joined: 07 Feb 2023, 22:28

Sending a key after mouseclick

Post by TxFvry » 07 Feb 2023, 23:01

basically, i want the script to switch back to/send 1 after using any of these keys
e::send 2
c::send 0
z::send 5
x::send 6
like the script is waiting for Lbutton (left click) to happen after one of these keys were pressed
it's for a game I play to make it switch back to 1 on the Hotbar after using a skill
so i dont have to equip 1 over and over after each skill use
oh and also set a wait time so if the mouseclick does not happen in the time set then the script wont act on it
and if another key other than those is pressed (like 1 or any other key except e,c,z,x) then have the script cancel this action
also set a delay after mouseclick for when 1 should be sent
i'll tweak it depending on if i want a delay or not
im Bad at explanations but i hope the message was received!

Rohwedder
Posts: 7614
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Sending a key after mouseclick

Post by Rohwedder » 09 Feb 2023, 04:02

Hallo,
perhaps?:

Code: Select all

#InstallKeybdHook
e::
c::
z::
x::
Send,% {e:2,c:0,z:5,x:6}[A_ThisHotkey]
Time := A_TickCount + 2000 ;2 seconds
; delay after mouseclick for when 1 should be sent
Return
#IF (A_TickCount < Time)
~LButton::
Time = 0
IF !InStr("eczx", A_PriorKey)
	Return
KeyWait, LButton
Sleep, 100
Send, 1
Return
#IF

Post Reply

Return to “Gaming Help (v1)”