AutoHotkey Community

It is currently May 26th, 2012, 6:15 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: February 10th, 2009, 9:58 pm 
Offline

Joined: September 16th, 2006, 7:47 pm
Posts: 66
OK, so ive made this script that uses screen coordinates for a game.
I got a new montior and wish to use another resolution before i used:
1024x768
now i use:
1280x1024

How do i convert screen coordinates to the new resolution?

Would be really nice with an example :)

This is a random part of my script:

z::
MouseMove, 677, 743
Click, left,
MouseMove, 19, 740
Click, left,
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2009, 11:17 pm 
u dont need to convert
just get those points again
(probably the same if u are using fullscreen mode in game)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2009, 11:22 pm 
Offline

Joined: September 16th, 2006, 7:47 pm
Posts: 66
its a ton of coordinates and would take me hours to replicate them all


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2009, 11:41 pm 
first of all, it shouldnt matter because ur game client size did not change
so all those clicks supposingly is the same spot (did u even try on the game yet?)
second, there is no such thing as converting coordinates
the best u can do is, x+100 or something

just in case no one comes out a converter that u want
here is a coordinate checker i often use to manually get points:
Code:
 
loop
{
MouseGetPos, xpos, ypos
tooltip, x%xpos% y%ypos%,1,1
sleep 200
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2009, 1:07 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
The monitor resolution won't matter if the size of the game screen is the same on both monitors. An 800 x 600 game screen is an 800 x 600 game screen. If the click are no longer going to the right place, that means the size of the game screen has adjusted to the new monitor and you'll have to know the size of the game screen on the old monitor in order to adjust the clicks. Here's an example of a function I wrote to work with different size windows for my poker tables, based on the default table size:

Code:
GamePlay(x, y){

  WinGetActiveStats, GameT, GameW, GameH, GameX, GameY ; used only for retrieving the width/height of the active window
  Vx := (x * GameW) / 808 ; 808 is default window width
  Vy := (y * GameH) / 634 ; 634 is default window height
  PlayX := Round(Vx) ; rounds to the nearest x coordinate
  PlayY := Round(Vy) ; rounds to the nearest y coordinate
  lParam := PlayX & 0xFFFF | (PlayY & 0xFFFF) << 16
  PostMessage, 0x201, , %lParam%, , ahk_id %GameID% ;WM_LBUTTONDOWN
  PostMessage, 0x202, , %lParam%, , ahk_id %GameID% ;WM_LBUTTONUP
 
}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2009, 6:04 am 
Offline

Joined: May 17th, 2008, 5:00 am
Posts: 39
Location: Dallas, TX
Not to harsh your mellow, but simple mathematical scaling of the coordinates is only 99% accurate. You can expect some glitches due to a) rounding inconsistencies and b) UI scaling tweaks in the game

If you store the coordinates in some sort of array (and FWIW associative "arrays" make for easily readable / tweakable code), you can then run the array(s) through a linear scaling, and then add if blocks to tweak any particular coordinates as needed.

Cheers,
Shawn


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2009, 6:45 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
greynite wrote:
Not to harsh your mellow, but simple mathematical scaling of the coordinates is only 99% accurate. You can expect some glitches due to a) rounding inconsistencies and b) UI scaling tweaks in the game


Ultimately for my purposes 99% is just fine as it's only when I get to the extremes of window size that I might see a difference. Nonetheless, I am a perfectionist so 99% is very annoying for a success rate.

greynite wrote:
If you store the coordinates in some sort of array (and FWIW associative "arrays" make for easily readable / tweakable code), you can then run the array(s) through a linear scaling, and then add if blocks to tweak any particular coordinates as needed.


I'm interested in this method but I'm not sure the examples of associative arrays/hashing I've found in the forums provide quite the relevance I'm looking for in this instance. Would you be willing to show me an example of how to do this with click coordinates?

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2009, 4:42 pm 
Offline

Joined: July 21st, 2008, 4:16 pm
Posts: 726
Location: Calgary, AB, Canada
Have you looked at the AHK built-in variables? %A_ScreenWidth% and %A_ScreenHeight%...

If you want it to be able to "Convert", you'll need to use variables. Something like
Code:
MouseMove, 677, 743
is useless to you. Something like
Code:
X := (A_ScreenWidth / 2) + 165 ; X = 677 (On  1024) or 805 (On 1280)
Y := A_ScreenHeight - 25 ; Y = 743 (On 768) or 999 (On 1024)
MouseMove, X, Y
is something you can work with. Though it would still take a bit of transition to "Convert" it, it can be done.

Also... For future reference, you can use the "MouseClick" or "Click" commands to move the mouse as well. That way you don't need to use the "MouseMove" command every second line.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: batto, hilalpro, Yahoo [Bot] and 63 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group