Jump to content
Sign in to follow this  

Phantom Mouse Events

Recommended Posts


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)


$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()
        Case $msg = $GUI_EVENT_CLOSE
            $mouse = MouseGetPos()
            $newLabel = GUICtrlCreateLabel("", $mouse[0], $mouse[1], 72, 54)
            GUICtrlSetBkColor($newLabel, 0xFFFFFF)
            GUISetState ()


Share this post

Link to post
Share on other sites


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...