Auto-executing script for DiRT 3 crashing resolved Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Auto-executing script for DiRT 3 crashing resolved

19 Apr 2019, 12:23

The following script begins a series of commands 100ms after AHK.exe is launched:

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        F11::
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return
Works fine, but stops executing @ "F11" :(

I have written additional commands beyond this point , but they are ignored. I have many, many auto-executing scripts,
but this is the only one in which I have a usable key mixed within it

Is there a way to write this script, so that it will continue inputting commands until it reaches the #ifWinActive line?

:morebeard:

PS> I started another thread with this same script, but the question posed is distinctly different. I do not want to be a busy
bee and cross-germinate 2 questions in a single thread :crazy:
Last edited by Evil-e on 20 Apr 2019, 02:55, edited 2 times in total.
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Auto-executing script

19 Apr 2019, 12:44

use Gosub or Goto
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Auto-executing script

19 Apr 2019, 15:34

OK.... I have tried the following

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        <---------------------------  ;tried every variable of GoSub and Goto here.... launch AHK.exe gives error
                        F11::
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return
About 20 attempts with & without commas, ::, and every variation of which I can think and just don't know how to "write" GoSub or Goto into my script :(

Can you please elaborate on your reply, please :)

:morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Auto-executing script

19 Apr 2019, 15:38

what have u tried?

Code: Select all

; <---------------------------  tried every variable of GoSub and Goto here.... launch AHK.exe gives error
this is a comment. comments are ignored by the interpreter
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Auto-executing script

19 Apr 2019, 16:32

I have tried:

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        GoSub::
                        F11::
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        GoSub::F11
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        GoSub
                        F11::
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        GoSub,
                        F11::
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        GoSub,
                        {
                         F11::
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 1000
                        Run, "D:\Games\DiRT\DiRT 3\Keymapping_DiRT_3_GAMEPLAY.exe"
                        sleep, 2000                  ;script stops executing at this point
                        GoSub::
                        {
                         F11
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        ----------------------------> ;I would like to add additional commands here & beyond
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return
I have inserted Goto in place of GoSub in each of the above circumstances and tried a few others that I don't recall. I have searched
AHK forums for "GoSub" & "Goto", but could not find it actually "written" into a script that I could reverse-engineer into my own :(

:morebeard:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Auto-executing script

19 Apr 2019, 19:06

EUREKA :)

Many thanks....AGAIN (seems like I say that a lot to you!) swag* :)

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"                              ;legend #2
                        sleep, 500
                        GoSub, Label1
                        F11::                                                                   ;legend #3
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping_RESTART.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        Label1:
                        sleep, 11000                                                             ;legend #4
                        Run, "D:\Games\DiRT\DiRT 3\Launch Keymapping_DiRT_3_GAMEPLAY.bat"        ;legend #5
                        sleep, 500
                        ExitApp                                                                  ;legend #6
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
return
There are 2 AHK.exe files needed to play this game. One just to launch and restart if crashes, the other scripted for gameplay


Legend:
#1: short-cut to game launches a batch file, that in turn, launches "Keymapping_DiRT_3.exe" (the script you see above)
#2: Script launches the games executable
#3: "F11" is ONLY used if the game crashes during the launch process (crash is seen within about 5~8 seconds)
#4: Gives me 11 seconds to key a restart, if appears the game has crashed
#5: Batch file with a SLEEP 1 command prior to launching script that will be used during gameplay
#6: the launch script is exited and the gameplay script starts 500ms later

NOTE: "Launch Keymapping_DiRT_3_GAMEPLAY.bat" file is written with a SLEEP 3 command to allow the script to
terminate the games executable and then ExitApp
NOTE 2: Two batch files cannot be run simultaneously (at least not on Windows XP) so care had to be taken, so that
CMD commands would not "overlap" and be executed by a single AHK script that would ultimately self-terminate

If all of this looks totally insane just to play a computer game... well, it is! But since the game is really cool and is
well known to crash during launch (just google "DiRT 3 crashing" and you will see what I mean), this is far and away
the most efficient way to overcome the issues posed when the game crashes. It locks up the computer and the usual
CTRL+ALT+DELETE or ALT+TAB do nothing at all. Hard-crashing the computer and rebooting is the only sure alternative.
Sometimes, ALT+ENTER will enable windowed-mode and allow access to Task Bar to enable Task Manager and crash the
game that way. This script allows the press of a single key (2 or 3 times is usually enough, but 10 times can happen)
Regardless, I can be in the games menu within 30 seconds at the absolute worst case scenario, where it might have taken
as many reboots of computer to accomplish the same thing. Lemmetellya..... frustration sets in and I would play something
else, long before I rebooted even 5 times.

Fortunately, the AHK script will accept keyboard input, so how this all came about. Now, if I could just get the last 10 hours
back it took to get to this moment..... well, what would be the fun in that :superhappy:

Peace, swag :morebeard:


*just can't bring myself to call you Mr. Fag.... lol
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)
Evil-e
Posts: 262
Joined: 04 Sep 2018, 11:09

Re: Auto-executing script

20 Apr 2019, 02:50

UPDATE:

Funny, how I need to see my work spelled out.... to "see" it. The GoSub command ended up resolving more than I had initially realized and allows even more time to abort / restart process if game crashes.

THE FOLLOWING FILES WERE REQUIRED FOR THE ABOVE POST TO TAKE PLACE:
"Launch DiRT 3 & Keymapping.bat"...........................;initial batch file to begin launch process
"Keymapping_DiRT_3.exe
"Keymapping_DiRT_3_GAMEPLAY.exe"
"Launch DiRT 3 & Keymapping_RESTART.bat"...............;identical to initial batch, but has SLEEP 3 command
"Launch Keymapping_DiRT_3_GAMEPLAY.bat
"Launch DiRT 3 delete cache files.bat"........................;executed upon close of game to delete 1.5gb+ of replay cache on C:\ Drive

THE FOLLOWING FILES ARE NOW THE ONLY ONES NECESSARY:
"Launch DiRT 3 & Keymapping.bat"............................;now incorporates SLEEP 3 command and makes the "...RESTART.bat" unnecessary
"Keymapping_DiRT_3.exe
"Launch DiRT 3 delete cache files.bat"........................;executed upon close of game to delete 1.5gb of replay cache on C:\ Drive

The following contains the script of both my earlier AHK.exe files:

Code: Select all

                        sleep, 100
                        Run, "D:\Games\DiRT\DiRT 3\dirt3_game.exe"
                        sleep, 500
                        GoSub, Label1
                        F11::
                        {
                                Run "D:\Games\DiRT\DiRT 3\Launch DiRT 3 & Keymapping.bat"
                                sleep, 1000
                                Process, Close, dirt3_game.exe
                                sleep, 250
                                ExitApp
                        }
                        Label1:
                        sleep, 15000
#IfWinActive ahk_exe dirt3_game.exe
WinWaitNotActive, ahk_exe dirt3_game.exe
WinWaitClose, ahk_exe dirt3_game.exe
sleep, 250
Run, "D:\Games\DiRT\DiRT 3\Launch DiRT 3 delete cache files.bat"      ;deletes 1.5gb+ cache
sleep, 250
ExitApp
return
WheelUp::                  ;up arrow key to navigate menu (hand never has to leave the mouse)
{
        send {up down}
        sleep, 50
        send {up up}
}
return
WheelDown::                ;down arrow key to navigate menu (hand never has to leave the mouse)
{
        send {down down}
        sleep, 50
        send {down up}
}
return
$MButton::esc              ;enter / exit menu (hand never has to leave the mouse)
$LButton::                 ;hold LMB to rewind / replay horrific crash in which I just killed 10 spectators... lol
{
        send {F1 down}
        sleep, 100
        send {F1 up}
        sleep, 100
        send {F2 down}
        sleep, 500
        keywait, LButton    ;release LMB restarts gameplay when I have seen enough death & destruction
        send {F2 up}
        sleep, 100
        send {F12 down}
        sleep, 100
        send {F12 up}
        sleep, 1000
}
return
$RButton::enter            ;execute highlighted items in menu (there is no mouse cursor in this games menu)
$XButton1::                ;left arrow key to navigate menu & "n" to look left while driving in gameplay
        send {left down}{n down}
        keywait, XButton1
        send {left up}{n up}
}
return
$XButton2::                ;right arrow key to navigate menu & "m" to look right while driving in gameplay
{
        send {right down}{m down}
        keywait, XButton2
        send {right up}{m up}
}
return
in 95% of all games, I script E~D~S~F to move character, control vehicles and navigate menu options. Normally T key for "ESC", but that
5% of games only work with mouse buttons. It is very fluid to control 100% of a game from start to finish without the need to relocate my hands*

I doubt very much that anybody cares about all this, but this post is really about closure for me, more than info for you :)

Until next time.... "goodnight, Mama..... goodnight, Dad... goodnight, Stan.... goodnight, Johnboy :morebeard:

NOTE: I have added "DiRT 3 crashing" to title of thread, so in future searches one may stumble upon it and find a better way to
deal with the persistent crashing of this game.
NOTE 2: I am sure that many of you could see there was a better solution, but am more gratified to have figured it out with the
right nudge from swag

*when I have to scratch my balls or the cat DEMANDS pets..... all bets are off :shifty:
I have a bit of experience opening and sending commands to game console and CMD.exe... just ask :)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 334 guests