GetMousePos: Multiply and Round up? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Scr1pter
Posts: 1278
Joined: 06 Aug 2017, 08:21
Location: Germany

GetMousePos: Multiply and Round up?

14 Sep 2017, 10:03

Hello guys,

I start to use AHK's GetMousePos function, but not for a window but for the screen.
However, instead of working with pixels I would like to work with other values,
because The Logitech Gaming Software doesn't work with pixels.
It works with values from 0 to 65535 (both on X and Y axis.)
Since my monitor's resolution is 1920x1080, I multiply the X pixels with 34,15 and the Y pixels with 60,736 (haven't found out the value yet - 60,68 is wrong).

This is my first code, which looked ok on the first view, but it's not correct:

Code: Select all

^+F2::
CoordMode, Mouse, Screen
MouseGetPos, xx, yy
lx := (xx * 34,15)
ly := (yy * 60,736)
mx := Round(lx)
my := Round(ly)
send %mx%, %my%
return
I also tried using float, but whatever I try, I don't receive the correct values.
My aim is to receive natural values, which get round up if it's ,50.
Example:
102,45 = 102
136,60 = 137
170,75 = 171

X Pixel X Logitech value
0 0
1 34
2 68
3 102
4 137 - My result is 136, which is wrong

Thanks for any help!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
User avatar
Scr1pter
Posts: 1278
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: GetMousePos: Multiply and Round up?  Topic is solved

14 Sep 2017, 10:09

Oh, I think I've already found the mistake.
Since I'm German, I use comma instead of dot.
After changing

Code: Select all

lx := (xx * 34,15)
to

Code: Select all

lx := (xx * 34.15)
it works.

Sorry.
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: GetMousePos: Multiply and Round up?

14 Sep 2017, 10:20

Try this, it is probably not perfect.

Code: Select all

#Persistent

CoordMode, Mouse, Screen
tx := 65535 / A_ScreenWidth
ty := 65535 / A_ScreenHeight

SetTimer, label, 20

label:
	MouseGetPos, x, y
	ToolTip, % Round(x * tx) ", " Round(y * ty)
return
Please excuse my spelling I am dyslexic.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 365 guests