Elettrone Posted September 1, 2009 Share Posted September 1, 2009 HI, i'm trying to have certain zone of the screen controlled with the PixelSearch function, as the window doesn't have a fixed resolution I tought i could use X% and Y% percentage rather exact pixels so that the relative position never changes. I'm using 3 decimal numbers to have a good precision and while it works well for X axis it screws me up with Y axis. If i resize the window vertically my relative point will skew towards the top(depending on how much i squeeze the window) by about 5%-8%. This is driving me crazy because i don't understand the problem, any help would be super... this is my very simple code: expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <GUIConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}","terminate") HotKeySet("{RIGHT}","increase_x") HotKeySet("{LEFT}","decrease_x") HotKeySet("{DOWN}","increase_y") HotKeySet("{UP}","decrease_y") HotKeySet("!{RIGHT}","increase_x_by1") HotKeySet("!{LEFT}","decrease_x_by1") HotKeySet("!{DOWN}","increase_y_by1") HotKeySet("!{UP}","decrease_y_by1") WinActivate("Warcraft III") WinWait("Warcraft III") $WinPos = WinGetPos("mywindow") $Percent_X = 0.5 $Percent_Y = 0.5 $GUI = GUICreate("",150,150,$WinPos[0]-150,0,$WS_POPUP+$WS_BORDER,$WS_EX_TOPMOST) GUISetState(@SW_SHOW,$GUI) GUISetBkColor(0x000000,$GUI) While 1 $WinPos = WinGetPos("mywindow") $Point_X = $WinPos[0] + $WinPos[2]*$Percent_X $Point_Y = $WinPos[1] + $WinPos[3]*$Percent_Y MouseMove($Point_X,$Point_y) $Px_Color = PixelGetColor($Point_X,$Point_Y) ToolTip("Percent X: " & Round($Percent_X,3) & @CR & @CR & "Percent Y:" & Round($Percent_Y,3) & @CR & @CR & "Pixel Color:" & $Px_Color) GUISetBkColor($Px_Color,$GUI) WEnd Func increase_x() $Percent_X = $Percent_X + 0.001 EndFunc Func decrease_x() $Percent_X = $Percent_X - 0.001 EndFunc Func increase_y() $Percent_y = $Percent_y + 0.001 EndFunc Func decrease_y() $Percent_y = $Percent_y - 0.001 EndFunc Func increase_x_by1() $Percent_X = $Percent_X + 0.01 EndFunc Func decrease_x_by1() $Percent_X = $Percent_X - 0.01 EndFunc Func increase_y_by1() $Percent_y = $Percent_y + 0.01 EndFunc Func decrease_y_by1() $Percent_y = $Percent_y - 0.01 EndFunc Func terminate() exit(0) EndFunc Link to comment Share on other sites More sharing options...
WolfWorld Posted September 1, 2009 Share Posted September 1, 2009 This is kinda hard as Autoit does not have "hook"s. You can get the old size of the window - the new size of the window. Basic math. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
Elettrone Posted September 1, 2009 Author Share Posted September 1, 2009 This is kinda hard as Autoit does not have "hook"s.You can get the old size of the window - the new size of the window.Basic math.That's why i put WinGetPos() inside the loop, to update the win XY, still i get a skew unless i add a % modifier but then the skew is not regular, it looks like exponential from bottom going towards top so if i add this %modifier i get a rather imprecise value if the win doesn't have a high res... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now