Sign in to follow this  
Followers 0
crystalburner

get state

10 posts in this topic

$outlook = GUICtrlCreateRadio("Somebody works on this computer and it has Microsoft Outlook or Outlook Express e-Mail.", 5, 365)

$exchange = GUICtrlCreateRadio("This computer is an unattended Server and has Microsoft Exchange Installed.", 5, 383)

$nonms = GUICtrlCreateRadio("This computer is an unattended Server and has a non Microsoft e-Mail system installed.", 5, 401)

I have 3 radio buttons in my gui

and in the while 1 ... Wend loop i have

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

etc

Wend

Inside this While .. Wend loop I want to be able to see if radio button 3 has been selected but whatever code i try to put in the loop gets run forever and makes a mess.

If someone chooses radio button nonms i just want a message to pop up once but if i put

$test = GUICtrlRead ( $nonms )

returns 88 as the $test

so if i put

if $test = 88 msgbox "4,"","you chose nonms")

i get an infinate loop of message boxes :o

what am i doing wrong?

Share this post


Link to post
Share on other sites



You could try something like this (I actually don't know if this is correct, but it seemed to work)

#include <guiconstants.au3>

$m = GUICreate('test')
$nonms = GUICtrlCreateRadio('testradio', 10, 10)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = - 3 Then Exit
    If $msg = BitOR($nonms, $GUI_CHECKED) Then MsgBox(0, '', '')
WEnd


[center]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.[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$outlook = GUICtrlCreateRadio("Somebody works on this computer and it has Microsoft Outlook or Outlook Express e-Mail.", 5, 365)

$exchange = GUICtrlCreateRadio("This computer is an unattended Server and has Microsoft Exchange Installed.", 5, 383)

$nonms = GUICtrlCreateRadio("This computer is an unattended Server and has a non Microsoft e-Mail system installed.", 5, 401)

I have 3 radio buttons in my gui

and in the while 1 ... Wend loop i have

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

etc

Wend

Inside this While .. Wend loop I want to be able to see if radio button 3 has been selected but whatever code i try to put in the loop gets run forever and makes a mess.

If someone chooses radio button nonms i just want a message to pop up once but if i put

$test = GUICtrlRead ( $nonms )

returns 88 as the $test

so if i put

if $test = 88 msgbox "4,"","you chose nonms")

i get an infinate loop of message boxes :o

what am i doing wrong?

You could use $test as a flag to indicate you've already detected that button and not check it any more:

#include <GUI_Constants.au3>

$test = 0
While(1)
   If $test <> $GUI_CHECKED Then
      $test = GuiCtrlRead($nonms)
      ... etc. ...
   EndIf
Wend

Once you detect it is pushed (I may not have remembered the Macro correctly, but you get the idea), you won't test it again at all.

Problem with that is radio buttons tend to get changed a couple times before the operator settles on the button they really wanted. That may drive you to use a seperate flag variable to hold the state of your test for the button.

Hope that helped! :geek:

Edit: The swiss cheese brain with the write-only memory never works, I got to a machine where I could look it up, and the value for a selected radio button is $GUI_CHECKED, not @BS_Pushed, and you can't use that constant without the GUI_Constants.au3 include file.

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

Bah ! You did it again :o

I dont understand BITOR

thats my problem...

i'll read it.. but thanks really.

Share this post


Link to post
Share on other sites

You could try something like this (I actually don't know if this is correct, but it seemed to work)

#include <guiconstants.au3>

$m = GUICreate('test')
$nonms = GUICtrlCreateRadio('testradio', 10, 10)

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = - 3 Then Exit
    If $msg = BitOR($nonms, $GUI_CHECKED) Then MsgBox(0, '', '')
WEnd
Cool! I didn't realize the messages returned by controls included the state as bits in the message. Usefull info...

:o


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

#6 ·  Posted (edited)

#include <guiconstants.au3>

$m = GUICreate('test')
$nonms = GUICtrlCreateRadio('test radio', 10, 10, 120)
$nonms2 = GUICtrlCreateRadio('test radio 2', 10, 30, 120)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $nonms
         If BitAND(GUICtrlRead($nonms), $GUI_CHECKED) Then MsgBox(0, 'test', "radio")
      Case $msg = $nonms2
         If BitAND(GUICtrlRead($nonms2), $GUI_CHECKED) Then MsgBox(0, 'test', "radio 2")
   EndSelect
WEnd

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

#include <guiconstants.au3>

$m = GUICreate('test')
$nonms = GUICtrlCreateRadio('test radio', 10, 10, 120)
$nonms2 = GUICtrlCreateRadio('test radio 2', 10, 30, 120)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $nonms
         If BitAND(GUICtrlRead($nonms), $GUI_CHECKED) Then MsgBox(0, 'test', "radio")
      Case $msg = $nonms2
         If BitAND(GUICtrlRead($nonms2), $GUI_CHECKED) Then MsgBox(0, 'test', "radio 2")
   EndSelect
WEnd
Ahh, I realized last night that I forgot GUICtrlRead() with the BitOr() when I was out and about, and forgot to post that here... Thanks Gary! Although I think it was one of your post anyway that I remembered that from :o

[center]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.[/center]

Share this post


Link to post
Share on other sites

even better example of checking the state of the control

#include <guiconstants.au3>

$m = GUICreate('test')
$nonms = GUICtrlCreateCheckbox('test checkbox', 10, 10, 120)
$nonms2 = GUICtrlCreateCheckbox('test checkbox 2', 10, 30, 120)

GUISetState()

While 1
   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $nonms
         If BitAND(GUICtrlRead($nonms), $GUI_CHECKED) Then MsgBox(0, 'test', "checkbox")
      Case $msg = $nonms2
         If BitAND(GUICtrlRead($nonms2), $GUI_CHECKED) Then MsgBox(0, 'test', "checkbox 2")
   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

Ahh, I realized last night that I forgot GUICtrlRead() with the BitOr() when I was out and about, and forgot to post that here... Thanks Gary! Although I think it was one of your post anyway that I remembered that from :o

be careful which you use for this BitAnd/BitOr, notice which I used.


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

#10 ·  Posted (edited)

#include <GUIConstants.au3>
ConsoleWrite(BitAND(BitOR($GUI_CHECKED,$GUI_DISABLE), $GUI_CHECKED) & @LF)
ConsoleWrite(BitOR($GUI_DISABLE, $GUI_CHECKED) & @LF)
ConsoleWrite(BitAND($GUI_DISABLE, $GUI_CHECKED) & @LF)

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