Page 1 of 1

$40 bounty Need script to stop mouse cursor moving on touch

Posted: 03 Feb 2015, 17:11
by jvkc
I'm willing to pay $40 U.S. by paypal to someone who can write a script for me. I can't justify spending dozens of hours figuring out how to solve my problem:

I have a multi-monitor system with one device having a touch-screen input. Windows moves the mouse cursor whenever you touch the screen. If you are using an application on the non-touch monitor, this is an unwanted behavior. I can't figure out any way to natively prevent windows from moving the mouse on a touch event (bounty available for a native solution as well, btw). I need to retain full touch functionality on the touch device while preventing the mouse cursor from moving when I use the device.

The ideal solution would prevent the behavior altogether. Alternatively, AHK could be used to check the mouse position on a touch event and return it to the previous spot after Windows moves it. This website may be relevant to detecting touch events (superuser.com/questions/565025/stopping-the-mouse-cursor-from-moving-when-using-a-touchscreen-and-multiple-moni).

I will pay one bounty based on my satisfaction of the following requirements:

[*]Prevents and/or repositions mouse cursor on touch event so that cursor remains at whatever monitor/position it was at when the touch event was detected
[*]Retains full native touchscreen functionality otherwise
[*]Reasonably efficient
[*]System: Microsoft Surface Pro 1 running Windows 8.1 64-bit
Thanks,
Justin

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 03 Feb 2015, 20:12
by boiler
How about this? Use control-Escape to exit, but that can be omitted or changed.

Code: Select all

#SingleInstance, Force
CoordMode, Mouse, Screen
SysGet, MonCount, MonitorCount
Loop, %MonCount%
{
	SysGet, Mon, Monitor, %A_Index%
	Width := MonRight - MonLeft
	Height := MonBottom - MonTop
	if (Width = 1920) && (Height = 1080)
		break
}
MouseGetPos, LX, LY
Loop
{
	MouseGetPos, MX, MY
	if ((MX >= MonLeft) && (MX <= MonRight) && (MY >= MonTop) && (MY <= MonBottom))
	&& not ((LX >= MonLeft) && (LX <= MonRight) && (LY >= MonTop) && (LY <= MonBottom))
		MouseMove, LX, LY, 0
	else
	{
		LX := MX
		LY := MY
	}
	Sleep, 50
}

^Esc::ExitApp
Edit: Made a change to account for the possibility that the mouse is already in the touch monitor's area so it doesn't get stuck in there to start.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 03 Feb 2015, 20:17
by boiler
This assumes that your Surface Pro 1 is running at the native resolution (don't know if it can even be changed anyway) and it's the only monitor on your system running at that exact resolution (1920 x 1080). If not, let me know, and we can work around that.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 03 Feb 2015, 21:04
by jvkc
boiler wrote:This assumes that your Surface Pro 1 is running at the native resolution (don't know if it can even be changed anyway) and it's the only monitor on your system running at that exact resolution (1920 x 1080). If not, let me know, and we can work around that.
Wow a faster response than expected. I will test by this weekend and get back to you.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 03 Feb 2015, 21:10
by boiler
OK. Thanks.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 04 Feb 2015, 04:30
by empardopo
If I got two monitors, how can I put a text in the monitor1 and another different text in the monitor2?
Thanks in advance.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 04 Feb 2015, 06:27
by boiler
empardopo wrote:If I got two monitors, how can I put a text in the monitor1 and another different text in the monitor2?

Code: Select all

SysGet, Mon1, Monitor, 1
SysGet, Mon2, Monitor, 2
Gui1X := Mon1Left + (Mon1Right - Mon1Left) / 2 - 100
Gui1Y := (Mon1Bottom - Mon1Top) / 2 - 25
Gui2X := Mon2Left + (Mon2Right - Mon2Left) / 2 - 100
Gui2Y := (Mon2Bottom - Mon2Top) / 2 - 25
Gui, 1:New
Gui, 1:Add, Text,,Here's some text on monitor 1.
Gui, 1:Show, w200 h50 x%Gui1X% y%Gui1Y%
Gui, 2:New
Gui, 2:Add, Text,,Here's some different text on monitor 2.
Gui, 2:Show, w200 h50 x%Gui2X% y%Gui2Y%
return


GuiClose:
2GuiClose:
ExitApp

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 04 Feb 2015, 06:29
by evilC
Will eithermouse not do this?

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 04 Feb 2015, 06:33
by empardopo
Thanks! It looks very easy...
I don't understand the values 2 - 100, 2 - 25 and 2 - 26. They mean?

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 04 Feb 2015, 06:34
by evilC
If the existing attempts do not work, let me know, I think I could do this using low level windows hooks to stop the event from ever happening, but I won't bother if someone else has already collected the bounty.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 04 Feb 2015, 06:40
by boiler
empardopo wrote:Thanks! It looks very easy...
I don't understand the values 2 - 100, 2 - 25 and 2 - 26. They mean?
The 26 was a typo. I changed it to 25.

They are just doing math to find the middle of each screen in the x and y directions. Take half of the width and add it to the leftmost x coordinate for that window and subtract 100 (100 is half of the width of the GUI). Similar for the y direction.

Re: $40 bounty Need script to stop mouse cursor moving on to

Posted: 09 Feb 2015, 16:32
by boiler
evilC wrote:If the existing attempts do not work, let me know, I think I could do this using low level windows hooks to stop the event from ever happening, but I won't bother if someone else has already collected the bounty.
It looks like no one is collecting the bounty. :o

Re: $40 bounty Need script to stop mouse cursor moving on touch

Posted: 30 Dec 2019, 17:39
by Bauer55
you rock boiler!

Re: $40 bounty Need script to stop mouse cursor moving on touch

Posted: 30 Dec 2019, 18:42
by boiler
Thanks. :thumbup: