Jump to content

Creating Radio Buttons To Perform Certain Actions


rayven
 Share

Recommended Posts

I have my IPDetection script that I'm modifying for a 2.0 update.

Right now, it's detecting both the lan and Public IP addresses. I wanted to create 2 radio buttons. Radio1: Public IP

Radio2: Lan IP

Once the user selects radio 1, it will get and display the PublicIP in a read-only edit box.

Once a user selects radio2, it will do the same thing, but display the lan IP address in a read-only box.

I think I have some code, though it's not correct I don't think:

GUICtrlCreateLabel("What IP Address Would You Like?" & @CRLF & "Select an IP to retrieve", 10, 10, 280, 20)
$hRadio_1 = GUICtrlCreateRadio("Public IP", 10, 10, 200, 20)
$hRadio_2 = GUICtrlCreateRadio("Lan IP", 10, 50, 200, 20)
Case $hRadio_1
$PublicIP = _GetIP()
Case $hRadio_2
$LanIP = @IPAddress1

I suppose that's the basic syntax of the radio button?

I suppose I could modify the ok button to say continue, but also it should know what selection the user chose from the radio button selected.

The rest of the script should copy the selected IP selection to the clipbard as well.

Right now, the rest of the script is:

GUICtrlCreateLabel("IP Addresses detected" & @CRLF & @CRLF & "The following were the IP addresses we found.", 10, 10, 280, 20)
$sText = "Public: " & $PublicIP & @CRLF & @CRLF & "Lan: " & @IPAddress1  & @CRLF
GUICtrlCreateEdit($sText, 10, 30, 280, 70, $ES_READONLY)
    GUICtrlCreateLabel("This information has been copied to the clipboard." & @CRLF & "You may dismiss this box by pressing OK", 10, 120, 280, 40)
$hButton = GUICtrlCreateButton("OK", 210, 210, 210, 210)
GUISetState(@Sw_Show)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $hButton
                GUIDelete($hGUI)
                ExitLoop
        EndSwitch
    WEnd
ClipPut($PublicIP & @CRLF & @IPAddress1)
Exit;
Edited by rayven
Link to comment
Share on other sites

You can't use "Case" statements while not in a Select/EndSelect or Switch/EndSwitch.

To solve your problem, you need to put appropriate entries in your While loop.

This is a basic example:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$Radio1 = GUICtrlCreateRadio("Radio1", 40, 40, 113, 17)
$Radio2 = GUICtrlCreateRadio("Radio2", 40, 72, 113, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Radio1
   MsgBox(0, "", "1")
  Case $Radio2
   MsgBox(0, "", "2")
 EndSwitch
WEnd

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...