Jump to content

Converting x,y Positions To Different Resolution


=sinister=
 Share

Recommended Posts

I made a function to convert x and y positions to different resolutions. My mom helped me with the equation :) so i don't know if it will work exactly. I keep getting decimals, so you might need to roud or take off the decimals along with the numbers. Tell me what ya think. It grabs the resolution of the current window and converts your x and y position. There were 2 different equations, so there are 2 different UDF's.

Func ConvertX($Number)
    $Resolution = WinGetClientSize("")
    $PosX = $Number * $Resolution[0]/800
    Return $PosX
EndFunc

Func ConvertY($Number)
    $Resolution = WinGetClientSize("")
    $PosY = $Number * $Resolution[1]/600
    Return $PosY
EndFunc

:P Hope ya like it.

--Edit--

Forgot to tell you the smallest Resolution it works with is 800x600!

Edited by =sinister=
Link to comment
Share on other sites

From this topic:

; converts coords (x,y) in (a,b ) screen resolution to (c,d) screen resolution
Func _ConvertCoords( $x, $y, $a, $b, $c = @DesktopWidth, $d = @DesktopHeight )
   Local $ret[2] = [( $c * $x ) / $a, ( $d * $y ) / $b]
   Return $ret
EndFunc

Hope it helps! :)

Edited by erifash
Link to comment
Share on other sites

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...