will88 Posted October 24, 2008 Share Posted October 24, 2008 expandcollapse popup#include <GuiConstantsEx.au3> $ini = @Scriptdir & "\Settings.ini" $StartHotKey = IniRead($ini,"Settings","Start","") $StopHotKey = IniRead($ini,"Settings","Stop","") If Not FileExists($ini) Then FileWrite($ini,"") IniWrite($ini,"Settings","ToolTip","0") IniWrite($ini,"Settings","Logs","0") EndIf If Not $StopHotKey = "" And Not $StartHotKey = "" Then HotKeySet($StartHotKey,"Start") HotKeySet($StopHotKey,"Stop") EndIf ; GuiCreate("LevelBot By: Blacknight",506,165,0,373) GuiSetState() GUICtrlCreateTab(0,1,506,167) GUICtrlCreateTabItem("Meele") $Meele = GUICtrlCreateCheckbox("Enable Meele",150,95) GUICtrlCreateTabItem("Ranged") $Range = GUICtrlCreateCheckbox("Enable Ranged",150,95) GUICtrlCreateTabItem("Magic") $Magic = GUICtrlCreateCheckbox("Enable Magic",150,95) GUICtrlCreateTabItem("Prayer") $Prayer = GUICtrlCreateCheckbox("Enable Prayer",150,95) GUICtrlCreateTabItem("Clicker") $Clicker = GUICtrlCreateCheckbox("Enable Clicker",150,95) $ClickTime = GUICtrlCreateInput("50",60,48,40,20) GUICtrlCreateLabel("Click Every",5,50) $ExactMouse = GUICtrlCreateCheckbox("Enable Exact MousePosition",200,50) $HelpMousePos = GUICtrlCreateButton("?",184,52,15,15) $HelpClick = GUICtrlCreateButton("?",100,50,15,15) GUICtrlCreateTabItem("Settings") GUICtrlCreateLabel("Start Key:",5,35) $StartKey = GUICtrlCreateInput($StartHotKey,60,33,50,25) $HelpStartKey = GUICtrlCreateButton("?",115,36,15,15) GUICtrlCreateLabel("Stop Key:",5,70) $StopKey = GUICtrlCreateInput($StopHotKey,60,66,50,25) $HelpStopKey = GUICtrlCreateButton("?",115,70,15,15) $ToolTip = GUICtrlCreateCheckbox("Show Tooltips",200,50) $HelpToolTips = GUICtrlCreateButton("?",184,52,15,15) $Logs = GUICtrlCreateCheckbox("Enable Logs",200,95) $HelpLogs = GUICtrlCreateButton("?",184,98,15,15) While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Logs $readLOG = IniRead($ini,"Settings","Logs","") If $readLOG = "0" Then GuiCtrlSetState($Logs, $GUI_CHECKED) $LogSet = IniWrite($ini,"Settings","Logs","1") ElseIf $readLOG = "1" Then GuiCtrlSetState($Logs, $GUI_UNCHECKED) $LogSet = IniWrite($ini,"Settings","Logs","0") EndIf Case $StartKey IniWrite($ini,"Settings","Start",$StartKey) Case $StopKey IniWrite($ini,"Settings","Stop",$StopKey) Case $ToolTip $readTOOL = IniRead($ini,"Settings","ToolTip","") If $readTOOL = "0" Then GuiCtrlSetState($ToolTip, $GUI_CHECKED) $ToolSet = IniWrite($ini,"Settings","ToolTip","1") ElseIf $readTOOL = "1" Then GuiCtrlSetState($ToolTip, $GUI_UNCHECKED) $ToolSet = IniWrite($ini,"Settings","Logs","0") EndIf Case $ExactMouse GuiCtrlSetState($ExactMouse, $GUI_CHECKED) $Exact = IniWrite($ini,"Settings","ExactMouse","1") Case $Meele If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Meele,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) Case $Range If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Range,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $Prayer If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Prayer,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $Clicker If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Clicker,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $Magic If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Magic,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $HelpLogs MsgBox(0,"Help - Logs","If enabled it will keeps logs such as How Many Clicks/How long Bot ran/Time Bot ended/Errors etc.") Case $HelpToolTips MsgBox(0,"Help - ToolTips","If checked it will display tooltips of the status of the bot(Running/Stopped/FindingMob etc") Case $HelpMousePos MsgBox(0,"Help - MousePosition","If box is checked, it will click in an exact spot you have picked, else once started the mouse will just keep clicking until stoped. To set the MousePosition, Check the Box and go to the spot on screen you want to click on and press your Start Hotkey") Case $HelpClick MsgBox(0,"Help - ClickEvery","This is how often it will click in milliseconds, default is 50Ms") Case $HelpStartKey MsgBox(0,"Help - StartKey","This is the hotkey to use, to start clicking/moving etc. Please do not use single key letters, only special letters such as F1-F12 & Home/Insert/PageUp etc, for it will not start the bot") Case $HelpStopKey MsgBox(0,"Help - StopKey","This is the hotkey to use, to stop clicking/moving etc. Please do not use single key letters, only special letters such as F1-F12 & Home/Insert/PageUp etc, for it will not stop the bot") EndSwitch WEnd Func Start() EndFunc Func Stop() EndFunc Its just a gui with some buttons/tabs for settings at the moment that write to .ini file to remeber it, for the next time you open it. But, theres 2 problems with it, 1)The first one is just a minor problem, when you run the script the tab labled "Meele" the buttons on that tab dont show up until you switch to a different tab, and then back. 2)at the last tab, "Settings" When you click the "ToolTip" checkbox and the "Enable Logs" it works fine at first but when you mess with them for a bit by unchecking/checking ToolTip adventully gets inaccurate(the .ini file) How do I make this script work better? Thanks Password-Keeper Link to comment Share on other sites More sharing options...
will88 Posted October 24, 2008 Author Share Posted October 24, 2008 bump Password-Keeper Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 24, 2008 Share Posted October 24, 2008 (edited) 1) Bumping within 24 hours of your last post is considered rude.2) Your code isn't very legible, you'll get more help if you make it easier to read.3) Your code looks incomplete. You also have identical code segments in your above post. Why put the same code multiple times?Edit: Posting a more legible version of your code below. I'll go through it and perhaps someone else will now that it's easier to understand and not like a run-on sentence.expandcollapse popup#include <GuiConstantsEx.au3> $ini = @Scriptdir & "\Settings.ini" $StartHotKey = IniRead($ini,"Settings","Start","") $StopHotKey = IniRead($ini,"Settings","Stop","") If Not FileExists($ini) Then FileWrite($ini,"") IniWrite($ini,"Settings","ToolTip","0") IniWrite($ini,"Settings","Logs","0") EndIf If Not $StopHotKey = "" And Not $StartHotKey = "" Then HotKeySet($StartHotKey,"Start") HotKeySet($StopHotKey,"Stop") EndIf ; GuiCreate("LevelBot By: Blacknight",506,165,0,373) GuiSetState() GUICtrlCreateTab(0,1,506,167) GUICtrlCreateTabItem("Meele") $Meele = GUICtrlCreateCheckbox("Enable Meele",150,95) GUICtrlCreateTabItem("Ranged") $Range = GUICtrlCreateCheckbox("Enable Ranged",150,95) GUICtrlCreateTabItem("Magic") $Magic = GUICtrlCreateCheckbox("Enable Magic",150,95) GUICtrlCreateTabItem("Prayer") $Prayer = GUICtrlCreateCheckbox("Enable Prayer",150,95) GUICtrlCreateTabItem("Clicker") $Clicker = GUICtrlCreateCheckbox("Enable Clicker",150,95) $ClickTime = GUICtrlCreateInput("50",60,48,40,20) GUICtrlCreateLabel("Click Every",5,50) $ExactMouse = GUICtrlCreateCheckbox("Enable Exact MousePosition",200,50) $HelpMousePos = GUICtrlCreateButton("?",184,52,15,15) $HelpClick = GUICtrlCreateButton("?",100,50,15,15) GUICtrlCreateTabItem("Settings") GUICtrlCreateLabel("Start Key:",5,35) $StartKey = GUICtrlCreateInput($StartHotKey,60,33,50,25) $HelpStartKey = GUICtrlCreateButton("?",115,36,15,15) GUICtrlCreateLabel("Stop Key:",5,70) $StopKey = GUICtrlCreateInput($StopHotKey,60,66,50,25) $HelpStopKey = GUICtrlCreateButton("?",115,70,15,15) $ToolTip = GUICtrlCreateCheckbox("Show Tooltips",200,50) $HelpToolTips = GUICtrlCreateButton("?",184,52,15,15) $Logs = GUICtrlCreateCheckbox("Enable Logs",200,95) $HelpLogs = GUICtrlCreateButton("?",184,98,15,15) While 1 $msg = GuiGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Logs $readLOG = IniRead($ini,"Settings","Logs","") If $readLOG = "0" Then GuiCtrlSetState($Logs, $GUI_CHECKED) $LogSet = IniWrite($ini,"Settings","Logs","1") ElseIf $readLOG = "1" Then GuiCtrlSetState($Logs, $GUI_UNCHECKED) $LogSet = IniWrite($ini,"Settings","Logs","0") EndIf Case $StartKey IniWrite($ini,"Settings","Start",$StartKey) Case $StopKey IniWrite($ini,"Settings","Stop",$StopKey) Case $ToolTip $readTOOL = IniRead($ini,"Settings","ToolTip","") If $readTOOL = "0" Then GuiCtrlSetState($ToolTip, $GUI_CHECKED) $ToolSet = IniWrite($ini,"Settings","ToolTip","1") ElseIf $readTOOL = "1" Then GuiCtrlSetState($ToolTip, $GUI_UNCHECKED) $ToolSet = IniWrite($ini,"Settings","Logs","0") EndIf Case $ExactMouse GuiCtrlSetState($ExactMouse, $GUI_CHECKED) $Exact = IniWrite($ini,"Settings","ExactMouse","1") Case $Meele If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Meele,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) Case $Range If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Range,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $Prayer If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Prayer,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $Clicker If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Clicker,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Magic, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $Magic If $StartHotKey = "" Or $StopHotKey = "" Then MsgBox(0,"Error","You must set a hotkey under Settings Tab!") GUICtrlSetState($Magic,$GUI_UNCHECKED) EndIf GuiCtrlSetState($Range, $GUI_UNCHECKED) GuiCtrlSetState($Prayer, $GUI_UNCHECKED) GuiCtrlSetState($Clicker, $GUI_UNCHECKED) GUICtrlSetState($Meele, $GUI_UNCHECKED) Case $HelpLogs MsgBox(0,"Help - Logs","If enabled it will keeps logs such as How Many Clicks/How long Bot ran/Time Bot ended/Errors etc.") Case $HelpToolTips MsgBox(0,"Help - ToolTips","If checked it will display tooltips of the status of the bot(Running/Stopped/FindingMob etc") Case $HelpMousePos MsgBox(0,"Help - MousePosition","If box is checked, it will click in an exact spot you have picked, else once started the mouse will just keep clicking until stoped. To set the MousePosition, Check the Box and go to the spot on screen you want to click on and press your Start Hotkey") Case $HelpClick MsgBox(0,"Help - ClickEvery","This is how often it will click in milliseconds, default is 50Ms") Case $HelpStartKey MsgBox(0,"Help - StartKey","This is the hotkey to use, to start clicking/moving etc. Please do not use single key letters, only special letters such as F1-F12 & Home/Insert/PageUp etc, for it will not start the bot") Case $HelpStopKey MsgBox(0,"Help - StopKey","This is the hotkey to use, to stop clicking/moving etc. Please do not use single key letters, only special letters such as F1-F12 & Home/Insert/PageUp etc, for it will not stop the bot") EndSwitch WEnd Func Start() EndFunc Func Stop() EndFuncEdit 2: Just moved your GUISetState() to after everything is created (good practice) and everything shows up fine, about to test the ini settings, will post back with results.Edit 3: I think I know your problem. You're reading from an ini file which may not exist (even if you create it the values will be null) and you're not checking the actual checkbox state. You need to read the ini file once before everything is loaded, set the checkbox states, and then when one is clicked read its state and write to the ini file instead of what you're doing. Edited October 24, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] 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