chancity Posted July 6, 2012 Posted July 6, 2012 Hi, I'm currently developing a program that uses a 16:9 aspect ratio and I'm wondering there is an easier way than hand jamming new coordinates for 4:3 aspect ratio. I've been searching the forums and googling all over and can't seem to find a good solution. I found this example below but its not working as intended. Thanks in advance... expandcollapse popupFunc CoordSwitch($coordx0, $coordy0) ;16:9 Call("DesktopResolution") If $Resolution = "1920x1080" Or $Resolution = "1600x900" Or $Resolution = "1366x768" Or $Resolution = "1360x768" Or $Resolution = "1280x720" Then $OriginalXCoord = $coordx0 $OriginalYCoord = $coordy0 $ResolutionXorY = StringSplit($Resolution, "x") $AdjustedXCoord = ($ResolutionXorY[1] / 1920) * $OriginalXCoord $AdjustedYCoord = ($ResolutionXorY[2] / 1080) * $OriginalYCoord MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1) EndIf ; 16:10 If $Resolution = "1680x1050" Or $Resolution = "1440x900" Or $Resolution = "1280x800" Then $OriginalXCoord = $coordx0 $OriginalYCoord = $coordy0 $ResolutionXorY = StringSplit($Resolution, "x") $AdjustedXCoord = ($ResolutionXorY[1] / 1680) * $OriginalXCoord $AdjustedYCoord = ($ResolutionXorY[2] / 1050) * $OriginalYCoord MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1) EndIf ; 4:3 Resoltions If $Resolution = "1400x1050" Or $Resolution = "1360x1024" Or $Resolution = "1280x960" Or $Resolution = "1152x864" Or $Resolution = "1024x768" Or $Resolution = "800x600" Then $OriginalXCoord = $coordx0 $OriginalYCoord = $coordy0 $ResolutionXorY = StringSplit($Resolution, "x") $AdjustedXCoord = ($ResolutionXorY[1] / 1400) * $OriginalXCoord $AdjustedYCoord = ($ResolutionXorY[2] / 1050) * $OriginalYCoord MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1) EndIf EndFunc Func DesktopResolution() Switch $resolution = "" Case @DesktopWidth = 800 And @DesktopHeight = 600 $resolution = "800x600" Case @DesktopWidth = 1024 And @DesktopHeight = 768 $resolution = "1024x768" Case @DesktopWidth = 1152 And @DesktopHeight = 864 $resolution = "1152x864" Case @DesktopWidth = 1280 And @DesktopHeight = 720 $resolution = "1280x720" Case @DesktopWidth = 1280 And @DesktopHeight = 800 $resolution = "1280x800" Case @DesktopWidth = 1280 And @DesktopHeight = 960 $resolution = "1280x960" Case @DesktopWidth = 1360 And @DesktopHeight = 768 $resolution = "1360x768" Case @DesktopWidth = 1366 And @DesktopHeight = 768 $resolution = "1366x768" Case @DesktopWidth = 1440 And @DesktopHeight = 900 $resolution = "1440x900" Case @DesktopWidth = 1400 And @DesktopHeight = 1050 $resolution = "1440x900" Case @DesktopWidth = 1600 And @DesktopHeight = 900 $resolution = "1600x900" Case @DesktopWidth = 1920 And @DesktopHeight = 1080 $resolution = "1920x1080" Case Else Return SetError(1, 0, $resolution) EndSwitch Return $resolution EndFunc
AZJIO Posted July 6, 2012 Posted July 6, 2012 Reduced your functionCoordSwitch($coordx0, $coordy0) Func CoordSwitch($OriginalXCoord, $OriginalYCoord) Local $AdjustedXCoord, $AdjustedYCoord, $DH, $DW $DW = @DesktopWidth $DH = @DesktopHeight Switch $DW & 'x' & $DH Case "1920x1080", "1600x900", "1366x768", "1360x768", "1280x720" ;16:9 $AdjustedXCoord = ($DW / 1920) * $OriginalXCoord $AdjustedYCoord = ($DH / 1080) * $OriginalYCoord MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1) Case "1680x1050", "1440x900", "1280x800" ; 16:10 $AdjustedXCoord = ($DW / 1680) * $OriginalXCoord $AdjustedYCoord = ($DH / 1050) * $OriginalYCoord MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1) Case "1400x1050", "1360x1024", "1280x960", "1152x864", "1024x768", "800x600" ; 4:3 $AdjustedXCoord = ($DW / 1400) * $OriginalXCoord $AdjustedYCoord = ($DH / 1050) * $OriginalYCoord MouseClick("Left", $AdjustedXCoord, $AdjustedYCoord, 1) Case Else MsgBox(0, '???', $DW & 'x' & $DH) EndSwitch EndFunc My other projects or all
chancity Posted July 6, 2012 Author Posted July 6, 2012 I tried editing my post to take that other function out, didn't realize it was in there when I posted. Other than that this will operate the exact same way as the one I posted..Thanks for the cleanup though.
AZJIO Posted July 6, 2012 Posted July 6, 2012 CoordSwitch(100, 100, 1280, 800) Func CoordSwitch($X, $Y, $W, $H) ; $W, $H - Original ; MouseClick("Left", @DesktopWidth / $W * $X, @DesktopHeight / $H * $Y, 1) MsgBox(0, 'Coord', 'x = '&@DesktopWidth / $W * $X &@CRLF& 'y = '&@DesktopHeight / $H * $Y) EndFunc My other projects or all
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