Change left clicks to right clicks at screen border

Ask gaming related questions
popdeg
Posts: 4
Joined: 26 Apr 2024, 02:23

Change left clicks to right clicks at screen border

26 Apr 2024, 02:37

I want to make a simple program that just checks where my mouse cursor is on the screen when I click, and if it's in the 5 pixel border to the screen edge, left click events are replaced with right click events.

Code: Select all

CoordMode "Mouse", "Screen"

LButton::
{
MouseGetPos &posX, &posY
if (posX < 5 or posY < 5 or posX > 3835 or posY > 2155)
{Click "Right"

}
else
Click "left"
}
I gave it a shot myself and the code kind of works on the desktop, but not really. It takes the left click and sends a right click instead if I'm at the edge, but it breaks dragging. The code also didn't work at all in the game I tried, clicks didn't do anything at all 95% of the time, I don't know if there's another type of click I should be sending for it to get picked up properly.
Rohwedder
Posts: 7700
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Change left clicks to right clicks at screen border

26 Apr 2024, 10:31

Hallo,
try:

Code: Select all

#Requires AutoHotkey v2.0
SetTimer TEdge, 200
#HotIf Edge
LButton::RButton
#HotIf
TEdge() {
	Global Edge
	CoordMode("Mouse", "Screen"), MouseGetPos(&posX, &posY)
	Edge := posX < 5 or posY < 5 or posX > 3835 or posY > 2155
} 
popdeg
Posts: 4
Joined: 26 Apr 2024, 02:23

Re: Change left clicks to right clicks at screen border

27 Apr 2024, 05:23

Thanks, that code works far better than my poor attempt. There's one issue with it though, the edge case where I move the mouse to the border, click, and then move back on-screen before letting go of the mouse button can cause the click to bug out until I go back to the edge and click again.
Rohwedder
Posts: 7700
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Change left clicks to right clicks at screen border

27 Apr 2024, 09:02

Then perhaps?:

Code: Select all

#Requires AutoHotkey v2.0
SetTimer TEdge, 200
~*LButton Up::Click("Up Right")
#HotIf Edge
*LButton::Click("Down Right")
#HotIf
TEdge() {
	Global Edge
	CoordMode("Mouse", "Screen"), MouseGetPos(&posX, &posY)
	Edge := posX < 5 or posY < 5 or posX > 3835 or posY > 2155
}
popdeg
Posts: 4
Joined: 26 Apr 2024, 02:23

Re: Change left clicks to right clicks at screen border

27 Apr 2024, 13:06

This does solve the issue in games, but outside of them every left click now ends with a right click up which makes navigation a little annoying. I could just call the script on game launch and then kill it on exit though, so it'll work, thanks a lot for the help.
Rohwedder
Posts: 7700
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Change left clicks to right clicks at screen border

28 Apr 2024, 10:24

Perhaps?:

Code: Select all

#Requires AutoHotkey v2.0
SetTimer TEdge, 200
#HotIf Edge
LButton::RButton
#HotIf
TEdge() {
	Global Edge
	InstallMouseHook()
	CoordMode("Mouse", "Screen"), MouseGetPos(&posX, &posY)
	IF (!Edge := posX < 5 or posY < 5 or posX > 3835 or posY > 2155)
	And GetKeyState("RButton") And !GetKeyState("RButton", "P")
		Click("Up Right")
}
popdeg
Posts: 4
Joined: 26 Apr 2024, 02:23

Re: Change left clicks to right clicks at screen border

29 Apr 2024, 08:51

This looks like it works flawlessly. Thanks a lot.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests