Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Activation on mouse move


  • Please log in to reply
6 replies to this topic
eskom
  • Members
  • 8 posts
  • Last active: Jan 26 2012 10:00 PM
  • Joined: 25 Oct 2011
Is there a way to activate a script when mouse moves like LButton:: does on left click? I guess I could do a permanent loop that checks if coordinates have changed but I was wondering about this and dont really know how to search for it.

G. Sperotto
  • Members
  • 539 posts
  • Last active: Jun 20 2015 04:54 PM
  • Joined: 12 Dec 2011
The OnMessage() function should do the job.


Heres a video tutorial about it. It even uses MouseMove as the example:

Part1:
<!-- m -->http://www.youtube.c... ... NtviHniOB4<!-- m -->

Part2:
<!-- m -->http://www.youtube.c... ... AjACikKLU4<!-- m -->

eskom
  • Members
  • 8 posts
  • Last active: Jan 26 2012 10:00 PM
  • Joined: 25 Oct 2011
I can't seem to work out how to get this on. Is there anything else i need on my Autohotkey.ahk?

Im trying to test with this code but nothing happens when i left click:

OnMessage(0x201, "Derp")
return

Derp(wParam, lParam, Msg) 
{
  Tooltip % "testing..."
}


Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011

Specifies a function to call automatically when the script receives the specified message.

try :
OnMessage(0x201, "Derp")

gui, show, w400 h200

return



Derp(wParam, lParam, Msg) 

{

  Tooltip % "testing..."

}


jethrow
  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009
Possibility:
CoordMode, Mouse, Screen
MouseGetPos, x1, y1
OnMessage(WM_MOUSEMOVE:=0x200, "MouseMove")
Gui, +ToolWindow
Gui, Show, x0 y0 w0 h0
Gui, +LastFoundExist
WinSet, Transparent, 1, % "ahk_id" WinExist()
Gui, Show, w%A_ScreenWidth% h%A_ScreenHeight%

MouseMove() {
	global
	MouseGetPos, x2, y2
	if (x1!=x2 and y1!=y2) {
		Gui, Destroy
		MsgBox, Moved Mouse
		ExitApp
	}
}

I think the permanent loop may be better though.

Rseding91
  • Members
  • 703 posts
  • Last active: Apr 02 2016 05:05 AM
  • Joined: 07 Jun 2010
A permanent loop is definitly better then a full screen GUI hidden in the backgroun :p

SetBatchLines,-1
#NoEnv
Coordmode,Mouse,Screen
MonitorMouseMovement := True
SetTimer,CheckMouseMovement,-1
Return

*~1::
	MonitorMouseMovement := True
	SetTimer,CheckMouseMovement,-1
Return

*~2::
	MonitorMouseMovement := False
	Sleep,-1
	ToolTip
Return

CheckMouseMovement()
{
	Global MonitorMouseMovement
	Static FirstRun = 1, OldX, OldY
	
	If (FirstRun){
		MouseGetPos,OldX,OldY
		FirstRun := False
		Return
	}
	
	If (!MonitorMouseMovement)
		Return 1
	
	MouseGetPos,CurrentX,CurrentY
	
	If (CurrentX != OldX Or CurrentY != OldY){
		ToolTip,Mouse Moved to: %CurrentX%`, %CurrentY%
		OldX := CurrentX, OldY := CurrentY
	} Else
		ToolTip
}

CheckMouseMovement:
	If (!CheckMouseMovement())
		SetTimer,CheckMouseMovement,-1
Return


Hedonist
  • Members
  • 41 posts
  • Last active: Sep 18 2014 01:15 PM
  • Joined: 24 Jan 2005

I like this solution, but how would I get the tooltip to disapear after 2 seconds then come back again if the mouse is moved again?