Jump to content

Launch Multiple Processes?


nxc
 Share

Recommended Posts

I first tried this with a batch file, but since you can't launch a new process without the previous closing I have turned to autoit.

here's an example of what i have written in batch:

1. taskkill /f /IM explorer.exe
2. c:\..\..\VideoGame.exe
3. start explorer.exe

what it's doing here is killing explorer, launching my game. then when game closes; brings explorer back.

But my question is..

I need to be able to run 2 processes one after the other on Line 2

can this be done with autoit?

Link to comment
Share on other sites

Look at Run() and RunWait() in the helpfile.

I am testing the script, but I can't really get it working. I don't intend on continuing use of AutoIt, just a simple alternative for an issue I'm having. If anyone can please show me how to do this would save me a lot of time.

Thanks,

nxc

Edit: I'm trying a simple test of the script:

Run("StarCraft.exe", "%ProgramFiles%\StarCraft\", @SW_MAXIMIZE)
Works if I use "notepad.exe" though Edited by nxc
Link to comment
Share on other sites

Final working result:

; Kill Explorer if explorer.exe is running
If ProcessExists("explorer.exe") Then
    ShellExecute("taskkill", "/f /IM explorer.exe")
EndIf

; Wait until Explorer is dead and boot up Starcraft
ProcessWaitClose("explorer.exe")
ShellExecute("StarCraft.exe", "", "C:\Program Files (x86)\StarCraft\")
ShellExecute("LoaderX.exe","", "C:\Users\nxc\Documents\Broodwar Modules\iCCupKiller 1.0\")

; After Starcraft closes restart Explorer
ProcessWaitClose("StarCraft.exe")
Run("C:\Windows\explorer.exe")

works great :D

Link to comment
Share on other sites

Edit: I'm trying a simple test of the script:

Run("StarCraft.exe", "%ProgramFiles%\StarCraft\", @SW_MAXIMIZE)
Works if I use "notepad.exe" though

That's probably because you don't give any path for the exe-file, only a working directory. Try:

Run(@ProgramFilesDir & "\StarCraft\StarCraft.exe", @ProgramFilesDir & "\StarCraft\", @SW_MAXIMIZE)
Link to comment
Share on other sites

I first tried this with a batch file, but since you can't launch a new process without the previous closing I have turned to autoit.

here's an example of what i have written in batch:

1. taskkill /f /IM explorer.exe
2. c:\..\..\VideoGame.exe
3. start explorer.exe

what it's doing here is killing explorer, launching my game. then when game closes; brings explorer back.

But my question is..

I need to be able to run 2 processes one after the other on Line 2

can this be done with autoit?

In batch files "start" does let you start a program without having to wait for the previous to finish execution.

you can also use /d to set the working path if required.

REM batch file
start "" notepad.exe
start "" calc.exe

REM batch file
taskkill /f /IM explorer.exe
start "" "C:\Users\nxc\Documents\Broodwar Modules\iCCupKiller 1.0\LoaderX.exe"
start "" /wait "C:\Program Files (x86)\StarCraft\StarCraft.exe"
explorer.exe

If you do use autoit, you don't have to externally call taskkill, there's an internal autoit command, ProcessClose()

Link to comment
Share on other sites

In batch files "start" does let you start a program without having to wait for the previous to finish execution.

you can also use /d to set the working path if required.

REM batch file
start "" notepad.exe
start "" calc.exe

REM batch file
taskkill /f /IM explorer.exe
start "" "C:\Users\nxc\Documents\Broodwar Modules\iCCupKiller 1.0\LoaderX.exe"
start "" /wait "C:\Program Files (x86)\StarCraft\StarCraft.exe"
explorer.exe

If you do use autoit, you don't have to externally call taskkill, there's an internal autoit command, ProcessClose()

My way :D

#include <Process.au3>
#include <WinAPI.au3>

Func _GetHwndFromPID($PID)
    $hWnd = 0
    $stPID = DllStructCreate("int")
    Do
        $winlist2 = WinList()
        For $i = 1 To $winlist2[0][0]
            If $winlist2[$i][0] <> "" Then
                DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
                If DllStructGetData($stPID, 1) = $PID Then
                    $hWnd = $winlist2[$i][1]
                    ExitLoop
                EndIf
            EndIf
        Next
        Sleep(100)
    Until $hWnd <> 0
    Return $hWnd
EndFunc;==>_GetHwndFromPID

; Kill Explorer if explorer.exe is running
If ProcessExists("explorer.exe") Then
    ShellExecute("taskkill", "/f /IM explorer.exe")
EndIf

; Wait until Explorer is dead and boot up Starcraft
ProcessWaitClose("explorer.exe")
ShellExecute("StarCraft.exe", "", "C:\Program Files (x86)\StarCraft\")
Sleep(3000)

ShellExecute("LoaderX.exe","", "C:\Users\nxc\Documents\Broodwar Modules\iCCupKiller 1.0\")
Sleep(1500)
$list = ProcessList("LoaderX.exe")
for $i = 1 to $list[0][0]
    ControlSend("", "", _GetHwndFromPID($list[$i][1]), "{ENTER}")
next
Sleep(1500)
WinActivate("Brood War")

; After Starcraft closes restart Explorer
ProcessWaitClose("StarCraft.exe")
ProcessClose("LoaderX.exe")
ProcessWaitClose("LoaderX.exe")
Run("C:\Windows\explorer.exe")
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...