Modify

#536 closed Bug (Wont Fix)

ControlGetFocus() prevents double-clicks

Reported by: MarcoM Owned by:
Milestone: Component: AutoIt
Version: 3.2.12.0 Severity: None
Keywords: ControlGetFocus Cc:

Description (last modified by Jpm)

It seems that polling which control has the focus with ControlGetFocus() resets somehow the mouse click counter/timer...

Here is a code sample showing this:

While 1
$CurrentWin = WinGetHandle("[Active]")
$CurrentControl = ControlGetFocus ($CurrentWin)
Sleep(50)
Wend

Double-clicks are not detected anymore when this code is running.

Attachments (0)

Change History (3)

comment:1 by Jpm, on Sep 4, 2008 at 6:50:34 AM

Description: modified (diff)

comment:2 by Valik, on Sep 4, 2008 at 5:43:28 PM

Resolution: Wont Fix
Status: newclosed

This can't be fixed. It's a quirk of windows that when getting focus the input state is reset (keyboard state, mouse state, et cetera). You can still double-click, you just now have to do it faster than the polling interval since it's going to reset the mouse input each time.

Closing as won't fix because while it is undesirable behavior it can't be fixed since it's a Windows design problem.

comment:3 by MarcoM, on Sep 6, 2008 at 11:02:55 PM

As a workaround, you can test for the left click and if it is pressed, wait a little longer than the double-click maximal interval before getting focus information. That will avoid resetting input events and still allow high frequency focus polling.

Here is an example of the workaround code:

#include <Misc.au3>
$DoubleClickPeriod = RegRead("HKCU\Control Panel\Mouse", "DoubleClickSpeed")
While 1
	$CurrentWin = WinGetHandle("[Active]")
	If _IsPressed("01", "user32.dll") Then
		Sleep($DoubleClickPeriod+50)
	Else
		$CurrentControl = ControlGetFocus ($CurrentWin)
		Sleep(10)
	EndIf
Wend

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.