Jump to content
Sign in to follow this  
power1power1

Mouse coordinates

Recommended Posts

power1power1

Hello, The simple script ('?do=embed' frameborder='0' data-embedContent>>) works fine. I have Windows 8.1 with screen resolution of 1920x1080 and scaling level set at 132%. The reported coordinates at the bottom right corner is 1440x810. I think Firefox also reports that as the screen resolution. Any comments? Thanks!

Share this post


Link to post
Share on other sites
water

What should your script return? The screen resolution (1920x1080) or the position of the mouse independant of the scaling level?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
power1power1

Well, when the mouse pointer is at the bottom right corner, I was expecting to get 1920x1080 rather than 1440x810 as the screen resolution is 1920x1080 ... I guess this is the new Windows 8.1 scaling effect, I didn't have this issue with Windows 8.

Share this post


Link to post
Share on other sites
water

You could play with AutoItSetOption "MouseCoordMode" and / or "PixelCoordMode".


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
BrewManNH

Your scaling level is affecting the coordinates, and you may be getting the coordinate above where the taskbar is on the screen instead of the screen resolution.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
power1power1

Thanks. Question: How do I get the screen scaling setting?

Edited by power1power1

Share this post


Link to post
Share on other sites
BrewManNH

Why do you need the screen scaling settings? If the coordinates returned work, and I assume you tried using them, then there's no need to look for the setting.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
power1power1

For example, try this and you get a wrong pixel color. You would need to apply the screen scaling factor to $aPos.

While 1
   $aPos = MouseGetPos()
   $iColor = PixelGetColor($aPos[0], $aPos[1])
   Tooltip($aPos[0] & ", " & $aPos[1] & ", " &  Hex($iColor, 6))
   Sleep (100)
WEnd
 

Edited by power1power1

Share this post


Link to post
Share on other sites
JLogan3o13

Can you explain exactly what you're trying to accomplish, and what application or window you're trying to manipulate? You're seeing how volatile using mouse coords can be; often there is a much easier way to do what you're trying to do.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
BrewManNH

If MousePos is giving you that coordinate, how do you know that the PixelGetColor is returning the color from the wrong position?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
power1power1

Trying the script, man!

Edited by power1power1

Share this post


Link to post
Share on other sites
Melba23

power1power1,

Please keep calm. People are trying to help you and getting ratty with them will not get you very far. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
water

And changing a post after you got warned doesn't help either :naughty:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
power1power1

water, I am not sure what you are talking about: At the moment, it shows my post was edited at 5 minutes ago and Melba 23 was posted at 4 minutes ago

Share this post


Link to post
Share on other sites
power1power1

Melba23, I am not sure what you are talking about either: The script is there to try. If anybody has any technical/professional comments regarding the subject, please do.

Share this post


Link to post
Share on other sites
Melba23

power1power1,

 

Melba23, I am not sure what you are talking about

A collection of hand-sized spherical objects! You know how that post read before you edited it. ;)

Now please get the thread back on track as I have enough to do elsewhere..... :whistle:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
power1power1

For the benefit of everybody, here it is:

Post # 11 before:

Try the script, man!

Post # 11 after:

Trying the script, man!

Share this post


Link to post
Share on other sites
power1power1

Using part of Yashied's script here: ('?do=embed' frameborder='0' data-embedContent>>), screen scaling factor can be calculated and the script in post #8 would show the correct color information:
 

$scale = 0
_GetScale()

While 1
   $position = MouseGetPos()
   $color = PixelGetColor($position[0] * $scale, $position[1] * $scale)
   Tooltip("X=" & $position[0] & ", Y=" & $position[1] & ", RGB=0x" &  Hex($color, 6), default, default, "Scaled Pixel Position and Hex Color:", 0, 4)
   Sleep (100)
WEnd
Exit

Func _GetScale()
   $tDEVMODE = DllStructCreate('byte[32];dword[10];byte[32];dword[6]')
   $pDEVMODE = DllStructGetPtr($tDEVMODE)
   $i = 0

   while 1
      $ret = DllCall('user32.dll', 'int', 'EnumDisplaySettings', 'ptr', 0, 'dword', $i, 'ptr', $pDEVMODE)
      if ($ret[0] = 0) then exitloop
      $width = DllStructGetData($tDEVMODE, 4, 2) ; native width
      $i += 1
   wend

   $scale = $width / @DesktopWidth
EndFunc

 

Edited by power1power1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×