Delta01 Posted September 30, 2007 Share Posted September 30, 2007 (edited) Hi,I'm making a code, with an .ini file. It was working, then i changed a few things and now it won't save the new values when i terminate the script.expandcollapse popup#include <GuiConstants.au3> Global $Paused, $Bar1 = "{F1}", $Bar2 = "{F2}", $Bar3 = "{F3}", $Bar4 = "{F4}", $msg = GuiGetMsg() HotKeySet("{F5}", "TogglePause") HotKeySet("{F6}", "Terminate") $inifile = "AFK_Weaponchanger_Config.ini" $iWep2 = IniRead($inifile, "Settings", "Wep2", "0") $iWep1 = IniRead($inifile, "Settings", "Wep1", "9") $iSpeed = IniRead($inifile, "Settings", "Speed", "8") $iOther = IniRead($inifile, "Settings", "Other", "7") $iBar = IniRead($inifile, "Settings", "Bar", "F1") $iWait = IniRead($inifile, "Settings", "WaitTime", "10") $iBuff = IniRead($inifile, "Settings", "BuffWhenWeaponchangeBack", "6") $i2Buff = IniRead($inifile, "Settings", "OtherBuffWhenWeaponchangeBack", "5") $main = GUICreate("AFK_Weaponchanger", 230, 430) GuiCtrlCreateGroup("Settings", 5, 5, -1, 330) $Label1 = GuiCtrlCreateLabel("Your alternative weapon is..", 10, 30) $Wep2 = GuiCtrlCreateInput($iWep2, 10, 50, 15, -1, $ES_NUMBER) $Label2 = GUICtrlCreateLabel("Your main weapon is..", 10, 80) $Wep1 = GuiCtrlCreateInput($iWep1, 10, 100, 15, -1, $ES_NUMBER) $Label3 = GuiCtrlCreateLabel("Your speed buff is..", 10, 130) $Speed = GuiCtrlCreateInput($iSpeed, 10, 150, 15, -1, $ES_NUMBER) $Label4 = GuiCtrlCreatelabel("Your other buff is..", 10, 180) $Other = GuiCtrlCreateInput($iOther, 10, 200, 15, -1, $ES_NUMBER) $Label5 = GuiCtrlCreateLabel("Your quickbar is..", 10, 230) $Bar = GuiCtrlCreateInput($iBar, 10, 250, 20, -1, $ES_UPPERCASE) $Label6 = GuiCtrlCreateLabel("Time to wait before buffing, in minutes..", 10, 280) $Wait = GuiCtrlCreateInput($iWait, 10, 300, 20, -1, $ES_NUMBER) $Help = GuiCtrlCreateMenu("&Help") $About = GuiCtrlCreateMenuItem("Help",$Help) $check = GuiCtrlCreateCheckBox("Start", 150, 310) $more = GuiCtrlCreateCheckBox("More", 100, 310) $HelpandHotkeys = GuiCtrlCreateButton("Help/Hotkeys", 80, 355, 80, 30) GuiSetState() GuiCtrlSetState($check, $GUI_UNCHECKED) $2nd = GUICreate("AFK_Weaponchanger", 230, 500) GuiCtrlCreateGroup("Settings", 5, 5, -1, 330) GuiCtrlCreateGroup("More", 5, 340, 210, 130) $Label1 = GuiCtrlCreateLabel("Your alternative weapon is..", 10, 30) $Wep2 = GuiCtrlCreateInput($iWep2, 10, 50, 15, -1, $ES_NUMBER) $Label2 = GUICtrlCreateLabel("Your main weapon is..", 10, 80) $Wep1 = GuiCtrlCreateInput($iWep1, 10, 100, 15, -1, $ES_NUMBER) $Label3 = GuiCtrlCreateLabel("Your speed buff is..", 10, 130) $Speed = GuiCtrlCreateInput($iSpeed, 10, 150, 15, -1, $ES_NUMBER) $Label4 = GuiCtrlCreatelabel("Your other buff is..", 10, 180) $Other = GuiCtrlCreateInput($iOther, 10, 200, 15, -1, $ES_NUMBER) $Label5 = GuiCtrlCreateLabel("Your quickbar is..", 10, 230) $Bar = GuiCtrlCreateInput($iBar, 10, 250, 20, -1, $ES_UPPERCASE) $Label6 = GuiCtrlCreateLabel("Time to wait before buffing, in minutes..", 10, 280) $Wait = GuiCtrlCreateInput($iWait, 10, 300, 20, -1, $ES_NUMBER) $buffLabel = GuiCtrlCreateLabel("Buff to use after weapon swap back", 10, 360) $buff = GuiCtrlCreateInput($iBuff, 10, 380, 15, -1, $ES_NUMBER) $2buffLabel = GUiCtrlCreateLabel("Alternative buff after weapon swap back", 10, 410) $2buff = GUiCtrlCreateInput($i2Buff, 10, 430, 15, -1) $More2 = GuiCtrlCreateCheckBox("More", 100, 445) $check2 = GuiCtrlCreateCheckBox("Start", 150, 445) $enable = GuiCtrlCreateCheckBox("Use", 50, 445) GuiSetState(@SW_HIDE, $2nd) GuiCtrlSetState($More2, $GUI_CHECKED) While 1 $msg = GuiGetMsg() $Read1 = GuiCtrlRead($Wep2) $Read2 = GuiCtrlRead($Wep1) $Read3 = GuiCtrlRead($Speed) $Read4 = GuiCtrlRead($Other) $Read5 = GuiCtrlRead($Bar) $Read6 = GuiCtrlRead($buff) $Read7 = GuiCtrlRead($2buff) $waiting = GuiCtrlRead($Wait)*60000 $iSleep = GuiCtrlRead($Wait) If $msg = $GUI_EVENT_CLOSE then Terminate() Endif If $msg = $About Then MsgBox(0, "Help", "When it says, 'Your alternative weapon is.,' that means put the number of the quickslot which that weapon is on below. Eg. My sword is on number 2, so i would put number 2." & @CRLF & "Time to wait before buffing, in minutes.. means how long should the script wait, before buffing again." & @CRLF & "Press F6 to close the script." & @CRLF & @CRLF & "Made by BoT90210, 0x33.org") Endif If $msg = $HelpandHotkeys Then MsgBox(48, "Help and Hotkeys", "Please fill in the boxes before unpausing the script." & @CRLF & "If you wish to edit them, please pause the script." & @CRLF & "The script will only work if silkroad is active.." & @CRLF & "If you are using the More Settings, you must tick the Use box to activate them" & @CRLF & "If you don't want to use one of the More Settings, enter - into the 2nd box." & @CRLF & "Press F6 to close the script") EndIf If GuiCtrlRead($more) = $GUI_CHECKED then GuiSetState(@SW_SHOW, $2nd) GuiSetState(@SW_HIDE, $main) Endif If GuiCtrlRead($More2) = $GUI_UNCHECKED Then GuiSetState(@SW_SHOW, $main) GuiSetState(@SW_HIDE, $2nd) GuiCtrlSetState($more, $GUI_UNCHECKED) GuiCtrlSetState($More2, $GUI_CHECKED) Endif If GUICtrlRead($check) = $GUI_CHECKED Then If ProcessExists("sro_client.exe") then ToolTip("AFK_WeaponSwitcher is running. Press F6 to close", 0, 0) WinWaitActive("SRO_Client") send("{END}") sleep(1100) If $Read5 = "F1" Then send($Bar1) ElseIf $Read5 = "F2" Then send($Bar2) ElseIf $Read5 = "F3" Then send($Bar3) ElseIf $Read5 = "F4" Then send($Bar4) EndIf sleep(500) Send($Read1) sleep(1500) Send($Read3) sleep(5000) Send($Read4) sleep(5000) Send($Read2) If GuiCtrlRead($enable) = $GUI_CHECKED Then sleep(1500) Send($Read6) sleep(5000) ElseIf GuiCtrlRead($2buff) = "-" then sleep(50) Else Send($Read7) sleep(5000) EndIf send("{INSERT}") sleep($waiting) Else MsgBox(48, "Silkroad is not open", "Please open Silkroad then try again") GuiCtrlSetState($check, $GUI_UNCHECKED) Endif EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep(50) ToolTip("AFK_Weaponchanger is paused - Press F5 to resume",0,0) WEnd ToolTip("") EndFunc Func Terminate() IniWrite($inifile, "Settings", "Wep2", $Read1) IniWrite($inifile, "Settings", "Wep1", $Read2) IniWrite($inifile, "Settings", "Speed", $Read3) IniWrite($inifile, "Settings", "Other", $Read4) IniWrite($inifile, "Settings", "Bar", $Read5) IniWrite($inifile, "Settings", "WaitTime", $iSleep) IniWrite($inifile, "Settings", "BuffWhenWeaponchangeBack", $Read6) IniWrite($inifile, "Settings", "OtherBuffWhenWeaponchangeBack", $Read7) Exit EndFuncWhat's wrong? As far as I can tell, it should be working!I use the same coding and it works in this code..expandcollapse popup#include <GuiConstants.au3> Global $Paused = 0 HotKeySet("{F5}", "Togglepause") HotKeySet("{F6}", "Close") $inifile = "BooYA's Spammer.ini" $iLine1 = IniRead($inifile, "SPAM", "Line1", "dont send") $iLine2 = IniRead($inifile, "SPAM", "Line2", "dont send") $iLine3 = IniRead($inifile, "SPAM", "Line3", "dont send") $iLine4 = IniRead($inifile, "SPAM", "Line4", "dont send") $iLine5 = IniRead($inifile, "SPAM", "Line5", "dont send") $iSleep = IniRead($inifile, "SLEEP", "Sleeptime", "1.5") $main = GuiCreate("BooYA's Spammer", 265, 450) $Line1 = GuiCtrlCreateInput($iLine1, 10, 55) $Line2 = GuiCtrlCreateInput($iLine2, 10, 85) $Line3 = GuiCtrlCreateInput($iLine3, 10, 115) $Line4 = GuiCtrlCreateInput($iLine4, 10, 145) $Line5 = GuiCtrlCreateInput($iLine5, 10, 175) $Close = GuiCtrlCreateButton("Close script", 87, 275, 100, 35) $Sleep = GuiCtrlCreateInPut($iSleep, 10, 230, 25, 20) $tab = GuiCtrlCreateTab(-1, -1) $check = GuiCtrlCreateCheckBox("Start", 100, 230) GuiCtrlCreateLabel("Delay inbetween messages, in seconds", 10, 205) GuiCtrlCreateLabel("Write: dont send (If you don't wish to use a line)" & @CRLF & "Enter what you wish to spam below", 10, 10) GuiCtrlCreateLabel("Made by BooYA©", 175, 435) GuiCtrlCreateLabel("Instructions: Run Silkroad, login then load the script." & @CRLF & "Fill in the boxes. Click on the chat box. Press F5" & @CRLF & "to stop (pause) the script. To start again tick Start" & @CRLF & "If you want to edit what you spam, please pause" & @CRLF & "the script first.", 10, 330) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $Close Exit EndSelect $Read1 = GuiCtrlRead($Line1) $Read2 = GuiCtrlRead($Line2) $Read3 = GuiCtrlRead($Line3) $Read4 = GuiCtrlRead($Line4) $Read5 = GuiCtrlRead($Line5) $SleepTime = GuiCtrlRead($Sleep)*1000 $sleeping = GuiCtrlRead($Sleep) If GuiCtrlRead($check) = $GUI_CHECKED then If $Read1 = "dont send" Then sleep(10) Else WinActivate("SRO_Client") WinWaitActive("SRO_Client") ControlSend("SRO_Client", "", "", GUICtrlRead($Line1), 1) sleep($SleepTime) ControlSend("SRO_Client", "", "", "{ENTER}") EndIf If $Read2 = "dont send" Then sleep(10) Else WinActivate("SRO_Client") WinWaitActive("SRO_Client") ControlSend("SRO_Client", "", "", GUICtrlRead($Line2), 1) sleep($SleepTime) ControlSend("SRO_Client", "", "", "{ENTER}") EndIf If $Read3 = "dont send" Then sleep(10) Else WinActivate("SRO_Client") WinWaitActive("SRO_Client") ControlSend("SRO_Client", "", "", GUICtrlRead($Line3), 1) sleep($SleepTime) ControlSend("SRO_Client", "", "", "{ENTER}") EndIf If $Read4 = "dont send" Then sleep(10) Else WinActivate("SRO_Client") WinWaitActive("SRO_Client") ControlSend("SRO_Client", "", "", GUICtrlRead($Line4), 1) sleep($SleepTime) ControlSend("SRO_Client", "", "", "{ENTER}") EndIf If $Read5 = "dont send" Then sleep(10) Else WinActivate("SRO_Client") WinWaitActive("SRO_Client") ControlSend("SRO_Client", "", "", GUICtrlRead($Line5), 1) sleep($SleepTime) ControlSend("SRO_Client", "", "", "{ENTER}") EndIf EndIf WEND Func TogglePause() GuiCtrlSetState($check, $GUI_UNCHECKED) EndFunc Func Close() IniWrite($inifile, "SPAM", "Line1", $Read1) IniWrite($inifile, "SPAM", "Line2", $Read2) IniWrite($inifile, "SPAM", "Line3", $Read3) IniWrite($inifile, "SPAM", "Line4", $Read4) IniWrite($inifile, "SPAM", "Line5", $Read5) IniWrite($inifile, "SLEEP", "Sleeptime", $sleeping) Exit EndFuncVery weird.. Edited September 30, 2007 by Delta01 Link to comment Share on other sites More sharing options...
Developers Jos Posted September 30, 2007 Developers Share Posted September 30, 2007 You are not using unique Controlhandles . E.G. $Wep2 is used in both GUIs this the first Ctrl isn't accessible anymore. SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
rover Posted September 30, 2007 Share Posted September 30, 2007 (edited) Delta01take a look at this post on resizing a guiCan you make a GUI bigger at runtime?I've changed your code to incorporate the gui resize and added a few changes you may want to check out for your future codingan ampersand, space and underscore "& _" can shorten a long messagebox line and wrap it to the next lineSwitch/Case statements look a little cleaner and apparently Switch is faster than If/Endif or Select/Case statementsyou may want to use a button (as shown in my code example) for expanding the GUI. e.g. "More/Less"as a Checkbox is a toggle on/off setting whereas a button is momentary or "One Shot"which makes for easier messageloop function coding in a while/wend loopjust some suggestionsEdit: wrapped lines problem fixedexpandcollapse popup#include <GuiConstants.au3> Opt("GUIResizeMode", $GUI_DOCKALL) ; *** Global $Paused, $Bar1 = "{F1}", $Bar2 = "{F2}", $Bar3 = "{F3}", $Bar4 = "{F4}", $msg = GuiGetMsg() HotKeySet("{F5}", "TogglePause") HotKeySet("{F6}", "Terminate") $inifile = "AFK_Weaponchanger_Config.ini" $iWep2 = IniRead($inifile, "Settings", "Wep2", "0") $iWep1 = IniRead($inifile, "Settings", "Wep1", "9") $iSpeed = IniRead($inifile, "Settings", "Speed", "8") $iOther = IniRead($inifile, "Settings", "Other", "7") $iBar = IniRead($inifile, "Settings", "Bar", "F1") $iWait = IniRead($inifile, "Settings", "WaitTime", "10") $iBuff = IniRead($inifile, "Settings", "BuffWhenWeaponchangeBack", "6") $i2Buff = IniRead($inifile, "Settings", "OtherBuffWhenWeaponchangeBack", "5") $main = GUICreate("AFK_Weaponchanger", 230, 430) GuiCtrlCreateGroup("Settings", 5, 5, -1, 330) $Label1 = GuiCtrlCreateLabel("Your alternative weapon is..", 10, 30) $Wep2 = GuiCtrlCreateInput($iWep2, 10, 50, 15, -1, $ES_NUMBER) $Label2 = GUICtrlCreateLabel("Your main weapon is..", 10, 80) $Wep1 = GuiCtrlCreateInput($iWep1, 10, 100, 15, -1, $ES_NUMBER) $Label3 = GuiCtrlCreateLabel("Your speed buff is..", 10, 130) $Speed = GuiCtrlCreateInput($iSpeed, 10, 150, 15, -1, $ES_NUMBER) $Label4 = GuiCtrlCreatelabel("Your other buff is..", 10, 180) $Other = GuiCtrlCreateInput($iOther, 10, 200, 15, -1, $ES_NUMBER) $Label5 = GuiCtrlCreateLabel("Your quickbar is..", 10, 230) $Bar = GuiCtrlCreateInput($iBar, 10, 250, 20, -1, $ES_UPPERCASE) $Label6 = GuiCtrlCreateLabel("Time to wait before buffing, in minutes..", 10, 280) $Wait = GuiCtrlCreateInput($iWait, 10, 300, 20, -1, $ES_NUMBER) $Help = GuiCtrlCreateMenu("&Help") $About = GuiCtrlCreateMenuItem("Help",$Help) $check = GuiCtrlCreateCheckBox("Start", 150, 310) $Expand_Button = GUICtrlCreateButton("More", 100, 310, 50, 20) ; *** $HelpandHotkeys = GuiCtrlCreateButton("Help/Hotkeys", 80, 355, 80, 30) ;-------------------------------------------------------------- ; *** $Group = GuiCtrlCreateGroup("More", 5, 340, 210, 130) GuiCtrlSetState($Group, $GUI_DISABLE + $GUI_HIDE) $buffLabel = GuiCtrlCreateLabel("Buff to use after weapon swap back", 10, 360) GuiCtrlSetState($buffLabel, $GUI_DISABLE + $GUI_HIDE) $buff = GuiCtrlCreateInput($iBuff, 10, 380, 15, -1, $ES_NUMBER) GuiCtrlSetState($buff, $GUI_DISABLE + $GUI_HIDE) $2buffLabel = GUiCtrlCreateLabel("Alternative buff after weapon swap back", 10, 410) GuiCtrlSetState($2buffLabel, $GUI_DISABLE + $GUI_HIDE) $2buff = GUiCtrlCreateInput($i2Buff, 10, 430, 15, -1) GuiCtrlSetState($2buff, $GUI_DISABLE + $GUI_HIDE) $enable = GuiCtrlCreateCheckBox("Use", 50, 445) GuiCtrlSetState($enable, $GUI_DISABLE + $GUI_HIDE) ;-------------------------------------------------------- GuiSetState() While 1 $msg = GuiGetMsg() $Read1 = GuiCtrlRead($Wep2) $Read2 = GuiCtrlRead($Wep1) $Read3 = GuiCtrlRead($Speed) $Read4 = GuiCtrlRead($Other) $Read5 = GuiCtrlRead($Bar) $Read6 = GuiCtrlRead($buff) $Read7 = GuiCtrlRead($2buff) $waiting = GuiCtrlRead($Wait)*60000 $iSleep = GuiCtrlRead($Wait) Switch $msg Case $GUI_EVENT_CLOSE Terminate() Case $About MsgBox(0, "Help", "When it says, 'Your alternative weapon is.,' that means put the number of the quickslot which that weapon" & _ " is on below." & @CRLF & "Eg. My sword is on number 2, so i would put number 2." & @CRLF & _ "Time to wait before buffing, in minutes.. means how long should the script wait, before buffing again." & @CRLF & _ "Press F6 to close the script." & @CRLF & @CRLF & "Made by BoT90210, 0x33.org") Case $HelpandHotkeys MsgBox(48, "Help and Hotkeys", "Please fill in the boxes before unpausing the script." & @CRLF & _ "If you wish to edit them, please pause the script." & @CRLF & _ "The script will only work if silkroad is active.." & @CRLF & _ "If you are using the More Settings, you must tick the Use box to activate them" & @CRLF & _ "If you don't want to use one of the More Settings, enter - into the 2nd box." & @CRLF & "Press F6 to close the script") Case $Expand_Button $GuiPos = WinGetPos($main) If $GuiPos[3] < 530 Then $Height = 530 $ButtonText = "Less" GuiCtrlSetState($HelpandHotkeys, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetPos($check, 150, 445) ;GUICtrlSetPos($Expand_Button, 100, 445) GuiCtrlSetState($Group, $GUI_ENABLE + $GUI_SHOW) GuiCtrlSetState($buffLabel, $GUI_ENABLE + $GUI_SHOW) GuiCtrlSetState($buff, $GUI_ENABLE + $GUI_SHOW) GuiCtrlSetState($2buffLabel, $GUI_ENABLE + $GUI_SHOW) GuiCtrlSetState($2buff, $GUI_ENABLE + $GUI_SHOW) GuiCtrlSetState($enable, $GUI_ENABLE + $GUI_SHOW) Else $Height = 462 $ButtonText = "More" GuiCtrlSetState($HelpandHotkeys, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetPos($check, 150, 310) ;GUICtrlSetPos($Expand_Button, 100, 310) GuiCtrlSetState($Group, $GUI_DISABLE + $GUI_HIDE) GuiCtrlSetState($buffLabel, $GUI_DISABLE + $GUI_HIDE) GuiCtrlSetState($buff, $GUI_DISABLE + $GUI_HIDE) GuiCtrlSetState($2buffLabel, $GUI_DISABLE + $GUI_HIDE) GuiCtrlSetState($2buff, $GUI_DISABLE + $GUI_HIDE) GuiCtrlSetState($enable, $GUI_DISABLE + $GUI_HIDE) EndIf GUICtrlSetData($Expand_Button, $ButtonText) WinMove($main, "", $GuiPos[0], $GuiPos[1], $GuiPos[2], $Height) EndSwitch If GUICtrlRead($check) = $GUI_CHECKED Then If ProcessExists("sro_client.exe") then ToolTip("AFK_WeaponSwitcher is running. Press F6 to close", 0, 0) WinWaitActive("SRO_Client") send("{END}") sleep(1100) Switch $Read5 Case "F1" send($Bar1) Case "F2" send($Bar2) Case "F3" send($Bar3) Case "F4" send($Bar4) EndSwitch sleep(500) Send($Read1) sleep(1500) Send($Read3) sleep(5000) Send($Read4) sleep(5000) Send($Read2) If GuiCtrlRead($enable) = $GUI_CHECKED Then sleep(1500) Send($Read6) sleep(5000) ElseIf GuiCtrlRead($2buff) = "-" then sleep(50) Else Send($Read7) sleep(5000) EndIf send("{INSERT}") sleep($waiting) Else MsgBox(48, "Silkroad is not open", "Please open Silkroad then try again") GuiCtrlSetState($check, $GUI_UNCHECKED) Endif EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep(50) ToolTip("AFK_Weaponchanger is paused - Press F5 to resume",0,0) WEnd ToolTip("") EndFunc Func Terminate() IniWrite($inifile, "Settings", "Wep2", $Read1) IniWrite($inifile, "Settings", "Wep1", $Read2) IniWrite($inifile, "Settings", "Speed", $Read3) IniWrite($inifile, "Settings", "Other", $Read4) IniWrite($inifile, "Settings", "Bar", $Read5) IniWrite($inifile, "Settings", "WaitTime", $iSleep) IniWrite($inifile, "Settings", "BuffWhenWeaponchangeBack", $Read6) IniWrite($inifile, "Settings", "OtherBuffWhenWeaponchangeBack", $Read7) Exit EndFunc Edited September 30, 2007 by rover I see fascists... 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