Sign in to follow this  
Followers 0
pietrog

Pressing any key won't terminate script

3 posts in this topic

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

Share this post


Link to post
Share on other sites



How about trying to disable the state of the pic so no messages are received from it.

GuiCtrlSetState($pic, $GUI_DISABLE)

Done off top of my head so do check syntax. :)

Share this post


Link to post
Share on other sites

Thanks - that worked perfectly.

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