Jump to content

Pressing any key won't terminate script


pietrog
 Share

Recommended Posts

Looking to have the script quit when either the mouse is moved or any key is pressed. The keypress doesn't seem to trigger when I create the picture control. If I comment out the GUICtrlCreatePic line, it works. If I leave it in, only the mouse move will terminate the script. I'd appreciate any insight. Thanks

#include <GUIConstants.au3>
Global Const $WM_KEYDOWN = 0x0100
Opt("RunErrorsFatal", 0)
Opt("GUIOnEventMode", 1)

$hGUI = GUICreate('test',300,200, 0, 0)
GUIRegisterMsg($WM_KEYDOWN, 'Terminate')
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, 'TermEvent')
$pic = GUICtrlCreatePic(@WindowsDir & '\lanma256.bmp', 10, 10, 0, 0)
GUISetState()

While 1
WEnd

Func Terminate($hWnd, $msg, $wParam, $lParam)
    Exit
EndFunc  ;==>Terminate

Func TermEvent()
    Exit
EndFunc  ;==>TermEvent
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...