DaHexor Posted February 11, 2011 Share Posted February 11, 2011 Hello All, I Tried searching for answer on forum without success so I figured I would post I'm sure this has been brought up alot. I Made a script that is using "PixelGetColor()" and "PixelSearch()" and "MouseClick()" and it's working 100% correct on Window Size: 1920x1080. Now when i tried it on my other computer Window Size: 1360x768 it Script didn't work at all cause coords would all be different. I was wondering is there some sorta Mathematical way to Change MouseCoords from the 1920x1080 to 1360x768 or even a different Window Size or whats my best option here to get it to work on multiple Window Size's other then Forcing a Window Size Change to a size i program it for. P.S. Thought i would just add this in while I'm at it is it possible to get it to "PixelGetColor()" and "PixelSearch()" and "MouseClick()" to work While Window is Minimized or in Foreground. Thanks, DaHexor Link to comment Share on other sites More sharing options...
Djordhan Posted February 11, 2011 Share Posted February 11, 2011 You could do something like this: Global $aOriginalRes[2] = [800,600] _CustomClick(453,208) ;Original code by Larry. ;Edited by BrettF Func _GetTotalScreenResolution() Local $aRet[2] Global Const $SM_VIRTUALWIDTH = 78 Global Const $SM_VIRTUALHEIGHT = 79 $VirtualDesktopWidth = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH) $aRet[0] = $VirtualDesktopWidth[0] $VirtualDesktopHeight = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT) $aRet[1] = $VirtualDesktopHeight[0] Return $aRet EndFunc Func _SetMouseCoord($x, $y) Local $aNewCoord[2], $aNewRes[2] $aNewRes = _GetTotalScreenResolution() $aNewCoord[0] = Round(($x / $aOriginalRes[0]) * $aNewRes[0],0) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aNewCoord = ' & $aNewCoord[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console $aNewCoord[1] = Round(($y / $aOriginalRes[1]) * $aNewRes[1],0) Return $aNewCoord EndFunc Func _CustomClick($x,$y) $pos = _SetMouseCoord($x,$y) MsgBox(0, "Mouse Coord Conversion", "Original MouseClick Coord: " & $x & "," & $y & @CRLF & "New MouseClick Coord: " & $pos[0] & "," & $pos[1]) ;MouseClick($pos[0],$pos[1]) EndFunc Link to comment Share on other sites More sharing options...
DaHexor Posted February 12, 2011 Author Share Posted February 12, 2011 Hello That seems to Kinda work although is there a way to get just the application window Resolution Not use it in Full Screen Mode Link to comment Share on other sites More sharing options...
Tvern Posted February 12, 2011 Share Posted February 12, 2011 You should be able to use WinGetClientSize so get the inner size of the window. (excluding the borders) For many windows ControlClick is allot nicer than using coordinates. If you use the au3info (Ctrl+F6 in scite if you have the full Scite package with autoit tools) tool to check the controls you interact with for their CLASSNN you can often send clicks directly to those controls, even when the window is inactive, or hidden. 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