{Dota - Legion Commander] Sequence of keys pressed one by one ending with click should initiate action Topic is solved

Ask gaming related questions (AHK v1.1 and older)
mrpopo1992
Posts: 10
Joined: 20 Aug 2018, 05:24

{Dota - Legion Commander] Sequence of keys pressed one by one ending with click should initiate action  Topic is solved

20 Aug 2018, 05:56

ok. let me explain. its for dota.my hero is legion commander.
enemy hero has linken sphere. so what i have to do is
1. break linken sphere with some item in my inventory
2. initiate my ultimate(duel) on the hero
both actions have to be done quickly

i want it such that when i press "r" and then release key and then press click on that hero i want both the above actions to occur on that hero.

Please note- the key "r" and Lbutton are not pressed together but rather in sequence, i.e., first, press and release "r"; when i click on enemy hero, if previous key was "r" then initiate the above actions.

I wrote a program; but here while pressing the key "r", my cursor has to hover over the hero;
again i want it such that the above actions occur on single lbutton on enemy hero( provided the previous pressed key was "r")


#InstallKeybdHook
#InstallMouseHook
#UseHook
SendMode Event

$r::
SetKeyDelay 20,100
Send {v}; this key selects an item in my inventory to break linken sphere
Click; this applies the above item on the enemy hero i click
Send {r}; this key is the default key to initiate ultimate/duel on enemy hero
Click; this initiates duel on the enemy hero i click
return
Last edited by mrpopo1992 on 26 Aug 2018, 02:22, edited 1 time in total.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: {Dota - Legion Commander] Sequence of keys pressed one by one ending with click should initiate action

20 Aug 2018, 08:16

u can hit Esc to exit out of the ulti casting mode

Code: Select all

#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1

#If !casting
*r::casting := true

#If casting
*Esc::casting := false
*$LButton::
	Send v{Click}r{Click}
	casting := false
return
mrpopo1992
Posts: 10
Joined: 20 Aug 2018, 05:24

Re: {Dota - Legion Commander] Sequence of keys pressed one by one ending with click should initiate action

26 Aug 2018, 02:20

wonderful. this works. took a long time understanding it. i wrote a similar programme after understanding your method. plz check if it performs the same.

#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1


*r::
casting := true

*Esc::
casting := false

#If casting
*$LButton::
Send v{Click}r{Click}
casting := false
return
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: {Dota - Legion Commander] Sequence of keys pressed one by one ending with click should initiate action

27 Aug 2018, 07:00

one thing to be aware of is when u have multiline hotkey subroutines, if u dont end them with a return statement, code execution will go on. Meaning in ur example, when u press R the flag gets set to true, then the Esc subroutine runs and the flag gets set back to false, then the LButton subroutine never gets to run because the flag is always false and the #If directive always fails. This piece of code, effectively, does nothing at all.

either put a return at the end of those subroutines as is the case with LButton or make them a single line only.
mrpopo1992
Posts: 10
Joined: 20 Aug 2018, 05:24

Re: {Dota - Legion Commander] Sequence of keys pressed one by one ending with click should initiate action

28 Aug 2018, 09:02

hey slight tweak to the programme. i want the autocast function to cancel on all keys except "r" and Rbutton.



#NoEnv
#SingleInstance Force
SendMode Input
SetBatchLines -1

#Usehook

*r::
casting := true
return

if(%A_PriorKey% != r || %A_PriorKey% != RButton)
casting := false
return

#If casting
*$LButton::
Send v{Click}r{Click}
casting := false
return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 116 guests