Sometimes script works, sometimes not

Ask gaming related questions
Evil-e
Posts: 108
Joined: 04 Sep 2018, 11:09

Sometimes script works, sometimes not

29 Apr 2019, 00:34

AHK will not always work in Evolution GT :(

Code: Select all

                                sleep, 7500
                                send {enter down}
                                sleep, 50
                                send {enter up}
                                sleep, 500
                                send {enter down}
                                sleep, 50
                                send {enter up}
                                sleep, 100
                                send {enter down}
                                sleep, 50
                                send {enter up}
                                sleep, 500
                                send {enter down}
                                sleep, 50
                                send {enter up}
                                sleep, 2500
                                send {down down}
                                sleep, 50
                                send {down up}
                                sleep, 100
                                send {enter down}
                                sleep, 50
                                send {enter up}
                                sleep, 100
#IfWinActive ahk_exe EGT.exe                                ;tried with / without this line
#IfWinActive Evolution GT ahk_class Evolution GT            ;tried with / without this line
WinWait, ahk_exe EGT.exe
WinWaitClose, ahk_exe EGT.exe                               ;all below this line fails sometimes
ExitApp
return
$F12::ExitApp
return
e::up
d::down
s::left
f::right
t::esc
XButton1::y
XButton2::u
$RButton::
{
        send {q down}{enter down}
        keywait, RButton
        send {q up}{enter up}
}
return
MButton::
{
        send {esc down}
        sleep, 20
        send {esc up}
        sleep, 250
        send {down down}
        sleep, 20
        send {down up}
        sleep, 20
        send {enter down}
        sleep, 20
        send {enter up}
        sleep, 1000
        send {down down}
        sleep, 20
        send {down up}
        sleep, 20
        send {enter down}
        sleep, 20
        send {enter up}
        sleep, 500
        send {enter down}
        sleep, 20
        send {enter up}
        sleep, 100
}
return
WheelUp::
{
        send {up down}
        sleep, 50
        send {up up}
}
return
WheelDown::
{
        send {down down}
        sleep, 50
        send {down up}
}
return
The automated section of script works 100% of the time, while everything below WinWaitClose, fails to work sometimes.
When script fails and close game, AHK continues to run, as ExitApp does not work. When I re-launch the game a second time,
the entire script works 100% of the time and ExitApp works when game is closed.

Running latest version of AHK and windowed or full-screen borderless windowed-mode do not help.

Any ideas?

:morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Sometimes script works, sometimes not

30 Apr 2019, 14:58

try using

Code: Select all

Process, WaitClose, EGT.exe

Code: Select all

#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.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

sleep, 7500
send {enter down}
sleep, 50
send {enter up}
sleep, 500
send {enter down}
sleep, 50
send {enter up}
sleep, 100
send {enter down}
sleep, 50
send {enter up}
sleep, 500
send {enter down}
sleep, 50
send {enter up}
sleep, 2500
send {down down}
sleep, 50
send {down up}
sleep, 100
send {enter down}
sleep, 50
send {enter up}
sleep, 100


WinWaitActive, ahk_exe EGT.exe 

;try using this
Process, WaitClose, EGT.exe

ExitApp
return


#If WinActive("ahk_exe EGT.exe") or WinActive("Evolution GT ahk_class Evolution G")

$F12::ExitApp
return
e::up
d::down
s::left
f::right
t::esc
XButton1::y
XButton2::u
$RButton::
{
        send {q down}{enter down}
        keywait, RButton
        send {q up}{enter up}
}
return
MButton::
{
        send {esc down}
        sleep, 20
        send {esc up}
        sleep, 250
        send {down down}
        sleep, 20
        send {down up}
        sleep, 20
        send {enter down}
        sleep, 20
        send {enter up}
        sleep, 1000
        send {down down}
        sleep, 20
        send {down up}
        sleep, 20
        send {enter down}
        sleep, 20
        send {enter up}
        sleep, 500
        send {enter down}
        sleep, 20
        send {enter up}
        sleep, 100
}
return
WheelUp::
{
        send {up down}
        sleep, 50
        send {up up}
}
return
WheelDown::
{
        send {down down}
        sleep, 50
        send {down up}
}
return
:wave: There is always more than one way to solve a problem. ;)
Evil-e
Posts: 108
Joined: 04 Sep 2018, 11:09

Re: Sometimes script works, sometimes not

30 Apr 2019, 17:58

It is not only that AHK.exe will not close when game has been exited, but that it fails to work at all, beyond the auto-execute portion.
Since this auto-execution is prior to the #IfWinActive line, AHK would attempt to perform these actions if I launched it
with, lets say.... Battlefield 1942. The rest of the script would fail, exactly as one would expect, being the incorrect active window.

So, if the automated top portion did not exist at all, then AHK has zero effect on the game. Sorry I did not explain this in a more
comprehensive manor :(

Discovered a work around earlier today and begins with the following batch file script:

Code: Select all

@echo off

cd "D:\Games\Evolution GT"

start EGT.exe                                     ;launches the games executable

start Keymapping_Evolution_GT_ExitApp.exe         ;launches a dummy script (see below)

sleep 1                                           ;time for above script to exit, before launching the second

start Keymapping_Evolution_GT.exe                 ;this second script is the one you see in initial post

exit
My dummy "Keymapping_Evolution_GT_ExitApp.exe" script:

Code: Select all

                                sleep, 500
                                ExitApp
#IfWinActive ahk_exe EGT.exe
#IfWinActive Evolution GT ahk_class Evolution GT
WinWait, ahk_exe EGT.exe
WinWaitClose, ahk_exe EGT.exe
ExitApp
return
I found that running an AHK.exe script, then terminating that script and running AHK script again in the same launch process,
completely resolves the issue and 100% of the script works every time :wtf:

Any thoughts as to what is happening would be appreciated :)

:morebeard:

PS> This is like the 4th time I had to create an oddball solution to resolve some strange issue.... am I the only one? lol
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
User avatar
evilC
Posts: 4738
Joined: 27 Feb 2014, 12:30

Re: Sometimes script works, sometimes not

07 May 2019, 09:56

WinWaitClose, ahk_exe EGT.exe ;all below this line fails sometimes
Everything below that line is a hotkey, and as such is outside of the normal flow-of-control, so this line has zero effect on the rest of the script, it merely blocks the auto-execute thread, which will not affect firing of the hotkeys

Return to “Gaming”

Who is online

Users browsing this forum: adi1998adi and 29 guests