Jump to content

Tight Loop Bug?


dcop
 Share

Recommended Posts

If I Dont hit the Button1 and get a function going within about 5 seconds it will run dov01() no matter whaich radio I have selected. If I hit select a radio and hit the button within a couple second of the GUI opening it works fine. TIA for any reasoning on this.

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Radio1 And $Button1
    dov01() 
    Case $msg = $Radio2 And $Button1 
    dov02() 
    Case $msg = $Radio3 And $Button1
    dov03()
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Link to comment
Share on other sites

  • Moderators

you have to guictrlread() the radios, to check if they are selected

Actually you need to
BitAnd(GUICtrlRead($Radio), $GUI_CHECKED) = $GUI_CHECKED
And when using things such as "Or" or "And", you need to restate what your wanting to check it against:
If $msg = $Radio And $msg = $Button
(Kind of hard to hit a radio a the same time as a button :) )

Might also think about downloading Beta if you haven't already, there's some more up to date examples on these types of things. http://www.autoitscript.com/forum/index.php?showtopic=19717

#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)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUICtrlSetState ($radio2, $GUI_CHECKED)

GUISetState ()  ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.')
        Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
            MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.')
    EndSelect
Wend

#include <GUIConstants.au3>

GUICreate("My GUI Button"); will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Run Notepad",  10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Button Test",  0, -1)

GUISetState ()  ; will display an  dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_1
            Run('Notepad.exe')  ; Will Run/Open Notepad
        Case $msg = $Button_2
            MsgBox(0, 'Testing', 'Button 2 was pressed')  ; Will demonstrate Button 2 being pressed
    EndSelect
Wend

Hope that helps you understand a bit better :(

Edited by SmOke_N

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

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...