Endless mouse

Share your favorite FastKeys commands
User avatar
Tom
Posts: 521
Joined: Nov 24th, ’15, 23:39

Post by Tom » Mar 12th, ’19, 20:36

You can use a A_ScreenWidth variable (width of primary monitor) instead of fixed numbers.
TokyoMike
Posts: 22
Joined: May 10th, ’18, 07:01

Post by TokyoMike » Mar 19th, ’19, 10:35

Tom wrote:
Mar 12th, ’19, 20:36
You can use a A_ScreenWidth variable (width of primary monitor) instead of fixed numbers.
Thank you. This worked on my giant monitor but when I switched back to my laptop it didn't The variable wouldn't correctly sense the right edge of the screen.

I put the numeric values in again for the small screen and things worked again. Is there any chance the A_ScreenWidth variable somehow "remembered" my large screen (like 3840) even after switching to the laptop screen? This is after reboots and several start/stops of Fastkeys. I am curious if something might be hard coded.
User avatar
Tom
Posts: 521
Joined: Nov 24th, ’15, 23:39

Post by Tom » Mar 21st, ’19, 20:35

Do you use multiple monitors? A_ScreenWidth is a system variable and it's value is always a width of your primary monitor.

What do you get if you put this line to the script?

Code: Select all

Msgbox % A_ScreenWidth
TokyoMike
Posts: 22
Joined: May 10th, ’18, 07:01

Post by TokyoMike » Mar 23rd, ’19, 02:23

Tom wrote:
Mar 21st, ’19, 20:35
Do you use multiple monitors? A_ScreenWidth is a system variable and it's value is always a width of your primary monitor.

What do you get if you put this line to the script?

Code: Select all

Msgbox % A_ScreenWidth
Ah - I see, maybe. At the office when I start my laptop I have the laptop open and it is connected to my monitor. At that moment there are 2 screens. Then I close the laptop lid and work from my monitor. So there is a change.

Now - that being said.

Today, from home (no external monitor) I added the message box as you suggested and it shows 1920. BUT - for some reason, the script is not working.

Am I doing the "math" wrong in the script?

Code: Select all

#Persistent
CoordMode, Mouse, Screen

SetTimer, ClosePopup, 500

Msgbox % A_ScreenWidth

ClosePopup:
MouseGetPos, xpos, ypos
IfGreater, xpos, %A_ScreenWidth%-2 ; my screen with is 1920 pixels
	MouseMove, -%A_ScreenWidth%-2, 0, 0, R
IfLess, xpos, 1
	MouseMove, %A_ScreenWidth%-2, 0, 0, R
;IfLess, ypos, 1
;	MouseMove, 0, 1078, 0, R
return
Thank you for your help.
User avatar
Tom
Posts: 521
Joined: Nov 24th, ’15, 23:39

Post by Tom » Mar 23rd, ’19, 21:49

This should work.

Code: Select all

CoordMode, Mouse, Screen
SetTimer, ClosePopup, 200

ClosePopup:
MouseGetPos, xpos, ypos
if (xpos > A_ScreenWidth-2)
	MouseMove, -A_ScreenWidth-2, 0, 0, R
if (xpos < 1)
	MouseMove, A_ScreenWidth-2, 0, 0, R
return
TokyoMike
Posts: 22
Joined: May 10th, ’18, 07:01

Post by TokyoMike » Mar 24th, ’19, 01:04

Tom wrote:
Mar 23rd, ’19, 21:49
This should work.

Code: Select all

CoordMode, Mouse, Screen
SetTimer, ClosePopup, 200

ClosePopup:
MouseGetPos, xpos, ypos
if (xpos > A_ScreenWidth-2)
	MouseMove, -A_ScreenWidth-2, 0, 0, R
if (xpos < 1)
	MouseMove, A_ScreenWidth-2, 0, 0, R
return
Thanks! This works great on my laptop - I will test with my giant monitor at the office on Monday.

Cheers!
TokyoMike
Posts: 22
Joined: May 10th, ’18, 07:01

Post by TokyoMike » Mar 25th, ’19, 08:30

TokyoMike wrote:
Mar 24th, ’19, 01:04
Thanks! This works great on my laptop - I will test with my giant monitor at the office on Monday.
Works great - the value adjusts properly. I suspect your logic is better than the original.

Thanks!
TokyoMike
Posts: 22
Joined: May 10th, ’18, 07:01

Post by TokyoMike » Apr 22nd, ’21, 04:47

Would it be possible to extend this to work with two monitors? The expectation would be to have the cursor wrap from the left of monitor to the right of the next monitor.

If (monitor1) and xpos = extreme left then movecursor to monitor2 and xpos extreme right and so on.
User avatar
Tom
Posts: 521
Joined: Nov 24th, ’15, 23:39

Post by Tom » Apr 23rd, ’21, 17:41

You could use the following code to get the far left and far right coordinates of all monitors.

Code: Select all

SysGet, monCount, 80
MonLeft:=MonRight:=0
Loop, % monCount 
{
    i := A_Index
    SysGet, mon%i%, Monitor, %i%
    MonLeft := (mon%i%Left<MonLeft) ? mon%i%Left : MonLeft
    MonRight := (mon%i%Right>MonRight) ? mon%i%Right : MonRight
}
Post Reply