Jump to content

GUI event problems


EnzoM
 Share

Recommended Posts

I've created a small GUI with 'yes' and 'no' buttons. I swear this was working, but it doesn't now. Can anyone see a problem with my code? I've tried it both using GUIOnEventMode and without. My 'yes' and 'no' events never fire. Appreciate any help/suggestions.

$GUI1_yesnoID = GUICreate($mName, 300, 100)
GUICtrlCreateLabel("Proceed?", 120, 10, 170, 65, $SS_LEFT)
$GUI1_yesButton = GUICtrlCreateButton("Yes", 130, 50, 50)
$GUI1_noButton = GUICtrlCreateButton("No", 210, 50, 50)
GUISetOnEvent($GUI_EVENT_CLOSE, "GUI1_closed")
GUICtrlSetOnEvent($GUI1_yesButton, "GUI1_yesButton")
GUICtrlSetOnEvent($GUI1_noButton, "GUI1_noButton")
GUICtrlCreatePic("recycle5.gif",3,0,110,97)
GUISetState(@SW_SHOW)
$GUI1_yes = False
$beginTimer = TimerInit()

While Not $GUI1_yes
    If TimerDiff($beginTimer) > $GUI1_Timeout * 1000 Then
        Exit
    EndIf
WEnd

; do the 'yes' stuff
Exit

Func GUI1_yesButton()
    $GUI1_yes = True
    MsgBox(0,"Test","Test",3)
EndFunc
Func GUI1_noButton()
    Exit
EndFunc
Func GUI1_closed()
    Exit
EndFunc
Link to comment
Share on other sites

  • Moderators

Opt("GUIOnEventMode", 1) ; At the top of your script.

You also have to disable the picture.

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

I have

Opt("GUIOnEventMode", 1)

at the top, and I added

$GUI1_picID = GUICtrlCreatePic("recycle5.gif",3,0,110,97)
GUICtrlSetState($GUI1_picID, $GUI_DISABLE)

per your suggestion: no change. Still doesn't fire either of the button events. The GUI1_closed event fires as expected. I must be missing something else?

Opt("GUIOnEventMode", 1) ; At the top of your script.

You also have to disable the picture.

Link to comment
Share on other sites

  • Moderators

Put this:

GUICtrlSetBkColor(-1, 0xFF0000)

After your Label creation, and you'll see the issue. (Just a hint, your label is too big).

Edit:

To fix it, do the same for the label as you did the pic, or resize the label to like 17 or something.

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

OMG that's so simple after I fought with it so long! Thanks heaps. Fixed!

Put this:

GUICtrlSetBkColor(-1, 0xFF0000)

After your Label creation, and you'll see the issue. (Just a hint, your label is too big).

Edit:

To fix it, do the same for the label as you did the pic, or resize the label to like 17 or something.

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