Jump to content
Sign in to follow this  
RealisT

Phantom Mouse Events

Recommended Posts

RealisT

WINDOWS XP SP3

A test script in Message Mode polls for mouse click events and creates a new label at the coords of the click event.

Inexplicably, the code for the Mouse Click event fires constantly, painting the GUI with countless new labels.

Why is the mouse event firing without any mouse clicks?

- The mouse works fine. Ordinary use in everything else (including AutoIt scripts) confirms that. This is an issue specific to this script.

Here is the code. I see no reason why the code in the $GUI_EVENT_PRIMARYDOWN case should be executed without mouse clicks. What is this code missing? I don't want to switch to OnEvent mode.

#include <GUIConstants.au3>
AutoItSetOption("WinTitleMatchMode", 2)

$mainForm = GUICreate("DYNAMIC CONTROL ADD", @DesktopWidth, @DesktopHeight, 0, 0)

GUISetBkColor(0xCCAAAA)

$mainLabel = GUICtrlCreateLabel("Click Screen", @DesktopWidth/2 - 200, 0, 400, 70, $SS_CENTER)
GUICtrlSetFont($mainLabel, 36, 600, 0, "Impact")
GUICtrlSetColor($mainLabel, 0x339966)
GUICtrlSetBkColor($mainLabel, 0xaaccff)

GUISetState ()

While 1 
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_EVENT_PRIMARYDOWN
            $mouse = MouseGetPos()
            $newLabel = GUICtrlCreateLabel("", $mouse[0], $mouse[1], 72, 54)
            GUICtrlSetBkColor($newLabel, 0xFFFFFF)
            GUISetState ()
    EndSelect
Wend


Exit

Share this post


Link to post
Share on other sites
whim

try replacing ...

Case $GUI_EVENT_PRIMARYDOWN

by ...

Case $msg = $GUI_EVENT_PRIMARYDOWN

Share this post


Link to post
Share on other sites
RealisT

Doh!

Copy & Paste error on my part; pasted over the $msg = . My bad.

I look at the same code over & over again and I start to miss things like that.

Thank you humbly.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.