Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Can AHK be used in LoL somehow?


  • Please log in to reply
18 replies to this topic
Feleran
  • Members
  • 5 posts
  • Last active: Oct 05 2013 08:39 AM
  • Joined: 02 Oct 2013

Title says it all. I've tried a few basic scripts and they did not work.
Does anyone know how to make them work? Or is it an impossible mission?

(I just want to swap left and middle mouse buttnos there, because the wheel is too difficult to click on.)



Temil2008
  • Members
  • 364 posts
  • Last active: Jun 14 2015 09:02 PM
  • Joined: 10 Dec 2012

per your other post.

http://www.autohotke...e-click-script/

 

I provided an answer, and you said it didnt work. care to elaberate?

- did the keys act like new key setup in game? if not, what happened?

- did the keys act like new key setup out of game? if not, what happened?

- did you run the script before or after opening game?


________________________________________________________________

Did a solution provided fix your issue? please mark as "Answered" if so. thank you!


Feleran
  • Members
  • 5 posts
  • Last active: Oct 05 2013 08:39 AM
  • Joined: 02 Oct 2013

The change worked outside of the game.

Previously, before trying AHK, I tried one other program for switching keys and that worked in the same way. Worked outside of game but not inside.

In game it's like nothing had been changed at all. And I tried running it before and in the middle too.

I also found this thread: http://www.autohotke...-little-script/. Going to try something from there in the evening.



Temil2008
  • Members
  • 364 posts
  • Last active: Jun 14 2015 09:02 PM
  • Joined: 10 Dec 2012

The change worked outside of the game.

Previously, before trying AHK, I tried one other program for switching keys and that worked in the same way. Worked outside of game but not inside.

In game it's like nothing had been changed at all. And I tried running it before and in the middle too.

I also found this thread: http://www.autohotke...-little-script/. Going to try something from there in the evening.

 

have you tried it with "run as admin" ? 

have you tried it while game was windowed mode?


________________________________________________________________

Did a solution provided fix your issue? please mark as "Answered" if so. thank you!


Feleran
  • Members
  • 5 posts
  • Last active: Oct 05 2013 08:39 AM
  • Joined: 02 Oct 2013

Window size didn't matter but running it (or even the other program = not AHK) as admin made left clicks and middle clicks both apply both of these clicks' effects in game.
I guess that the game allowed AHK to "add" cliks but didn't allow to "remove" them, so every click started to count as 2 different clicks.

 

Anyway I believe I've found a better solution for attack-moving anyway, so I'll stop messing with AHK now :p
Thanks again for your time.



Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Every click is starting as two clicks because AHK allows the original keypress through as well as the one you are reprogramming it for. You need to add $ before the hotkey.

 

ie.

 

MButton::LButton  'This turns out to press Mbutton, then Lbutton
 

$MButton::LButton 'This only presses Lbutton

 

Not usually necessary but I have had this problem in a couple games now, LoL included. So far AHK really hasn't been very useful in LoL other than making jungle timers or auto chat notifications. The gameplay just varies too much unless you are a couple specific champions that rely heavily on a fixed rotation.


If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


Tannex
  • Members
  • 59 posts
  • Last active: Nov 13 2015 03:26 PM
  • Joined: 29 Apr 2013

tried every way i know of, seems like LoL does NOT allow AHK input.



Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Yes LoL DOES allow input. Tested and verified working as of 10/30/2013.

 

Alternately verified:

Works to enter preconfigured chat strings.

Also works for casts and mouse clicks.

 

 

 

 

Edit: If there is any interest in a how to for LoL I will write one. Basically you have to break down every keypress into individual up/down commands with a small sleep between. The 'why' for this behavior is a little technical.


If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


RHCP
  • Members
  • 1228 posts
  • Last active: Apr 08 2017 06:17 PM
  • Joined: 29 May 2006

Basically you have to break down every keypress into individual up/down commands with a small sleep between. The 'why' for this behavior is a little technical.

 

What is the issue then? Sounds like it has a mechanism to ignore automated input or at least input with inadequate pressDuration.



Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Ok here we go.

 

First thing we need to know is that LoL uses DirectX not only for drawing the screen it also uses the DirectInput portion of DirectX. DirectInput

captures keystrokes by 'polling' the state of all the keys on the keyboard. Basically take a snapshot of the current state of all the keys on the keyboard, then

after about 15ms it takes another snapshot and compares the two.

 

This is done to allow the game to 'see' multiple key presses at the same time. The problem is that all of the send methods in AHK are way too fast for this, approx 5 ms to send a single keytstroke.

 

Now here is where we run into problems with LoL... Since the polling rate is so slow in comparison to our send rate keystrokes are 'lost' between snapshots. Now the second problem is any sleep time between 1-10 is essentially the same and rounded up to 10 or 15.6 depending and will vary depending on your computers hardware. See http://www.autohotke...mands/Sleep.htm for the reasons behind this and an example of how to achieve lower sleep times.

 

Interesting fact, game pads and mice with very high polling rates will have the same effect in League. I use a Belkin N52TE and with it set to a high polling rate I 'lose' keystrokes all the time.

 

Chat commands do not seem to suffer from the same issue. I would guess that it is the difference between 'buffered' and 'immediate' keyboard input.

See here for more detailed data on DirectInput http://msdn.microsof...9(v=vs.85).aspx

 

Chat can be done like this:

<code>

NumpadMinus::

     Send {Enter}

     Send Rawr!!

     Send {Enter}

return

</code>

 

Actions must be done like this:

<code>

NumpadEnter::

     Send {q down}

     Sleep 10

     Send {q up}

return

</code>

 

I can't remember exactly what the polling rate is for DirectInput. It is around 15ms. This really becomes a problem when trying to string together more than a few keypresses in a row. I am interested to see what anyone comes up with. So far I have a working Jungle Timer /w announcements and a "Multi-Tap" style chat callout system that works pretty well. Hope this helps!


If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Bump...

 

If anyone is interested in collaborating on some hotkeys/bots for this game let me know. Shoot me a PM, I keep an eye on this subforum a lot.


If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


Neverlevel
  • Members
  • 268 posts
  • Last active: Aug 18 2014 07:25 AM
  • Joined: 28 Jan 2008

i used to run a bot that took advantage of the bush bug in dominion to win. start a bot game..run to bush..and wiggle..accept victory and check for IP gain. start a new game or switch accounts if no IP gain. i've also experimented with a GG ascii script and a Mid only bot.


The early bird gets the worm but the second rat gets the cheese!

Neverlevel
  • Members
  • 268 posts
  • Last active: Aug 18 2014 07:25 AM
  • Joined: 28 Jan 2008

i used to run a bot that took advantage of the bush bug in dominion to win. start a bot game..run to bush..and wiggle..accept victory and check for IP gain. start a new game or switch accounts if no IP gain. i've also experimented with a GG ascii script and a Mid only bot. i dont know what all still works..my screenshot.ahk gives me black screenshots...dunno if pixelgetcolor will still work.

 

This still works but its not for INGAME use.. quick select character and Call Position. Uses Fkeys to save locations and click where needed to chat/select character.

 

QuickCall:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance, force
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

x = 0
y = 0
InputBox, Input, What to Call PRESS F8 FOR COMMAND LIST, Your Call, , 640, 480


F1::
{
Mouseclick, left, %x%, %y%
sleep, 79
Send, %input% {enter}
}
Return

F2::Mousegetpos, x, y
Return



F3::
{
Mouseclick, Left, %x2%, %y2%
return
}

F4::Mousegetpos,x2, y2
Return

F5::reload

F7::send, thereisnourflevel

F8::Msgbox, F1 = Click and Send saved MSG. F2 = Record location to click and send your location call.  F3 = Click saved champion location F4 = Save champion location.    F5 = Reload script and reset EVERYTHING   F7 = Make the play button Orange

KB swipe still works.

#IfWinActive, League of Legends (TM) Client ;Make the hotkey only work when league is active

F1::
{
Send, {2 Down}
Sleep, 50
Send, {2 Up}
Sleep, 50
Send, {e Down}
Sleep, 50
Send, {e Up}
Sleep, 50
Send, {w Down}
Sleep, 50
Send, {w Up}
Sleep, 50
Send, {q Down}
Sleep, 50
Send, {q Up}
Sleep, 50
Send, {r Down}
Sleep, 50
Send, {r Up}
Sleep, 50
}

The early bird gets the worm but the second rat gets the cheese!

Ruevil2
  • Members
  • 226 posts
  • Last active: Dec 04 2015 11:05 PM
  • Joined: 27 Mar 2012

Here is a script I use during SoloQ.

 

For calling out MIA's, emergencies and recalls in the chat. Multi Tap system. For people who hate typing in chat while trying to game.

 

 

Key:                 First Press:    Second Press:         Third Press:

NumpadSub =    Mia Top        !!Emergency Top!!    Recall

NumpadAdd =    Mia Mid         !!Emergency Mid!!     Recall

NumpadEnter =  Mia Bot         !!Emergency Bot!!     Recall

;**********************************************
;***Call Ur Inc! League of Legends Edition V1.0
;***9/5/2013 ThrottleMunky, aka XHonorFaceX
;***Multi-Tap Hotkey for providing info to your team
;***Thanks to Relayer for the MultiPress Function!
;**********************************************
 
;Instructions:
;Hotkeys are Numpad Minus, Plus and Enter. Tapping multiple times alters the msg that will be sent in chat.
;Next release I may change the buttons around and add a setup Gui for editing the
;Hotkeys and corresponding messages.
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Initialization
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#SingleInstance, Force
#Persistent
;SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Operations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$NumpadSub::Action := MultiPress("MiaT, EmergencyT, Recall")
$NumpadAdd::Action := MultiPress("MiaM, EmergencyM, Recall")
$NumpadEnter::Action := MultiPress("MiaB, EmergencyB, Recall")
$Numpad0::Action := MultiPress("null, GG")
 
TakeAction:
SetTimer, TakeAction, Off
if (IsLabel(Action))
Gosub, %Action%
Return
 
;*************
;***NumpadSub***
;*************
MiaT:
Send {Enter}
Sleep 10
Send MIA Top
Sleep 10
Send {Enter}
Return

EmergencyT:
Send {Enter}
Sleep 10
Send !!Emergency Top!!
Sleep 10
Send {Enter}
Return
 
;*************
;***NumpadAdd***
;*************
MiaM:
Send {Enter}
Sleep 10
Send MIA Mid
Sleep 10
Send {Enter}
Return

EmergencyM:
Send {Enter}
Sleep 10
Send !!Emergency Mid!!
Sleep 10
Send {Enter}
Return
 
;*************
;***NumpadEnter***
;*************
MiaB:
Send {Enter}
Sleep 10
Send MIA Bot
Sleep 10
Send {Enter}
Return

EmergencyB:
Send {Enter}
Sleep 10
Send !!Emergency Bot!!
Sleep 10
Send {Enter}
Return
 
 
Recall:
Send {Enter}
Send Recall
Send {Enter}
Return
 
;**********************************
;***Capture Multiple Key Presses***
;**********************************
MultiPress(actionList = "", delay = 400)
{
Static pressCount := 0
 
pressCount := ( ((A_PriorHotKey = "") || (A_ThisHotKey = A_PriorHotKey)) && (A_TimeSincePriorHotkey < delay) ) ? (pressCount + 1) : (1)
 
if (actionList = "")  ;this option flags to just return count to caller (no list present)
Return pressCount
 
SetTimer, TakeAction, % delay
Loop, Parse, actionList, `,, %A_Space%
 
if (A_Index = pressCount)
Return A_LoopField
 
Return False
}

If I helped you out and you would like to show appreciation, feel free to buy me a beer.  grin.png   btn_donateCC_LG.gif


Arcanist
  • Members
  • 27 posts
  • Last active: May 30 2016 11:26 AM
  • Joined: 10 Mar 2014

Hey Ruevil 2. I tried all of your scripts and none of them work in game. They worked outside of the game. Do you have any new way of making macros in LoL? I would love to be able to have a keybind where I heal all four of my teammates with different buttons. I think you can already do this with the LoL keybind options but I don't know how. Thanks for your hard work

 

EDIT: I have figured out how to do it. I use a Razer Naga so that's why they're the numpad buttons. These macros can cast Taric's Q on each ally, item slot 3 on each ally and item slot 4 on each ally.

F1 - F4 selects spells. F5 - F6 selects allies.

 

If anyone knows how to change the colour of each ally's health bar separately, I would love to know. It's hard to remember which number every ally is during a team fight.

;;Script must be run as administrator to work in game


; ALLY 1


; Heal
$Numpad1::
Send,{F1 down}
sleep 10
Send,{F1 up}
sleep 10
Send,{F5 down}
sleep 10
Send,{F5 up}
Return


; ITEM 3
$Numpad2::
Send,{Ins down}
sleep 10
Send,{Ins up}
sleep 10
Send,{F5 down}
sleep 10
Send,{F5 up}
Return


; ITEM 4
$Numpad3::
Send,{Home down}
sleep 10
Send,{Home up}
sleep 10
Send,{F5 down}
sleep 10
Send,{F5 up}
Return




; ALLY 2


;Heal
$Numpad4::
Send,{F1 down}
sleep 10
Send,{F1 up}
sleep 10
Send,{F6 down}
sleep 10
Send,{F6 up}
Return


; ITEM 3
$Numpad5::
Send,{Ins down}
sleep 10
Send,{Ins up}
sleep 10
Send,{F6 down}
sleep 10
Send,{F6 up}
Return


; ITEM 4
$Numpad6::
Send,{Home down}
sleep 10
Send,{Home up}
sleep 10
Send,{F6 down}
sleep 10
Send,{F6 up}
Return


; ALLY 3


;Heal
$Numpad7::
Send,{F1 down}
sleep 10
Send,{F1 up}
sleep 10
Send,{F7 down}
sleep 10
Send,{F7 up}
Return


; ITEM 3
$Numpad8::
Send,{Ins down}
sleep 10
Send,{Ins up}
sleep 10
Send,{F7 down}
sleep 10
Send,{F7 up}
Return


; ITEM 4
$Numpad9::
Send,{Home down}
sleep 10
Send,{Home up}
sleep 10
Send,{F7 down}
sleep 10
Send,{F7 up}
Return


; ALLY 4


;Heal
$Numpad0::
Send,{F1 down}
sleep 10
Send,{F1 up}
sleep 10
Send,{F8 down}
sleep 10
Send,{F8 up}
Return


; ITEM 3
$NumpadSub::
Send,{Ins down}
sleep 10
Send,{Ins up}
sleep 10
Send,{F8 down}
sleep 10
Send,{F8 up}
Return


; ITEM 4
$NumpadAdd::
Send,{Home down}
sleep 10
Send,{Home up}
sleep 10
Send,{F8 down}
sleep 10
Send,{F8 up}
Return


;Recall
CapsLock::F11
Return