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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jvkc
Posts: 2
Joined: 03 Feb 2015, 16:55

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

03 Feb 2015, 17:11

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
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

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

03 Feb 2015, 20:12

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.
Last edited by boiler on 03 Feb 2015, 21:36, edited 1 time in total.
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

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

03 Feb 2015, 20:17

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.
jvkc
Posts: 2
Joined: 03 Feb 2015, 16:55

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

03 Feb 2015, 21:04

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.
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

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

04 Feb 2015, 04:30

If I got two monitors, how can I put a text in the monitor1 and another different text in the monitor2?
Thanks in advance.
Everything is possible!
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

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

04 Feb 2015, 06:27

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
Last edited by boiler on 04 Feb 2015, 06:37, edited 3 times in total.
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

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

04 Feb 2015, 06:33

Thanks! It looks very easy...
I don't understand the values 2 - 100, 2 - 25 and 2 - 26. They mean?
Everything is possible!
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

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

04 Feb 2015, 06:34

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.
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

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

04 Feb 2015, 06:40

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.
User avatar
boiler
Posts: 17044
Joined: 21 Dec 2014, 02:44

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

09 Feb 2015, 16:32

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 352 guests