Hello,
Rather than using a hotkey, is it possible to launch a script by moving then stopping the mouse?
Thanks
Trigger a script when the mouse stops moving
-
- Posts: 312
- Joined: 19 Nov 2013, 08:44
Trigger a script when the mouse stops moving
A ------------------------------ [A LOT OF SPACE] ------------------------------ LOT
"ALOT" is not a word. It never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
"ALOT" is not a word. It never has been a word and it never will be a word.
"A LOT" is 2 words. Remember it as though there's [A LOT OF SPACE] between them.
-
- Posts: 14
- Joined: 02 Sep 2014, 23:03
Re: Trigger a script when the mouse stops moving
Code: Select all
#NoEnv
Do_ToolTip:=1
mWait:=200
gosub Mouse_Check
return ; end auto execute
MOUSE_STOPPED:
;
; put your code here
;
return
!Esc:: ; Alt + Esc to quit
ExitApp
Mouse_Check:
mStill:=0
MouseGetPos, Ox, Oy
Sleep %mWait%
loop {
MouseGetPos, Mx, My
if( Mx = Ox && My = Oy ) {
mStill++
if( mStill >= 5 ) { ; 5 = 1000/mWait
mStill:=0
if( !IS_MSTOPPED && Do_ToolTip )
ToolTip, Mouse has stopped moving.
IS_MSTOPPED:=1
SetTimer, MOUSE_STOPPED, -1
}
} else {
IS_MSTOPPED:=0
ToolTip
}
Ox:=Mx, Oy:=My
Sleep %mWait%
}
return
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: Trigger a script when the mouse stops moving
You may also like Mouse Gestures.
Re: Trigger a script when the mouse stops moving
The technique posted by Garbidge_1 will not detect when the mouse stops moving, it will detect when the mouse cursor stops moving. You could be moving the mouse against the edge of the monitor, and the cursor would not move, but the mouse would still be moving.
Also, in many games, the windows cursor will not move when you move the mouse, so this code will not do anything.
Detecting when the mouse itself stops moving is non-trivial, because you simply stop getting mouse move messages when it stops moving, so you need to set a timer running after every move, and when the timer fires, you consider the mouse stopped.
If you want to detect the mouse stopping moving, see the sample script in my MouseDelta library - it shows how to do this with the RAWINPUT API. All the code you need is there.
Also, in many games, the windows cursor will not move when you move the mouse, so this code will not do anything.
Detecting when the mouse itself stops moving is non-trivial, because you simply stop getting mouse move messages when it stops moving, so you need to set a timer running after every move, and when the timer fires, you consider the mouse stopped.
If you want to detect the mouse stopping moving, see the sample script in my MouseDelta library - it shows how to do this with the RAWINPUT API. All the code you need is there.
Who is online
Users browsing this forum: alawsareps, Google [Bot], mebelantikjaya, mikeyww, RussF and 309 guests