Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 19:16

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Translate Mouse coords into Window coords.

Discussion on Translate Mouse coords into Window coords. within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,323
Received Thanks: 928
Translate Mouse coords into Window coords.

I have a mouse hook that gives me raw location data based on the screen resolution.

If you run a game in windowed mode, the coordinates won't match. If you run a game in fullscreen but you have 2 or more monitors, they won't match either.

If the screens are different size(resolution) they wont match either.


How would I translate the location data into the (game)window's relative location?

Get the Left / Top properties of the window using p/invoke, getting the size of the window using p/invoke and calculating the real size based on the OS's theme and then do some sort of scaling?





or simply ask the user to move the mouse to the top left corner to get the 0,0 of the game? What about ego shooters where there is no mouse? You can basically spin around forever since there is no left edge just a upper one.
Xio. is offline  
Old 11/03/2015, 13:24   #2
 
UniveX''s Avatar
 
elite*gold: 75
Join Date: Mar 2009
Posts: 528
Received Thanks: 21
You could just get the window rectangle & then moving relative to window, that would be WindowRect.Left + X where X is the coord and for Y it would be WindowRect.Top + Y.

Simple pseudo:
Code:
static public void SetMouse(IntPtr hwnd, Point p)
        {
            RECT rectHandle = new RECT();
            GetWindowRect(hwnd, out rectHandle);
            Cursor.Position = new Point(p.X + rectHandle.Left, p.Y + rectHandle.Top);
        }
GetWindowRect is WinAPI, simply include that & you should be fine. You could also just use PostMessage to solve this. If you have some issue, feel free to hit me up.

Have a nice day,
UniveX
UniveX' is offline  
Thanks
1 User
Old 11/03/2015, 21:07   #3
 
elite*gold: 585
Join Date: Jul 2011
Posts: 268
Received Thanks: 104
Post How to get the real size and map to screen coordinates.

You can get the real size with the GetClientRect function.
With the ClientToScreen function you can do the mapping to screen coordinates.
0ptimist is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Screen Coords <--> Map Coords using autoit
04/21/2009 - CO2 Programming - 1 Replies
Someone might like this. I provide an example of how to convert screen coords into map coords and visa versa. So that if your using autoit or some other mouse clicking macro tool, then you can get it to accurately get the mouse coordinates to click to move to a map-coordinate location. This method works by using autoit to look at the current player coordinates (_MemoryRead()), and performing some clicks on the screen to take map coordinate samples for mouse clicks in different locations....
How to get the coords?
01/10/2007 - Conquer Online 2 - 9 Replies
Anyone already figured out how to get the coords like they are showed in the upperleft? the coord offset given here is not that much accurate if you use for example a skill it is going to 0,0 after logging in or using a portal it is 0,0 when doing a jump it is set instat to the target coords. i am looking for a way to get the real coords, not much luck till now.
BWH Erz Coords
10/30/2005 - World of Warcraft - 2 Replies
Hi Leute könntet ihr mir bitte en paar coord. von Erzen posten? Hmm am besten wäre Thorium... Aber ich nehm netürlich alles was ich bekomme... Schon mal Danke im Vorraus ;)
BWL/MC Coords
10/29/2005 - World of Warcraft - 2 Replies
Hat mal jemand andere mc/bwl coords als nur zu Gehennas und Lashlayer? Danke
MC coords
08/17/2005 - World of Warcraft - 2 Replies
hab eine frage/bitte :) suche hilfe für das kleine prequest für mc für das quest muss man ja durch das gesammte brd reisen bis zum eingang der raid instanz für MC in BRD und rein und ein kernfragment holen, hat jmd die coords vor dem raidportal in brd? wäre sehr hilfreich ^^



All times are GMT +1. The time now is 19:16.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.