DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: IDEA: ignore too early clicks  (Read 5,407 times)

george_m6002

  • Participant
  • Joined in 2008
  • *
  • Posts: 1
IDEA: ignore too early clicks
« on: September 09, 2008, 11:22 AM »
I like having checked "Snap to" option for mouse (it avoids moving the mouse on the screen too much). But there is a bad point also: sometimes, a new dialog box can suddenly appear, the mouse automatically goes to default button (because of "snap to"), and you by mistake, wanting to click somewhere else, click on that button.

Is there a way to create a autohotkey script (or something else and would it be feasible) to ignore clicks that were made too early (=the difference between the moment the button appears on the screen and the moment the click was done is less than the time a human needs to make voluntarily this reaction)?

Thanks

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: IDEA: ignore too early clicks
« Reply #1 on: September 09, 2008, 09:36 PM »
I can understand what you mean. It must be very anoying.
Even though I can't present a solution for your problem, I suggest you check out my own DialogMove (discussed here). Instead of moving the mouse, it moves the dialog box that pops up.
If DialogMove fits you, I may add that delay to it (because with DialogMove, I control the window movement, thus I can disable the mouse button at just the right moment.)

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • Participated in NANY Challenge Twice
    • Coding Snacks
Re: IDEA: ignore too early clicks
« Reply #2 on: September 23, 2008, 07:44 AM »
:) Try WaitForIt!

It prevents accidental clicking on popup windows or when using "snap to" mouse settings.
To change the delay, just edit the delay= line in the code.

Skrommel

Code
;WaitForIt.ahk
; Prevent accidental clicking on popup windows or when using "snap to" mouse settings
;Skrommel @ 2008

delay=1000  ;Time to wait in milliseconds

#SingleInstance,Force
SetWinDelay,0
Gui,+LastFound +OwnDialogs 
hWnd:=WinExist() 
DllCall("RegisterShellHookWindow",UInt,hWnd) 
msgNum:=DllCall("RegisterWindowMessage", Str,"SHELLHOOK") 
OnMessage(msgNum,"ShellMessage") 
active:=WinActive("A") 
OnExit,EXIT
Return


LBUtton::
MouseGetPos,mx,my,mwin,mctrl
If (mwin=active)
{
  If (A_TickCount-activated>delay)
    MouseClick,L,,,1,0,D,
}
Else
  MouseClick,L,,,1,0,D,
Return


~LButton Up::
Return


ShellMessage(wParam,lParam)
{ 
  Global active,activated,mwin,delay

  If wParam=4  ;HSHELL_WINDOWACTIVATED=4 HSHELL_WINDOWCREATED=1
  IfWinExist,ahk_id %lParam%
  {
    active:=lParam 
    activated:=A_TickCount
  } 
  If (active=mwin)
    activated:=A_TickCount-delay
} 

EXIT: 
  DllCall( "DeregisterShellHookWindow", UInt,hWnd ) ; Redundant, I guess! 
ExitApp 

Original address: https://www.donationcoder.com/forum/index.php?topic=14824.0