I was searching for mouse hovering and motion detection related commands and thought why not create a simple lib.
Here is [mouseMoved.ahk] containing functions to detect if the Mouse Cursor moved from it's initial position:
Code: Select all
[list=][/list]
; Functions to test and see if the mouse cursor moved from it's initial position.
;
mouseMoved_Initial() { ; ----------------------
global x1, y1
mouseGetPos, x1, y1
} ; -------------------------------/
mouseMoved() { ; ------------------------
global x1, y1
mouseGetPos, x2, y2
xmv := ( x1 != x2 ) ;x moved
ymv := ( y1 != y2 ) ;y moved
bool := ( xmv or ymv )
return bool
} ; -----------------------------/
- mouseMoved_Initial()
- mouseMoved()
mouseMoved_Initial() is basicaly just mouseGetPos, x1, y1.
The other one is mouseMoved() witch returns 1 if the mouse moved, or 0 the mouse cursor did not move.
Here's how to include example [include.ahk]:
Code: Select all
#include <mouseMoved> ; Testing the lib
loop ; main loop
{
mouseMoved_Initial()
sleep 1 ; Wait for mouse movement
moved := mouseMoved()
tooltip, %moved%, 200, 200 ; Display some rezult
}
esc::exitApp
I have also attached a *.7z file for this code. Please let me know if there are any mistakes or improvements to be made in this code so i could possibly fix it.
Thanks