Jump to content

Phantom Mouse Events


RealisT
 Share

Recommended Posts

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
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...