The online racing simulator
Autohotkey
(3 posts, started )
Autohotkey
Hi guys this is a question for those familiar with AutoHotkey,

I have a script which I use to run LFS, it first opens LFS Strobe - then opening the strobe file, LFS Cops, then LFS using the run commands..

There are two things I would like to add to the script to do which is the following;

Check if the program is already running before running it, and if it is already running don't run it again.

If I close LFS, close all the other programs it opened.

This is the script atm;

Run D:\Stuff to keep\Live For Speed\strobe\LfsStrobe.exe
WinWait, Lfs Strobe by Tommy,
WinMove -1244, 170
WinWait, Lfs Strobe by Tommy,
IfWinNotActive, Lfs Strobe by Tommy, , WinActivate, Lfs Strobe by Tommy,
WinWaitActive, Lfs Strobe by Tommy,
MouseClick, left, 33, 346
Sleep, 100
WinWait, Open,
IfWinNotActive, Open, , WinActivate, Open,
WinWaitActive, Open,
Sleep, 400
MouseClick, left, 252, 384
Sleep, 100
MouseClick, left, 252, 384
Sleep, 100
WinWait, OK!,
IfWinNotActive, OK!, , WinActivate, OK!,
WinWaitActive, OK!,
MouseClick, left, 94, 128
Sleep, 100
Winmove,Lfs Strobe by Tommy,,,,201,206
Run D:\Junk\25 July 11\Si.lnk
WinWait, LFS Cops v1.1,
Winmove,-1034,174
Sleep, 100
Run D:\Lfs\LFS.exe

Anybody can help?
To check whether a program is already open or not, you can use IfWinExist the exact same way you use IfWinActive. You just have to tell AHK what to do depending on this.
When you want to close everything LFS has opened, I guess you want to use WinClose (see details on autohotkey's command reference page).
As it seems the script does nothing more once LFS is running, I think you could use a WinWaitClose command; that way, as soon as LFS closes, it will resume the script, in which you add the WinClose commands.

Something like this:
Run D:\Lfs\LFS.exe
WinWaitClose, Live For Speed
WinClose, Lfs Strobe by Tommy,,1 ; waiting 1 sec to be safe
; same for the other windows

For the program detection:
If not WinExist, Lfs Strobe
Run D:\Stuff to keep\Live For Speed\strobe\LfsStrobe.exe

I'm no pro at AHK however, so you may have to play with this a little before it works
Thanks very much, i'll try this

Edit, Worked a charm with some modifications, thanks!

Autohotkey
(3 posts, started )
FGED GREDG RDFGDR GSFDG