#include <AutoItConstants.au3>
#include <WinAPI.au3>
;~ #RequireAdmin ;when active mouse and kb input is blocked while dragging
FileInstall("SetDpi.exe", @TempDir & "\SetDpi.exe") ; optional SetDpi
HotKeySet("+!d", "Terminate") ; Shift-Alt-D
Local $qhd = ("2560")
Local $fhd = ("1920")
Local $hd = ("1280")
Global $scale = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth
;ConsoleWrite("Scale = " & _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] & " / " & @DesktopWidth & " = " & $scale & @CRLF)
If $scale > 1 Then ; optional SetDpi
run (@TempDir & "\SetDpi.exe 100") ; optional SetDpi
EndIf ; optional SetDpi
If not ProcessExists("Colonization.exe") Then
Run("Colonization.exe","")
sleep(30000)
EndIf
ProcessWait ("Colonization.exe")
While ProcessExists("Colonization.exe")
Sleep(50)
If WinActive("Colonization") Then
Local $sRes = WinGetPos ("[Active]")
;ConsoleWrite("Used Resolution: " & $sRes[2] & "x" & $sRes[3] & @LF)
;~ Local $cOLOR = PixelSearch ( 879, 77, 1232, 80, 9856307) ; debug block to find a color all resolutions share
;~ If Not @error Then
;~ ConsoleWrite("Found the color at: x:" & $Color[0] & " y:"& $Color[1] & @LF)
;~ Else
;~ ConsoleWrite("Could not found any gold" & @LF)
;~ EndIf
If $sRes[2] = $qhd then
Local $iColor = PixelGetColor(2204, 79, 0) ;1440p
;ConsoleWrite("The color is:" & $iColor & @LF)
If $iColor = ("9856307") Then ;the golden top border of the window
BlockInput($BI_DISABLE) ;only works with active "RequireAdmin", if not "RequireAdmin" it just does not block
_MouseDragFast2(2204, 79, 1180, 480)
MouseMove(1487,569,1)
BlockInput($BI_ENABLE)
EndIf
ElseIf $sRes[2] = $fhd then
Local $iColor = PixelGetColor(1874, 79, 0) ;1080p
If $iColor = ("9856307") Then
BlockInput($BI_DISABLE)
_MouseDragFast2(1874, 81, 1177, 281)
MouseMove(1178,363,1)
BlockInput($BI_ENABLE)
EndIf
ElseIf $sRes[2] = $hd then
Local $iColor = PixelGetColor(924, 79, 0) ;720p
If $iColor = ("9856307") Then
BlockInput($BI_DISABLE)
_MouseDragFast2(924, 79, 630, 140)
MouseMove(941,224,1)
BlockInput($BI_ENABLE)
EndIf
Else
ConsoleWrite("Unsupported Resolution" & @LF)
EndIf
EndIf
WEnd
Run (@TempDir & "\SetDpi.exe " & $scale*100); optional SetDpi
Func _MouseDragFast($x, $y,$x2,$y2)
$x = $x*65535/@DesktopWidth
$y = $y*65535/@DesktopHeight
$x2 = $x2*65535/@DesktopWidth
$y2 = $y2*65535/@DesktopHeight
_WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE), $x, $y)
_WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTDOWN), $x, $y)
_WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE), $x2, $y2)
_WinAPI_Mouse_Event(BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTUP), $x2, $y2)
EndFunc
Func _MouseDragFast2($x, $y, $x2, $y2, $User32 = "User32.dll")
$x_koef = 65535/@DesktopWidth
$y_koef = 65535/@DesktopHeight
$User32 = DllOpen("User32.dll")
$x *= $x_koef
$y *= $y_koef
$x2 *= $x_koef
$y2 *= $y_koef
DllCall($User32, "none", "mouse_event", "int", 32769, "int", $x, "int", $y, "int", 0, "int", 0) ; 32769 0x8001 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE)
DllCall($User32, "none", "mouse_event", "int", 32770, "int", $x, "int", $y, "int", 0, "int", 0) ; 32770 0x8002 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTDOWN)
DllCall($User32, "none", "mouse_event", "int", 32769, "int", $x2, "int", $y2, "int", 0, "int", 0) ; 32769 0x8001 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_MOVE)
DllCall($User32, "none", "mouse_event", "int", 32772, "int", $x2, "int", $y2, "int", 0, "int", 0) ; 32772 0x8004 BitOR($MOUSEEVENTF_ABSOLUTE, $MOUSEEVENTF_LEFTUP)
EndFunc
Func Terminate()
Run (@TempDir & "\SetDpi.exe " & $scale*100); optional SetDpi
Exit
EndFunc