Jump to content

Optimizing coordinates based on desktop resolution


Recommended Posts

Pretty much what the title says. I'm not looking to change a desktop resolution, but simply coming up with a single coordinate that would work for every desktop resolution.

An example would be that I'm looking to opening a file on a 1024x768 resolution. I know I could simple record a coordinate for that file, but then that same coordinate wouldn't work for another resolution such as 1440x900.

Some solutions I found was to use @DesktopHeight/Width and divide it by some number. I would do this, but I'm not sure what the number would be. Is there any other methods I could use?

Thanks for any help! :]

Link to comment
Share on other sites

Hi,

Please provide some more information about how you are going to use this....

Is it to center a GUI for example?

Local $hGUI = GUICreate('', 400, 300, -1, -1) ; centered GUI of 400x300
GUISetState()

WinMove($hGUI, "", 10, 10) ; move window off center...
Sleep(1000)

; center window again, size of window and screen does not matter
Local $aPos = WinGetPos($hGUI)
WinMove($hGUI, "", (@DesktopWidth / 2) - ($aPos[2] / 2), (@DesktopHeight / 2) - ($aPos[3] / 2))
Sleep(1000)

Edited by Robjong
Link to comment
Share on other sites

iRAWRRichard,

If your just trying to center the app then just divide desktop widths and heights by 2 like JS said. If your going for a different location, I treat the cordinates as a percentage ratio. For example if the GUI sits at 100,100 on a 1024x768 resolution, a similar location on 1440x900 would be

(100/1024) * 1440 -> 140.625

(100/768) * 900 -> 117.1875

So you end up with 141, 117

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...