Search the Community
Showing results for tags 'Aspect ratio'.
-
H guys, I have a script that uses mouse clicks at different positions on the screen but I realised every UI changes depeding on aspect ratio. I have solved the problem of scaling to different resolutions by using percentages @desktopwidth @desktopheight so now the main issue is making one script that automatically detects aspect ratio like this: CoordSwitch($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 I have written 3 different scripts for each aspect ratio 4:3, 16:9 and 16:10 but I would like to include all the data in one script so it can automatically change probably based on IF statements. This is my code so far. (4:3 Aspect Ratio) The mouse clicks are the main data, I also have the coordinates for 16:9 and 16:10 so please ask if you need those also thanks! Global $sHeight = @DesktopHeight Global $sWidth = @DesktopWidth Global $UnPaused HotKeySet("+1","_TogglePause") ; Press Shift+1 to start script HotKeySet("+2", "_Terminate") ; Press Shift+2 to terminate script MsgBox(64, "Welcome!") While 1 ; Loop 1 Sleep(100) ; Waiting for function call. Pressing the Start hotkey ends this loop ToolTip('Paused. Press SHIFT+1 to resume/pause or SHIFT+2 to terminate.',0,0) WEnd Func _TogglePause() ToolTip('Started. Press SHIFT+1 to pause or SHIFT+2 to terminate.',0,0) $UnPaused = NOT $UnPaused While $UnPaused ; Loop 2 ToolTip("1") MouseClick("Left", @DesktopWidth *0.931, @DesktopHeight *0.846, 1, 10) ToolTip("2") MouseClick("Left", @DesktopWidth *0.0771, @DesktopHeight *0.723, 1, 20) ToolTip("3") MouseClick("Left", @DesktopWidth *0.622, @DesktopHeight *0.515, 2, 20) ToolTip("4") MouseClick("Left", @DesktopWidth *0.463, @DesktopHeight *0.606, 2, 20) ToolTip("5") MouseClick("Left", @DesktopWidth *0.273, @DesktopHeight *0.584, 1, 20) ToolTip("6") MouseClick("Left", @DesktopWidth *0.506, @DesktopHeight *0.608, 1, 20) WEnd EndFunc Func _Terminate() If MsgBox(4, 'Do you want to exit?', 'Click Yes to exit, or No to continue') = 6 Then Exit EndFunc ;==>_Pause