[Solve] monitor mouse movement

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

[Solve] monitor mouse movement

05 Jan 2014, 05:47

Is there any way to use OnMessage(0x200, "WM_MOUSEMOVE") for Non-ahk window?

I'm trying to write a mouse gestures script, which needs to track the mouse movement.
Currently I'm using a timer, is there better ways?
Last edited by arcticir on 31 Jan 2014, 06:33, edited 2 times in total.
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: monitor mouse movement

07 Jan 2014, 05:17

Thanks. I already knew, including strokeit and StrokesPlus, but they can not meet my requirements.
Zelio
Posts: 278
Joined: 30 Sep 2013, 00:45
Location: France

Re: monitor mouse movement

18 Jan 2014, 03:52

I really think that you have to use a low level thing as "SetWindowsHookEx" with "WH_MOUSE_LL", with some search I guess some scripts are ready yet for autohotkey, it is a powerfull solution...
Also I guess it is possible but not elegant to have an elevated admin right script who attach each focused process to your current AHK script for to watch...
Good luck !

edit:

Code: Select all

#Persistent
#SingleInstance Force
SetBatchlines -1
OnExit, UnHook

; http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990.aspx , WH_MOUSE_LL

hHookMouse := DllCall("SetWindowsHookEx", "int", 14, "Uint", RegisterCallback("Mouse", "Fast"), "Uint", 0, "Uint", 0)
Return

UnHook:
DllCall("UnhookWindowsHookEx", "Uint", hHookMouse)
ExitApp

Mouse(nCode, wParam, lParam)
{
	Critical
	Tooltip, % (wParam = 0x201 ? "LBUTTONDOWN"
		: wParam = 0x202 ? "LBUTTONUP"
		: wParam = 0x200 ? "MOUSEMOVE"
		: wParam = 0x20A ? "MOUSEWHEEL"
		: wParam = 0x20E ? "MOUSEWHEEL"
		: wParam = 0x204 ? "RBUTTONDOWN"
		: wParam = 0x205 ? "RBUTTONUP"
		: "?")
	. " ptX: " . NumGet(lParam+0, 0, "int")
	. " ptY: " . NumGet(lParam+0, 4, "int")
	. "`nmouseData: " . NumGet(lParam+0, 10, "short")
	. " flags: " . NumGet(lParam+0, 12, "uint")
	. " time: " . NumGet(lParam+0, 16, "uint")
	Return DllCall("CallNextHookEx", "Uint", 0, "int", nCode, "Uint", wParam, "Uint", lParam)
}

Esc::
ExitApp
else search "subclassing" or "attachthread" or how use a global mouse hook inserted into every process... but using your mousegetpos with a timer solution is enough if well coded...
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: monitor mouse movement

31 Jan 2014, 06:26

Very grateful for your help.
Sorry I'm so late reply, it really helped me a lot!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: inseption86, jaka1, LuckyJoe, metallizer, Rohwedder and 334 guests