Page 1 of 1

Looking for a script that alters mouse input on a certain window only.

Posted: 29 May 2017, 02:31
by tobindax
I want a script that does two simple things.

1. When you click in that window instead of LClick and RClick it sends letters "A" and "B" respectively (examples).

2. When you actually move the mouse in that window each of the 4 directions of movements are sent as letters "C", "D" (-x/+x) and "E", "F" (-y/+y) (again, letters are examples).

I realize the latter might be more daunting.

Re: Looking for a script that alters mouse input on a certain window only.  Topic is solved

Posted: 29 May 2017, 10:11
by neomulemi6

Code: Select all

SetTitleMatchMode, 2
#IfWinActive, window title ; replace this with your window title
#Persistent

SetTimer, Timer1, 10

LButton::Send a
RButton::Send b

Timer1:
Padding = 25 ; number of pixels the mouse must be moved to activate the script.  
MouseGetPos, MouseX, MouseY
If (MouseX <> LastX && MouseY <> LastY)
{
	If (MouseX > LastX + Padding)
	{
		Send d
	}
	Else If (MouseX < LastX - Padding)
	{
		send c
	}
	If (MouseY > LastY + Padding)
	{
		Send f
	}
	Else If (MouseY < LastY - Padding)
	{
		send e
	}
	LastX := MouseX
	LastY := MouseY
}
Return

Re: Looking for a script that alters mouse input on a certain window only.

Posted: 30 May 2017, 01:36
by tobindax
I thank you. I wonder if the mouse part is simulating continuous pressing or multiple presses. The idea is to replace temporarily the direction keys of a game with a modifier, e.g. when pressing shift (or another modifier) to continually press A, S, D, or F depended on mouse motion.

I might test it/alter it anyway.

EDIT: Followup is answered here: https://autohotkey.com/boards/viewtopic.php?f=5&t=32462