Jump to content
Sign in to follow this  
pcjunki

if radio button is selected then

Recommended Posts

I'm needing some assistance.
I have a gui, that we use to help manage our computers and network stuff.
i have radio buttons working that when selected, they pull data from text files, then i'm able to execute functions such as ping, and opening up a remote mmc to that pc ect ect

I'm trying to add a new gui button($editradio), that when pressed (depending on which radio button is pressed) will open up the text file that goes with that radio button.

here is my code (I've left allot of stuff out, and only put in what i felt is needed to help me accomplish this)

#Region ###Remote push###
$TabSheet1 = GUICtrlCreateTabItem("Remote Push")


$Group1 = GUICtrlCreateGroup(" ", 18, 55, 180, 505, $WS_BORDER, $WS_EX_CLIENTEDGE)
$Radio1 = GUICtrlCreateRadio("firstfloor", 25, 69, 113, 30)
$Radio2 = GUICtrlCreateRadio("2ndfloor", 25, 98, 113, 30)

$Group2 = GUICtrlCreateGroup(" ", 200, 56, 697, 641, $WS_BORDER, $WS_EX_CLIENTEDGE)
$Label1 = GUICtrlCreateLabel("Computer", 216, 69, 233, 25)
$input1 = GUICtrlCreateCombo("", 216, 92, 233, 25, BitOR($CBS_DROPDOWN, $WS_VSCROLL))
$PINGHOST = GUICtrlCreateButton("Ping", 216, 122, 91, 57)
$MMC = GUICtrlCreateButton("Remote" & @CRLF & "MMC", 455, 122, 91, 57, $bs_multiline)
$editradio = GUICtrlCreateButton("edit" & @CRLF & "list", 455, 415, 91, 57, $bs_multiline)

GUICtrlCreateTabItem("")
GUISetState(@SW_MAXIMIZE)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit


            #Region ###REMOTEPUSH###
         Case $Radio1
            GUICtrlSetData($input1, "")
            $Readcityhall = FileRead("\\server1\scripts\1stfloor.txt")
            GUICtrlSetData($input1, StringReplace($Readcityhall, @CRLF, "|"),1)


         Case $Radio2
            GUICtrlSetData($input1, "")
            $Readcityhall = FileRead("\\server1\scripts\2ndfloor.txt")
            GUICtrlSetData($input1, StringReplace($Readcityhall, @CRLF, "|"),1)
            
            #EndRegion ###Remote push###

        

        Case $PINGHOST
            $pc = GUICtrlRead($input1)
            Run(@ComSpec & ' /k ' & 'ping ' & $pc & ' -t')


        Case $MMC
            $pc = GUICtrlRead($input1)
            Run(@ComSpec & ' /c ' & 'compmgmt.msc /computer:\\' & $pc, "", @SW_HIDE)


         Case $editradio
                If GUICtrlRead($radio1) _IsPressed Then
                   shellExecute("\\server1\scripts\1stfloor.txt")
                Else
                ElseIf

 

Share this post


Link to post
Share on other sites

@pcjunki

Did you look in the Help file? :)

The example about GUICtrlCreateRadio() shows how to read the state of the Radio button.


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Example:

PS: When posting code please include the full code

Case $editradio
            Select
                Case BitAND(GUICtrlRead($Radio1), $GUI_CHECKED) = $GUI_CHECKED
                    MsgBox(4096, "Radio1", GUICtrlRead($Radio1, 1))
                Case BitAND(GUICtrlRead($Radio2), $GUI_CHECKED) = $GUI_CHECKED
                    MsgBox(4096, "Radio2", GUICtrlRead($Radio2, 1))
            EndSelect

 

Share this post


Link to post
Share on other sites

None of that fancy coding for checking a radio button/checkbox is needed. You can read the state of the radio button directly without using BitAnd.

Quote

From the help file:

For Checkbox and Radio controls only the $GUI_CHECKED (1), $GUI_UNCHECKED (4) or $GUI_INDETERMINATE (2) states are returned so the value can be used directly.

 

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...