Jump to content

While loop hangs in GUI


JonBMN
 Share

Go to solution Solved by Jos,

Recommended Posts

Just trying to use a simple While loop to watch for input in a GUI window, but when I go to run it and then give the input. It seems to completely hang and I must at that point stop it manually and restart. I know I'm missing something (could be trivial), but a push would be greatly appreciated.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>

Local $F1Button, $F1Key

HotKeySet("{Esc}", "Quit")
$F1Key = HotKeySet("{F1}", "UnlockCar")

GUI()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_Event_Close
            Quit()
        Case $msg = $F1Button
            UnlockMe()
    EndSelect
WEnd

Func GUI()
    $DisclaimerHandle = GUICreate("Disclaimer", 525, 245, -1, -1, -1, $WS_EX_TOPMOST) ;Creates the GUI window
    GUICtrlCreateLabel("example", 7, 15)
    GUICtrlCreateLabel("", 7, 30)
    GUICtrlCreateLabel("example", 7, 45)
    GUICtrlCreateLabel(" example", 7, 60)
    GUICtrlCreateLabel("", 7, 75)
    GUICtrlCreateLabel("example", 7, 90)
    GUICtrlCreateLabel("example", 7, 105)
    GUICtrlCreateLabel("example", 7, 135)
    GUICtrlCreateLabel("example", 7, 165)
    GUICtrlCreateLabel("if using a touchscreen press the F1 button below.", 7, 180)
    $F1Button = GUICtrlCreateButton("F1", 217, 205, 50, 30)
    GUISetState(@SW_SHOW) ;Shows the GUI window
EndFunc   ;==>GUI

Func UnlockMe()
    MsgBox(0, "I work", "I work")
    Quit()
EndFunc   ;==>UnlockMe

Func Quit()
    GUIDelete()
    Exit
EndFunc   ;==>Quit
Link to comment
Share on other sites

  • Developers
  • Solution

After commenting the Hotkey since that points to an invalid name, the script works fine.

When clicking on the F1 button the Msgbox() is activated fine, only it is shown behind the Main window as that has the TopMost attribute.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

×
×
  • Create New...