Rodders Posted July 5, 2008 Posted July 5, 2008 I still have a lot to learn with Autoit so I am hoping someone can help me with a couple of problems. I have written a script for launching game servers for my lan parties, the script works but as I want to add more buttons I am wondering if there is a more efficient way of coding it. At the moment the game icon is beside the button is it possible to have both the icon and text on the button. CODE#include <GUIConstants.au3> #include <Misc.au3> _Singleton("WinPE creator") Opt('MustDeclareVars', 1) Local $var1, $svr1, $var2, $svr2, $var3, $svr3 Local $var4, $svr4, $var5, $svr5, $var6, $svr6 Local $var7, $svr7, $var8, $svr8, $var9, $svr9 Local $var10, $svr10, $config, $logo1, $test Opt("GUIOnEventMode", 1) GUICreate("Server launcher", 400, 390) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $var1 = IniReadSection("game_config.ini", "button1") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var1[4][1] & "\" & $var1[2][1], -1, 16, 22, 32, 32) $svr1 = GUICtrlCreateButton( $var1[1][1], 50, 20, 140, 40) GUICtrlSetOnEvent($svr1, "Svr1") $var2 = IniReadSection("game_config.ini", "button2") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var2[4][1] & "\" & $var2[2][1], -1, 16, 82, 32, 32) $svr2 = GUICtrlCreateButton( $var2[1][1], 50, 80, 140, 40) GUICtrlSetOnEvent($svr2, "Svr2") $var3 = IniReadSection("game_config.ini", "button3") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var3[4][1] & "\" & $var3[2][1], -1, 16, 142, 32, 32) $svr3 = GUICtrlCreateButton( $var3[1][1], 50, 140, 140, 40) GUICtrlSetOnEvent($svr3, "Svr3") $var4 = IniReadSection("game_config.ini", "button4") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var4[4][1] & "\" & $var4[2][1], -1, 16, 202, 32, 32) $svr4 = GUICtrlCreateButton( $var4[1][1], 50, 200, 140, 40) GUICtrlSetOnEvent($svr4, "Svr4") $var5 = IniReadSection("game_config.ini", "button5") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var5[4][1] & "\" & $var5[2][1], -1, 16, 262, 32, 32) $svr5 = GUICtrlCreateButton( $var5[1][1], 50, 260, 140, 40) GUICtrlSetOnEvent($svr5, "Svr5") $var6 = IniReadSection("game_config.ini", "button6") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var6[4][1] & "\" & $var6[2][1], -1, 206, 22, 32, 32) $svr6 = GUICtrlCreateButton( $var6[1][1], 240, 20, 140, 40) GUICtrlSetOnEvent($svr6, "Svr6") $var7 = IniReadSection("game_config.ini", "button7") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var7[4][1] & "\" & $var7[2][1], -1, 206, 82, 32, 32) $svr7 = GUICtrlCreateButton( $var7[1][1], 240, 80, 140, 40) GUICtrlSetOnEvent($svr7, "Svr7") $var8 = IniReadSection("game_config.ini", "button8") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var8[4][1] & "\" & $var8[2][1], -1, 206, 142, 32, 32) $svr8 = GUICtrlCreateButton( $var8[1][1], 240, 140, 140, 40) GUICtrlSetOnEvent($svr8, "Svr8") $var9 = IniReadSection("game_config.ini", "button9") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var9[4][1] & "\" & $var9[2][1], -1, 206, 202, 32, 32) $svr9 = GUICtrlCreateButton( $var9[1][1], 240, 200, 140, 40) GUICtrlSetOnEvent($svr9, "Svr9") $var10 = IniReadSection("game_config.ini", "button10") If @error Then MsgBox(4096, "", "Unable to read INI file.") endif GUICtrlCreateIcon( $var10[4][1] & "\" & $var10[2][1], -1, 206, 262, 32, 32) $svr10 = GUICtrlCreateButton( $var10[1][1], 240, 260, 140, 40) GUICtrlSetOnEvent($svr10, "Svr10") $config = GUICtrlCreateButton( "Edit Config File", 140, 340, 160, 30) GUICtrlSetOnEvent($config, "Config") $logo1 = GUICtrlCreateIcon( "KR3-trans.ico", -1, 40, 330, 48, 48) GUISetState (@SW_SHOW) While 1 Sleep(1000) WEnd Func Svr1() ShellExecute( $var1[2][1], $var1[3][1], $var1[4][1]) EndFunc Func Svr2() ShellExecute( $var2[2][1], $var2[3][1], $var2[4][1]) EndFunc Func Svr3() ShellExecute( $var3[2][1], $var3[3][1], $var3[4][1]) EndFunc Func Svr4() ShellExecute( $var4[2][1], $var4[3][1], $var4[4][1]) EndFunc Func Svr5() ShellExecute( $var5[2][1], $var5[3][1], $var5[4][1]) EndFunc Func Svr6() ShellExecute( $var6[2][1], $var6[3][1], $var6[4][1]) EndFunc Func Svr7() ShellExecute( $var7[2][1], $var7[3][1], $var7[4][1]) EndFunc Func Svr8() ShellExecute( $var8[2][1], $var8[3][1], $var8[4][1]) EndFunc Func Svr9() ShellExecute( $var9[2][1], $var9[3][1], $var9[4][1]) EndFunc Func Svr10() ShellExecute( $var10[2][1], $var10[3][1], $var10[4][1]) EndFunc Func Config() ShellExecute("game_config.ini", "", @ScriptDir, "edit") EndFunc Func CLOSEClicked() Exit EndFunc
Rodders Posted July 5, 2008 Author Posted July 5, 2008 Almost forgot, this is the ini file the script reads CODE[button1] btn=Farcry Round 1 command=bin32\farcry_winsv.exe param="SProfile_run round1" workdir=C:\Program Files\Ubisoft\Crytek\Far Cry [button2] btn=Farcry Round 2 command=bin32\farcry_winsv.exe param="SProfile_run round2" workdir=C:\Program Files\Ubisoft\Crytek\Far Cry [button3] btn=Farcry Round 3 command=bin32\farcry_winsv.exe param="SProfile_run round3" workdir=C:\Program Files\Ubisoft\Crytek\Far Cry [button4] btn="Farcry Assault" command=bin32\farcry_winsv.exe param="SProfile_run assault" workdir=C:\Program Files\Ubisoft\Crytek\Far Cry [button5] btn="Vehicles pack" command=bin32\farcry_winsv.exe param=-MOD:vehiclespack "SProfile_run KR3_VP" workdir=C:\Program Files\Ubisoft\Crytek\Far Cry [button6] btn="Fear Round 1" command=FEARServer.exe param=-optionsfile round1 workdir=C:\Program Files\Sierra\FEARCombat [button7] btn="Fear Round 2" command=FEARServer.exe param=-optionsfile round2 workdir=C:\Program Files\Sierra\FEARCombat [button8] btn="Fear Round 3" command=FEARServer.exe param=-optionsfile round3 workdir=C:\Program Files\Sierra\FEARCombat [button9] btn="Enemy Territory" command=ETDED.exe param= +set sv_pure 1 +exec objective_server.cfg workdir=C:\Program Files\Wolfenstein - Enemy Territory [button10] btn="Fear" command=FEARServer.exe param=-optionsfile kr3
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