Page 1 of 1

League macro only works once  Topic is solved

Posted: 03 Oct 2018, 17:47
by Ludenife
Hi.

I have an "antiflame" macro for League, that sends a motivational sentence when I press Enter, effectively disabling the chat.
It used to work fine, but now it only works for one game, and then if I start another one I have to reload the script.
This only happens in League windows, tested on other games/applications and it works as intended.

Here is the script:

Code: Select all

if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}

#If WinActive("ahk_class RiotWindowClass") || WinActive("ahk_class TankWindowClass")
*Enter::
*NumpadEnter::

Send, {Enter}
sleep, 100
Send, (It picks a sentence randomly from an array)
sleep, 100
Send, {Enter}

return
#If
Thanks.

Re: League macro only works once

Posted: 05 Oct 2018, 01:43
by Ludenife
Bump.
I don't know why it shows as solved, but it is not.
Thanks.

Re: League macro only works once

Posted: 05 Oct 2018, 06:35
by Rohwedder
Hallo,
only a try:

Code: Select all

GroupAdd, League, ahk_class RiotWindowClass
GroupAdd, League, ahk_class TankWindowClass
if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}

#IfWinActive ahk_group League
$*Enter::
$*NumpadEnter::

Send, {Enter}
sleep, 100
Send, (It picks a sentence randomly from an array)
sleep, 100
Send, {Enter}

return
#IfWinActive

Re: League macro only works once

Posted: 05 Oct 2018, 09:12
by Ludenife
Hi, thanks for answering.

I tried your code and the result is the same. It only works if the scripts is started, reloaded or unsuspended while the game is running. If the script starts before the game window opens, it won't work, as if it doesn't recognize the id and doesn't trigger the hotkey.
What I can't figure out is why it works with other games without a problem, like it used to do with this one. :crazy:

Re: League macro only works once

Posted: 12 Oct 2018, 06:35
by Ludenife
Still trying to fix it but no luck... Any ideas?

Re: League macro only works once

Posted: 13 Oct 2018, 00:58
by Rohwedder
Hallo,
I'm not a player, but Google says this is a well-known behavior of League.

Re: League macro only works once

Posted: 13 Oct 2018, 02:36
by swagfag
Maybe starting a new game unloads keyboard hooks. You can try suspending and unsuspending briefly on an timer to reload the hooks.

Re: League macro only works once

Posted: 14 Oct 2018, 08:01
by Ludenife
Rohwedder wrote:Hallo,
I'm not a player, but Google says this is a well-known behavior of League.
Hi, I can't find any recent info, most threads are from 2013-2014 and my scripts worked just fine like a year ago. Do they propose any solution?

I'm going to try the reload timer if everything else fails. Just discovered that launching "Window Spy" makes the macro work again too without reloading or unsuspending. :crazy:

Re: League macro only works once

Posted: 24 Oct 2018, 07:42
by swagfag
Ludenife wrote:
14 Oct 2018, 08:01
Just discovered that launching "Window Spy" makes the macro work again too without reloading or unsuspending.
that makes me even more inclined to believe it has something to do with how the keyboard hooks are interacting. LOL is probably loading its own hook, which overrides all other hooks.
try the following, run ur script, play a game, start a new one, verify that the script is no longer working, then start this script:

Code: Select all

$q::msgbox hook hotkey
finally, check if ur game script is working again. If it is, then its confirmed

Re: League macro only works once

Posted: 04 Dec 2018, 10:53
by Ludenife
swagfag wrote:
24 Oct 2018, 07:42
Ludenife wrote:
14 Oct 2018, 08:01
Just discovered that launching "Window Spy" makes the macro work again too without reloading or unsuspending.
that makes me even more inclined to believe it has something to do with how the keyboard hooks are interacting. LOL is probably loading its own hook, which overrides all other hooks.
try the following, run ur script, play a game, start a new one, verify that the script is no longer working, then start this script:

Code: Select all

$q::msgbox hook hotkey
finally, check if ur game script is working again. If it is, then its confirmed
Hi, sorry for the delay, I could not register in the forum nor post as a guest.

I tested it and it works, can I prevent the League hook from overriding my own or there is no solution?

Thanks for your time.

Re: League macro only works once

Posted: 04 Dec 2018, 11:19
by swagfag
u cant prevent it. what u can do is reload ur script's hook so as to override the one belonging to LOL. to do this u must suspend then unsuspend the script. u can do this manually urself in the scripts tray menu, but it would be easier to put it on a, say, 2 second timer that would do this automatically over and over again for you.

Code: Select all

Settimer reloadhooks, 2000
Return

reloadhooks:
Suspend On
Suspend Off
Return