Jump to content

Begginer question


Frit
 Share

Recommended Posts

Here is how to get wether a checkbox or radio button is checked....

$GUI_UNCHECKED Radio or Checkbox will be unchecked

$GUI_CHECKED Radio or Checkbox will be checked

for buttons

While 1 ;Starts an INFINITE LOOP

$msg = GUIGetMsg() ;Listens to see if a control is pressed

case $msg = $YourButtonVariable ; If the control that is pressed is your button then.. note($YourButtonVariable is the variable you made your button in.. ex. $Button_1 = GUICtrlCreateButton())

ExecuteFunctionName() ;execute this function...

WEnd

Hope that helps

Link to comment
Share on other sites

  • Moderators

If it's your own GUI, you'll use the $ sign before the creation to create the variable.

$GUI = GUICreate('Title')
$CheckBox1 = GUICtrlCreateCheckBox('CkBox', 10, 10)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = - 3 Then Exit
    If $msg = $CheckBox1 And GUICtrlRead($CheckBox1) = 1 Then
        MsgBox(0, '', 'You Checked the check box')
    EndIf
    Sleep(10)
Wend

If it's another application, look up ControlCommand() in the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

#include <GUIConstants.au3>
GUICreate("My GUI radio"); will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
$btn = GUICtrlCreateButton( "Test", 100, 100, 100, 20)
GUISetState ()   ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $btn Then
        If BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then
            MsgBox(0,"test", " Radio 1 was checked   ")
        ElseIf BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then
            MsgBox(0,"test", " Radio 2 was checked   ")
        EndIf
    EndIf
        
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

8)

getting slower am i

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

@Chris

Your script has an error.

I thinks it's with the "case" part.

Something about a "select".

Get on him!!! :o

Tell him to use [ code] [/ code] tags too while your at it!!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Get on him!!! :o

Tell him to use [ code] [/ code] tags too while your at it!!

hahah... I did'nt even provide full code??????????

im confused....

what was the error message? i don't even have a case statement in their... lol

Edited by CHRIS95219
Link to comment
Share on other sites

Here is how to get wether a checkbox or radio button is checked....

$GUI_UNCHECKED Radio or Checkbox will be unchecked

$GUI_CHECKED Radio or Checkbox will be checked

for buttons

While 1 ;Starts an INFINITE LOOP

$msg = GUIGetMsg() ;Listens to see if a control is pressed

case $msg = $YourButtonVariable ; If the control that is pressed is your button then.. note($YourButtonVariable is the variable you made your button in.. ex. $Button_1 = GUICtrlCreateButton())

ExecuteFunctionName() ;execute this function...

WEnd

Hope that helps

hahah... I did'nt even provide full code??????????

im confused....

what was the error message? i don't even have a case statement in their... lol

This line sure looks like a case statement to me: case $msg = $YourButtonVariable

The rest of the guys posted code, so I'm not going to....

Link to comment
Share on other sites

oh, woops, i did'nt see that.. sorry people...

While 1;Starts an INFINITE LOOP
$msg = GUIGetMsg();Listens to see if a control is pressed
select
case $msg = $YourButtonVariable; If the control that is pressed is your button then.. note($YourButtonVariable is the variable you made your button in.. ex. $Button_1 = GUICtrlCreateButton())
ExecuteFunctionName();execute this function...
EndSelect
WEnd

urrr, today is not my day...

Edited by CHRIS95219
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...