Jump to content
Sign in to follow this  
LongBowNZ

Script creates .pid file in script directory...?

Recommended Posts

LongBowNZ

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

Share this post


Link to post
Share on other sites
DW1

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 by danwilli

Share this post


Link to post
Share on other sites
LongBowNZ

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

Share this post


Link to post
Share on other sites
Helge

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?

Share this post


Link to post
Share on other sites
LongBowNZ

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.

Share this post


Link to post
Share on other sites
DW1

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 by danwilli

Share this post


Link to post
Share on other sites
LongBowNZ

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

Share this post


Link to post
Share on other sites
LongBowNZ

@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"..

Share this post


Link to post
Share on other sites
LongBowNZ

Got it to work :), I forgot to add something, its "+game modname" not "+modname" :).

Thanks for your help danwilli :P

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 by LongBowNZ

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.