nxc Posted September 23, 2009 Share Posted September 23, 2009 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.exewhat 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 2can this be done with autoit? Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 23, 2009 Share Posted September 23, 2009 Look at Run() and RunWait() in the helpfile. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
nxc Posted September 23, 2009 Author Share Posted September 23, 2009 (edited) 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 September 23, 2009 by nxc Link to comment Share on other sites More sharing options...
nxc Posted September 23, 2009 Author Share Posted September 23, 2009 Found a workaround Run not executing "starcraft.exe" just used ShellExecute instead. Link to comment Share on other sites More sharing options...
Yashied Posted September 23, 2009 Share Posted September 23, 2009 Ooo, StarCraft, I like it. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
nxc Posted September 23, 2009 Author Share Posted September 23, 2009 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 Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted September 23, 2009 Share Posted September 23, 2009 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) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
TurionAltec Posted September 24, 2009 Share Posted September 24, 2009 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 More sharing options...
nxc Posted September 24, 2009 Author Share Posted September 24, 2009 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 expandcollapse popup#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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now