Sign in to follow this  
Followers 0
LordSlippy

If Radio is checked

6 posts in this topic

I'm trying to add this into a script.

Let's say $CurrentlyIK = GuiCtrlCreateRadio("Inn Keeper", 20, 290, 80, 20)

is checked, how would I make it change the value in the .ini from 0 to 1

and when its unchecked, change the value in the .ini back to 0

I have looked in the help file and cannot seem to find this.

Any help?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm trying to add this into a script.

Let's say $CurrentlyIK = GuiCtrlCreateRadio("Inn Keeper", 20, 290, 80, 20)

is checked, how would I make it change the value in the .ini from 0 to 1

and when its unchecked, change the value in the .ini back to 0

I have looked in the help file and cannot seem to find this.

Any help?

<{POST_SNAPBACK}>

While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG =  $CurrentlyIK
            If GUICtrlRead( $CurrentlyIK) = $GUI_CHECKED Then
                IniWrite(file,section,keyword,1)
            Else
                IniWrite(file,section,keyword,0)
            EndIf
    EndSelect
WEnd
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG =  $CurrentlyIK
            If GUICtrlRead( $CurrentlyIK) = $GUI_CHECKED Then
                IniWrite(file,section,keyword,1)
            Else
                IniWrite(file,section,keyword,0)
            EndIf
    EndSelect
WEnd

<{POST_SNAPBACK}>

Thank you for the code.

It's not working for me though, I'm sure im doing something wrong. But I have

While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG =  $CurrentlyIK
            If GUICtrlRead( $CurrentlyIK) = $GUI_CHECKED Then
                IniWrite("WhereToGo.ini","Currently at","InnKeeper",1)
            Else
                IniWrite("WhereToGo.ini","Currently at","InnKeeper",0)
                            EndIf
    EndSelect
WEnd

So I run it, click innkeeper, then open WhereToGo.ini and its still 0.

I should probably post the whole code--

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:        Genocide <myemail@nowhere.com>
;
; Script Function:
;   Template AutoIt script.
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

Global $IniRead_Wins = IniWrite("WhereToGo.ini", "Currently at", "Zeplin", 0)
Global $IniRead_Wins = IniWrite("WhereToGo.ini", "Currently at", "WindRider", 0)
Global $IniRead_Wins = IniWrite("WhereToGo.ini", "Currently at", "InnKeeper", 0)
Global $IniRead_Wins = IniWrite("WhereToGo.ini", "Going to", "AuctionHouse", 0)
Global $IniRead_Wins = IniWrite("WhereToGo.ini", "Going to", "WindRider", 0)
Global $IniRead_Wins = IniWrite("WhereToGo.ini", "Going to", "Zeplin", 0)


$main_Window = GuiCreate("MyGUI", 392, 350,(@DesktopWidth-392)/2, (@DesktopHeight-323)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUISetState(@SW_SHOW)

; MENU 
$File = GuiCtrlCreateMenu("File")
$Options = GuiCtrlCreateMenu("Options")
$About = GuiCtrlCreateMenu("About")
$Help = GuiCtrlCreateMenu("Help")

;Menu Items
$exititem = GUICtrlCreateMenuitem ("Exit",$file)
$aboutitem = GUICtrlCreateMenuitem ("About",$About)

$GoingTo = GuiCtrlCreateGroup("Where to go", 280, 90, 110, 110)
$GoingToZep = GuiCtrlCreateRadio("Zeplin", 290, 110, 90, 20)
$GoingToAH = GuiCtrlCreateRadio("Auction House", 290, 140, 90, 20)
$GoingToWR = GuiCtrlCreateRadio("Wind Rider", 290, 170, 90, 20)
$CurrentlyAt = GuiCtrlCreateGroup("Where you are", 10, 210, 100, 110)
$CurrentlyWR = GuiCtrlCreateRadio("Wind Rider", 20, 230, 80, 20)
$CurrentlyZep = GuiCtrlCreateRadio("Zeplin", 20, 260, 80, 20)
$CurrentlyIK = GuiCtrlCreateRadio("Inn Keeper", 20, 290, 80, 20)
$EditManually = GuiCtrlCreateButton("Edit Manually", 290, 300, 100, 20)
$AutoGo_Pic = GuiCtrlCreatePic("Autogo.bmp", 20, 10, 200, 70)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $EditManually
        Run(@comspec & " /c notepad WhereToGo.ini","",@SW_HIDE)
        
    Case $msg = $exititem
        ExitLoop
        
   While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG =  $CurrentlyIK
            If GUICtrlRead( $CurrentlyIK) = $GUI_CHECKED Then
                IniWrite("WhereToGo.ini","Currently at","InnKeeper",1)
            Else
                IniWrite("WhereToGo.ini","Currently at","InnKeeper",0)
                            EndIf
    EndSelect
WEnd

    Case $msg = $aboutitem
MsgBox ( 0, "About", "     World Of Warcraft Task Automater -- By Genocide" )

        
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;
    EndSelect
WEnd
Exit

    
#endregion --- GuiBuilder generated code End ---

and my .ini looks like

[Currently at]
Zeplin=0
WindRider=0
InnKeeper=0

[Going to]
AuctionHouse=0
WindRider=0
Zeplin=0

Share this post


Link to post
Share on other sites

Looking at your code, was wondering why the 2 while loops? only one needed.

for example:

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $EditManually
            Run(@ComSpec & " /c notepad WhereToGo.ini", "", @SW_HIDE)
            
        Case $msg = $exititem
            ExitLoop
            
        Case $msg = $CurrentlyIK
            If GUICtrlRead($CurrentlyIK) = $GUI_CHECKED Then
                IniWrite("WhereToGo.ini", "Currently at", "InnKeeper", 1)
            Else
                IniWrite("WhereToGo.ini", "Currently at", "InnKeeper", 0)
            EndIf
            
        Case $msg = $aboutitem
            MsgBox(0, "About", "       World Of Warcraft Task Automater -- By Genocide")
            
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;
    EndSelect
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thank you very much, I must have looked that over.

I am stuck yet again though. I got all it to write to 1 when it is checked, but it never goes back to 0, so I end up with all of the equalling 1

I tried

Case $msg = $CurrentlyWR
            If GUICtrlRead($CurrentlyWR) = $GUI_UNCHECKED Then
                IniWrite("WhereToGo.ini", "Currently at", "WindRider", 0)
            Else
                IniWrite("WhereToGo.ini", "Currently at", "WindRider", 1)
            EndIf

But it didn't work.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Looking at your code, you have them grouped so you'll have to unset the ini flag when another option is checked

example:

Case $msg = $CurrentlyIK
            IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "InnKeeper", 1)
                IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "Zeplin", 0)
                IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "WindRider", 0)

            Case $msg = $CurrentlyZep
            IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "Zeplin", 1)
                IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "InnKeeper", 0)
                IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "WindRider", 0)

            Case $msg = $CurrentlyWR
            IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "WindRider", 1)
                IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "Zeplin", 0)
                IniWrite(@ScriptDir & "\WhereToGo.ini", "Currently at", "InnKeeper", 0)

should be able to case each one similar

won't need the if statements with them grouped

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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