Sign in to follow this  
Followers 0
lopolop

Input box to INI

5 posts in this topic

#1 ·  Posted (edited)

i have another problem... i am trying to add a easy setup for a bot but it doesnt wnat to work..

here is what i have

Opt("GUIOnEventMode", 1)

GUICreate("Bot Setup",200,300)

$okbutton = GUICtrlCreateButton("OK",65,270,70,20)
GUICtrlSetOnEvent($okbutton, "okbutton")

$MainAttack = GUICtrlCreateInput("Main Attack",15,20,70,20)
$MASleep = GUICtrlCreateInput("Main Sleep",110,20,70,20)
$SlowAttack = GUICtrlCreateInput("Slow Attack",15,60,70,20)
$SASleep = GUICtrlCreateInput("Slow Sleep",110,60,70,20)
$FreezeAttack = GUICtrlCreateInput("Freeze Attack",15,100,70,20)
$FASleep = GUICtrlCreateInput("Slow Sleep",110,100,70,20)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
    
Func okbutton()
$Check_ini_Exsist = FileExists("Bot.ini")
    If $Check_ini_Exsist = 1 Then
        FileOpen("Bot.ini", 1)
            IniWrite("Bot.ini", "Attacks", "MainAttack", $MainAttack)
            IniWrite("Bot.ini", "AttackSleeps", "MASleep", $MASleep)
            IniWrite("Bot.ini", "Attacks", "SlowAttack", $SlowAttack)
            IniWrite("Bot.ini", "AttackSleeps", "SASleep", $SASleep)
            IniWrite("Bot.ini", "Attacks", "FreezeAttack", $FreezeAttack)
            IniWrite("Bot.ini", "AttackSleeps", "FASleep", $FASleep)
        FileClose("Bot.ini")
        MsgBox( 1, "YAH!", "You are now ready to run the Bot.")
        GUISetState(@SW_HIDE)
    Else
        MsgBox( 1, "INI Error", "No Bot.ini File was found.")
    EndIf
EndFunc

oddly... it changes the ini to the same exact number everytime....

Original INI:

; Bot Configuration File
;
;###########################

[Attacks]
MainAttack = 0
SlowAttack = 0
FreezeAttack = 0

[AttackSleeps]
MASleep = 0
SASleep = 0
FASleep = 0

After... i could put in anything... no matter what it changes too...

; Bot Configuration File
;
;###########################

[Attacks]
MainAttack =4
SlowAttack =6
FreezeAttack =8

[AttackSleeps]
MASleep =5
SASleep =7
FASleep =9

i dont understand at all whats happening...

just to note... this is my first time using GUI

Edited by lopolop

Share this post


Link to post
Share on other sites



Change

IniWrite("Bot.ini", "Attacks", "MainAttack", $MainAttack)
IniWrite("Bot.ini", "AttackSleeps", "MASleep", $MASleep)
IniWrite("Bot.ini", "Attacks", "SlowAttack", $SlowAttack)
IniWrite("Bot.ini", "AttackSleeps", "SASleep", $SASleep)
IniWrite("Bot.ini", "Attacks", "FreezeAttack", $FreezeAttack)
IniWrite("Bot.ini", "AttackSleeps", "FASleep", $FASleep)

To

IniWrite("Bot.ini", "Attacks", "MainAttack", GUICtrlRead($MainAttack))
IniWrite("Bot.ini", "AttackSleeps", "MASleep", GUICtrlRead($MASleep))
IniWrite("Bot.ini", "Attacks", "SlowAttack", GUICtrlRead($SlowAttack))
IniWrite("Bot.ini", "AttackSleeps", "SASleep", GUICtrlRead($SASleep))
IniWrite("Bot.ini", "Attacks", "FreezeAttack", GUICtrlRead($FreezeAttack))
IniWrite("Bot.ini", "AttackSleeps", "FASleep", GUICtrlRead($FASleep))

I also do not think that you require to check for existance of ini file. You also do not need fileopen or fileclose as it will be created if it does not exist.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

You are writing the control's controlID, not the control's value to the INI file which is why it is not working. Try changing

IniWrite("Bot.ini", "AttackSleeps", "FASleep", $FASleep)

to

IniWrite("Bot.ini", "AttackSleeps", "FASleep", GUICtrlRead($FASleep))

Check out GUICtrlRead in the help file.


“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Share this post


Link to post
Share on other sites

Thanks alot!

sorry for the late reply... i was just woundering... is there a way to actually close the gui? or just hide it.. or is it the same thing...


Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks alot!

sorry for the late reply... i was just woundering... is there a way to actually close the gui? or just hide it.. or is it the same thing...

You either hide it or destroy it, but you need to know the handle from when you created it:

$MyGuiHandle = GUICreate("Bot Setup",200,300)

GuiSetState(@SW_Hide, $MyGuiHandle); This will hide the gui

GuiSetState(@SW_Minimize, $MyGuiHandle) ; This will minimize the gui

GuiDelete($MyGuiHandle); This will destroy the gui

There is also a @SW_Disable switch, but I'm not sure what that one does yet (newbie answer).

Enjoy. :-)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  
Followers 0