 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
fenix
Joined: 16 Sep 2006 Posts: 66
|
Posted: Tue Feb 10, 2009 8:58 pm Post subject: Math question for script coordinates with diff resolutions |
|
|
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 |
|
| Back to top |
|
 |
evan Guest
|
Posted: Tue Feb 10, 2009 10:17 pm Post subject: |
|
|
u dont need to convert
just get those points again
(probably the same if u are using fullscreen mode in game) |
|
| Back to top |
|
 |
fenix
Joined: 16 Sep 2006 Posts: 66
|
Posted: Tue Feb 10, 2009 10:22 pm Post subject: |
|
|
| its a ton of coordinates and would take me hours to replicate them all |
|
| Back to top |
|
 |
evan Guest
|
Posted: Tue Feb 10, 2009 10:41 pm Post subject: |
|
|
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
} |
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Wed Feb 11, 2009 12:07 am Post subject: |
|
|
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
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
greynite
Joined: 17 May 2008 Posts: 39 Location: Dallas, TX
|
Posted: Wed Feb 11, 2009 5:04 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Wed Feb 11, 2009 5:45 am Post subject: |
|
|
| 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? _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Sivvy
Joined: 21 Jul 2008 Posts: 726 Location: Calgary, AB, Canada
|
Posted: Wed Feb 11, 2009 3:42 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|