Jump to content

Recommended Posts

Posted

Hi All,

I am writing a script to control the Reolink desktop client. My development machine is running Windows 10, while the target machine, our HTPC, is running Windows 11. I have just updated to the current release v3.3.18.0.

The script works wonderfully on my development machine, but failed right from the first try on the HTPC. I then realised the colors were slightly different, so got the correct color codes from Au3Info, but I am still failing.

[After writing a lengthy post, I realised there was 1 other difference between the 2 machines] 

I think I have found the problem. PixelGetColor uses different code than whatever Au3Info uses to get pixel color. PixelGetColor fails when running at a non-100% scaling.

The attached image is a screenshot of the issue. The code to make the mouse box is:

Func DoMouse()
    $mouse = MouseGetPos()
    $mgui = GUICreate("MouseTester", 200, 90, -1, 200, 0x80000000 + 0x00400000, 0x00000080 + 0x00000008)
    $MLoc = GUICtrlCreateLabel("Mouse Pos: x = " & $mouse[0] & ", y = " & $mouse[1], 10, 5, 180)
    $Pix = GUICtrlCreateLabel("Pixel Colour: " & Hex(PixelGetColor($mouse[0], $mouse[1])), 10, 25, 180)
    $WDim = GUICtrlCreateLabel("Window Size: " & $RLWinSize[2] & "x" & $RLWinSize[3], 10, 45, 180)
    GUICtrlCreateLabel("Numpad4 to exit", 10, 65, 180)
    GUISetState(@SW_SHOW)
    GUISetState(@SW_DISABLE)
    While 1
        $mouse = MouseGetPos()
        Sleep(100)
        Select
            Case _IsPressed("67") ; = "{numpad7}"
                ;MsgBox(0, "", $nmsg)
                MouseMove($mouse[0] - 1, $mouse[1])
            Case _IsPressed("69") ; = "{numpad9}"
                MouseMove($mouse[0] + 1, $mouse[1])
            Case _IsPressed("68") ; = "{numpad8}"
                MouseMove($mouse[0], $mouse[1] - 1)
            Case _IsPressed("65") ; = "{numpad5}"
                MouseMove($mouse[0], $mouse[1] + 1)
            Case _IsPressed("64") ; = numpad4
                ExitLoop
        EndSelect
        GUICtrlSetData($MLoc, "Mouse Pos: x = " & $mouse[0] & ", y = " & $mouse[1])
        GUICtrlSetData($Pix, "Pixel Colour: " & PixelGetColor($mouse[0], $mouse[1]))
    WEnd
    GUIDelete($mgui)
EndFunc   ;==>DoMouse

My perfectly running script on the development machine broke immediately when changing scale. AU3Info continued to return the correct colors.

What do I replace PixelGetColor with so my code returns the same value as Au3Info?

Screenshot 2025-11-29 144947.jpg

Posted

put at the top of your script
DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2)
and try
 :unsure:

I know that I know nothing

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...