Jump to content

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

Lol Smartcast Little Script


  • Please log in to reply
13 replies to this topic
JonnyE
  • Members
  • 4 posts
  • Last active: Sep 10 2013 08:11 PM
  • Joined: 07 Sep 2013

Hi,

I am trying to make a script for League of Legends, which should press two keys automatically (2 and 3), when i just press 2( using for smartcast).

Here's my current script:

2::
IfWinExist, League of Legends (TM) Client
{WinActivate,  League of Legends (TM) Client
Sleep 20
Send {2 down}
Send {2 up}
Send {3 down}
Send {3 up}
return
}

It doesn't do anything in Lol, when i remove the Check for the Window it presses just 3 in a endless loop, i am a newbie in autohotkey so thanks for help.



danielsan73
  • Members
  • 10 posts
  • Last active: Jul 28 2017 12:08 PM
  • Joined: 26 Jul 2013

Try delay 100ms in middle:

Sleep, 200
Send, {2 down}
Sleep, 100
Send, {2 up}
Sleep, 100
Send, {3 down}
Sleep, 100
Send, {3 up}
Sleep, 100


Oozr
  • Members
  • 59 posts
  • Last active: Sep 14 2013 11:57 PM
  • Joined: 13 Aug 2013

Alright Danielsan!!!!

 

to know AHK is to love AHK ... hehe

 

The Sleeps during the key press might be shorter, say 20ms, but you got it right.

 

--Oozr



DarkRandom
  • Members
  • 51 posts
  • Last active: Sep 28 2013 07:20 AM
  • Joined: 30 Aug 2013

It might be because the hotkey is calling itself (you're sending '2' when pressing '2' wich may cause the script to call itselft again and again, also it's a good idea to have a sleep before and after the send so the game can register the key press, try this:

~2::
IfWinExist, League of Legends (TM) Client
{WinActivate,  League of Legends (TM) Client
Sleep 20
Send {3}
Sleep 20
return
}

This way the script will send only '2' outside LoL and '2' and '3' when the win exists. 



JonnyE
  • Members
  • 4 posts
  • Last active: Sep 10 2013 08:11 PM
  • Joined: 07 Sep 2013

Thanks, it works outside Lol, but just in Lol it wont do anything, also if i remove the window check it doesnt work, any tips?

Edit: Ok, so running the script as admin works, when i type in ingame chat "2" it types "23" so that basically works, but the thing i want to do doesnt seem to work. If any lol players here the thing i want to do is: Set a ward with hotkey "2" and jump to it with skill which is hotkey "3" so when i press 2 it automatically presses 3 too. I have tried to set the Sleep to a longer time, but that doesnt work either. Thanks for help

Edit2: I solved it, i changed the "Send {3"} to " Send, {3 down} .. Send, {3 up}"

Final Script:

~2::
IfWinExist, League of Legends (TM) Client
{WinActivate,  League of Legends (TM) Client
Sleep 5
Send, {3 down}
Sleep 5
Send, {3 up}
Sleep 5
return
}

Still trying around with the Sleep to make it as fast as possible.



Oozr
  • Members
  • 59 posts
  • Last active: Sep 14 2013 11:57 PM
  • Joined: 13 Aug 2013

I have not played LoL, but from the description of what your trying to do... pressing 3 right after 2 won't work.

In theory it should, but you need to wait for the game respond to it.  Press 2, sleep for a bit to let the game deal with the input, then press 3.

 

Also, someone (forgive me for not remembering) posted something about LoL using DirectX for input.  The last keypress is compared to the current keypress (somewhat fast) and if they match, it's considered input.  Kinda goofy but thats how Im told it works. This could play havoc with AHK.  I would search the forums here for that post, it was informative.

 

--Oozr



DarkRandom
  • Members
  • 51 posts
  • Last active: Sep 28 2013 07:20 AM
  • Joined: 30 Aug 2013

I think I do understand what you're trying to do: an auto ward jump with lee sin, right?

 

I tried to do it myself but apparently LoL don't recognize any key except 'enter'. The thing is... The keys are being sent since I see them being pressed if I open the chat in-game but they just don't work when not in chat. In short: they work on the in-game chat but in the game itself the only key that works is 'Enter', the one that opens the chat.

 

I tried send, sendinput, sendevent, sendplay, sendraw, controlsend and none worked so far.

 

Yeah, I don't know. I will wait someone that might understand what's going on.

 

Edit: For future reference, I also tried with #UseHook and #InstallKeybdHook.



JonnyE
  • Members
  • 4 posts
  • Last active: Sep 10 2013 08:11 PM
  • Joined: 07 Sep 2013

Yeah, exactly, ward jump with Lee. The script i posted above works for me, running it as admin is important, otherwise it wont work for me.

I have my ward from Item place 2 Smartcast set to "2" and my W skill Smartcast set to "3".



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

In order for an hotkey to work in LoL.

 

2 things:

1: You MUST run in windowed mode!! This is critical.

2: Your script MUST be run as administrator if using an OS above XP.

 

This is why your hotkey doesn't do anything in LoL. These two things are absolutely necessary for AHK

to work!!!


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


JonnyE
  • Members
  • 4 posts
  • Last active: Sep 10 2013 08:11 PM
  • Joined: 07 Sep 2013

As said, the script i posted above works for me, also in full screen,but you have to run it as admin.



DarkRandom
  • Members
  • 51 posts
  • Last active: Sep 28 2013 07:20 AM
  • Joined: 30 Aug 2013

As said, the script i posted above works for me, also in full screen,but you have to run it as admin.

 

Oh, then sorry, I'm stupid. =P

Ok, if the first script I sent works, this is better to do what you want:

$2::
IfWinExist, League of Legends (TM) Client
{
        Send 2
	IfWinActive, League of Legends (TM) Client
	{
		Sleep 50
		Send 3
	}
}
else
	Send 2
return

Now you only need to adjust one sleep, if you really need to; and the hotkey will only work within the game. My advice is: you don't really need to set the sleep too low; to put in perspective, the average human reaction time is 215ms, so 50ms is already fast enough - if the game can handle that, of course.



Oozr
  • Members
  • 59 posts
  • Last active: Sep 14 2013 11:57 PM
  • Joined: 13 Aug 2013

You might also check the help file for SetKeyDelay.

With this you can stretch the keypress if needed.  I've had to do this in other games I've played

 

Glad this worked out.

 

--Oozr



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

DarkRandom is correct. Your Sleep time is too low. You are not actually sleeping 5 mili due to rounding of the function.

 

From Sleep Documentation:

[quote]

Due to the granularity of the OS's time-keeping system, Delay is typically rounded up to the nearest multiple of 10 or 15.6 milliseconds (depending on the type of hardware and drivers installed). For example, a delay between 1 and 10 (inclusive) is equivalent to 10 or 15.6 on most Windows NT/2000/XP systems. To achieve a shorter delay, see Examples.

[/quote}


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


Butters
  • Members
  • 22 posts
  • Last active: Mar 08 2014 02:00 AM
  • Joined: 15 Sep 2013

SetTimer, gRuntime, 100

gRuntime:
  WinGet, pName, ProcessName, A
  if pName = NAME OF THE PROCESS IN TASKMANAGER
  {
  Suspend, off
  }
  else
  {
  Suspend, on
  }
return

 

this may be useful instead of putting it into the trigger might speed things up having this on top.

it will suspend the script everywhere except LoL

then you can just put like this example where it will choose your spell and click for you also wherever your mouse is positioned

that way you can just mouse over and press 2

2::

  Send 2

  Sleep 50

  Send Click       ;click at current position

  Sleep 50

  Send 3

  Sleep 50

  Send Click      ; again for second spell

return