LongBowNZ Posted July 27, 2007 Share Posted July 27, 2007 Hi, would like some help to get this script working. It creates the GUI fine, but when i click on any of the buttons battlefield doesn't start. What does happen though is it creates a file called BF1942.pid in the script directory with some numbers in it. The code is probably messed up (it's my first script) so any ideas or improvements are appreciated. #NoTrayIcon #include <GUIConstants.au3> $BfDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\EA GAMES\Battlefield 1942", "GAMEDIR") $BfExe = $BfDir & "\BF1942.exe" $ModDir = $BfDir & "\Mods\" GUICreate("BF42ML", 150, 200) GUISetIcon("icon.ico") GUISetState () $button1 = GUICtrlCreateButton ("Battlefield 1942", 0, 0, 150, 40) $button2 = GUICtrlCreateButton ("DC Extended", 0, 40, 150, 40) $button3 = GUICtrlCreateButton ("DC Final", 0, 80, 150, 40) $button4 = GUICtrlCreateButton ("Desert Combat", 0, 120, 150, 40) $button5 = GUICtrlCreateButton ("Transformers", 0, 160, 150, 40) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run($BfExe & " " & "+restart 1") Case $msg = $button2 Run($BfExe & " " & "+restart 1 +DC_Extended") Case $msg = $button3 Run($BfExe & " " & "+restart 1 +DC_Final") Case $msg = $button4 Run($BfExe & " " & "+restart 1 +DesertCombat") Case $msg = $button5 Run($BfExe & " " & "+restart 1 +Transformers") EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
DW1 Posted July 27, 2007 Share Posted July 27, 2007 (edited) Instead of just Run($BfExe & " " & "+restart 1 +DC_Extended")oÝ÷ Ù:òjëh×6Run(@ComSpec & " /c " & $BfExe & " " & "+restart 1 +DC_Extended", "", @SW_HIDE) Edit: Oops, too many quotes Edited July 27, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
LongBowNZ Posted July 27, 2007 Author Share Posted July 27, 2007 That solved the BF1942.pid problem but battlefield still wont load up, i opened up task manager and noticed when I clicked on the buttons a new process was added but then went away too quick to see what it was. New Code: #NoTrayIcon #include <GUIConstants.au3> $BfDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\EA GAMES\Battlefield 1942", "GAMEDIR") $BfExe = $BfDir & "\BF1942.exe" $ModDir = $BfDir & "\Mods\" GUICreate("BF42ML", 150, 200) GUISetIcon("icon.ico") GUISetState () $button1 = GUICtrlCreateButton ("Battlefield 1942", 0, 0, 150, 40) $button2 = GUICtrlCreateButton ("DC Extended", 0, 40, 150, 40) $button3 = GUICtrlCreateButton ("DC Final", 0, 80, 150, 40) $button4 = GUICtrlCreateButton ("Desert Combat", 0, 120, 150, 40) $button5 = GUICtrlCreateButton ("Transformers", 0, 160, 150, 40) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run(@ComSpec & " /c " & '$BfExe & " " & "+restart 1"', "", @SW_HIDE) Case $msg = $button2 Run(@ComSpec & " /c " & '$BfExe & " " & "+restart 1 +DC_Extended"', "", @SW_HIDE) Case $msg = $button3 Run(@ComSpec & " /c " & '$BfExe & " " & "+restart 1 +DC_Final"', "", @SW_HIDE) Case $msg = $button4 Run(@ComSpec & " /c " & '$BfExe & " " & "+restart 1 +DesertCombat"', "", @SW_HIDE) Case $msg = $button5 Run(@ComSpec & " /c " & '$BfExe & " " & "+restart 1 +Transformers"', "", @SW_HIDE) EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
Helge Posted July 27, 2007 Share Posted July 27, 2007 You need to set the workingdir to the game's directory.. This works for me :$BfDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\EA GAMES\Battlefield 1942", "GAMEDIR") $BfExe = $BfDir & "\BF1942.exe" Run($BfExe, $BfDir)@danwilli : Why use @comspec in this case? Link to comment Share on other sites More sharing options...
LongBowNZ Posted July 27, 2007 Author Share Posted July 27, 2007 How do I add the commands into the target? e.g.: +restart 1 - Stops the startup video from playing. +game modname - Loads a certain mod at startup. Link to comment Share on other sites More sharing options...
DW1 Posted July 27, 2007 Share Posted July 27, 2007 (edited) Like This: #NoTrayIcon #include <GUIConstants.au3> $BfDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\EA GAMES\Battlefield 1942", "GAMEDIR") $BfExe = $BfDir & "\BF1942.exe" $ModDir = $BfDir & "\Mods\" GUICreate("BF42ML", 150, 200) GUISetIcon("icon.ico") GUISetState () $button1 = GUICtrlCreateButton ("Battlefield 1942", 0, 0, 150, 40) $button2 = GUICtrlCreateButton ("DC Extended", 0, 40, 150, 40) $button3 = GUICtrlCreateButton ("DC Final", 0, 80, 150, 40) $button4 = GUICtrlCreateButton ("Desert Combat", 0, 120, 150, 40) $button5 = GUICtrlCreateButton ("Transformers", 0, 160, 150, 40) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run(@ComSpec & " /c " & $BfExe & " " & "+restart 1", "", @SW_HIDE) Case $msg = $button2 Run(@ComSpec & " /c " & $BfExe & " " & "+restart 1 +DC_Extended", "", @SW_HIDE) Case $msg = $button3 Run(@ComSpec & " /c " & $BfExe & " " & "+restart 1 +DC_Final", "", @SW_HIDE) Case $msg = $button4 Run(@ComSpec & " /c " & $BfExe & " " & "+restart 1 +DesertCombat", "", @SW_HIDE) Case $msg = $button5 Run(@ComSpec & " /c " & $BfExe & " " & "+restart 1 +Transformers", "", @SW_HIDE) EndSelect WEnd Exit EDIT: Sorry man, my example had too many quotes in it... now this should work Edited July 27, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
LongBowNZ Posted July 27, 2007 Author Share Posted July 27, 2007 Tried this and +restart 1 seems to work but +"modname" doesn't...? #NoTrayIcon #include <GUIConstants.au3> $BfDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\EA GAMES\Battlefield 1942", "GAMEDIR") $BfExe = $BfDir & "\BF1942.exe" GUICreate("BF42ML", 150, 200) GUISetIcon("icon.ico") GUISetState () $button1 = GUICtrlCreateButton ("Battlefield 1942", 0, 0, 150, 40) $button2 = GUICtrlCreateButton ("DC Extended", 0, 40, 150, 40) $button3 = GUICtrlCreateButton ("DC Final", 0, 80, 150, 40) $button4 = GUICtrlCreateButton ("Desert Combat", 0, 120, 150, 40) $button5 = GUICtrlCreateButton ("Transformers", 0, 160, 150, 40) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run($BfExe & " " & "+restart 1", $BfDir) Case $msg = $button2 Run($BfExe & " " & "+restart 1 +DC_Extended", $BfDir) Case $msg = $button3 Run($BfExe & " " & "+restart 1 +DC_Final", $BfDir) Case $msg = $button4 Run($BfExe & " " & "+restart 1 +DesertCombat", $BfDir) Case $msg = $button5 Run($BfExe & " " & "+restart 1 +Transformers", $BfDir) EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
LongBowNZ Posted July 27, 2007 Author Share Posted July 27, 2007 @danwilli Nothing happens when I click on the buttons. When i tried my above code it loaded up BF and didnt play the startup video , but it doesn't load up any of the mods. I don't know why it would use "+restart 1" but not "+"modname".. Link to comment Share on other sites More sharing options...
LongBowNZ Posted July 27, 2007 Author Share Posted July 27, 2007 (edited) Got it to work , I forgot to add something, its "+game modname" not "+modname" . Thanks for your help danwilli EDIT: Code if you want to see it #NoTrayIcon #include <GUIConstants.au3> $BfDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\EA GAMES\Battlefield 1942", "GAMEDIR") $BfExe = $BfDir & "\BF1942.exe" GUICreate("BF42ML", 150, 200) GUISetIcon("icon.ico") GUISetState () $button1 = GUICtrlCreateButton ("Battlefield 1942", 0, 0, 150, 40) $button2 = GUICtrlCreateButton ("DC Extended", 0, 40, 150, 40) $button3 = GUICtrlCreateButton ("DC Final", 0, 80, 150, 40) $button4 = GUICtrlCreateButton ("Desert Combat", 0, 120, 150, 40) $button5 = GUICtrlCreateButton ("Transformers", 0, 160, 150, 40) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 Run($BfExe & " " & "+restart 1", $BfDir) Case $msg = $button2 Run($BfExe & " " & "+restart 1 +game DC_Extended", $BfDir) Case $msg = $button3 Run($BfExe & " " & "+restart 1 +game DC_Final", $BfDir) Case $msg = $button4 Run($BfExe & " " & "+restart 1 +game DesertCombat", $BfDir) Case $msg = $button5 Run($BfExe & " " & "+restart 1 +game Transformers", $BfDir) EndSelect WEnd Exit Edited July 27, 2007 by LongBowNZ 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