Jump to content

PixelGetColor return value is not correct when x,y reported by AU3Info - (Moved)


vip88
 Share

Recommended Posts

4 hours ago, vip88 said:

If (x,y) is given by AU3Info tool, PixelGetColor(x,y) return value is not correct.

I use https://www.autoitscript.com/forum/files/file/478-control-viewer-mod/
I can lock in CV the "Browse tool"/"Finder tool" by right and left click simultaneously. While locked in CV, I dragged the AU3Info's "Finder tool" to see if the values are not the same, but they are the same.

Look at the "Coord Mode" and make sure that is in the same mode as in the other color picker (Screen/Window/Client).

Edit: I've downloaded the program ( jcpicker ) and found no discrepancies.

 

Edited by argumentum
dig deeper

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • Moderators

vip88,

Very often these discrepancies are the result of having your display scaling set to something other than 100%, so I suggest you check your machine and see if that is the case.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

On 2/6/2021 at 7:22 AM, Melba23 said:

Very often these discrepancies are the result of having your display scaling set to something other than 100%

Yes. Here is code to save the day: 

;;; https://www.autoitscript.com/forum/topic/205086-get-screen-width-and-height-but-not-the-same-as-os-moved/?tab=comments#comment-1474562
;~      #include <WinAPISys.au3>
;~      ConsoleWrite(@DesktopWidth & "x" & @DesktopHeight & @CRLF) ; 2560x1080 ; 2048x864 @ 125%
;~      ConsoleWrite( _WinAPI_GetSystemMetrics(0) & "x" & _WinAPI_GetSystemMetrics(1) & @CRLF) ; 2560x1080 ; 2048x864 @ 125%
;~      ConsoleWrite( _WinAPI_GetSystemMetrics(78) & "x" & _WinAPI_GetSystemMetrics(79) & @CRLF) ; 3760x1920 ; 3760x1920 @ 125% on monitor 1

#include <WinAPIGdi.au3>

; enum _PROCESS_DPI_AWARENESS
Global Const $PROCESS_DPI_UNAWARE = 0
Global Const $PROCESS_SYSTEM_DPI_AWARE = 1
Global Const $PROCESS_PER_MONITOR_DPI_AWARE = 2

; enum _MONITOR_DPI_TYPE
Global Const $MDT_EFFECTIVE_DPI = 0
Global Const $MDT_ANGULAR_DPI = 1
Global Const $MDT_RAW_DPI = 2
Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI

Global $g_hGUI, $g_iLeft = -1, $g_iTop = -1, $g_iDpi = $PROCESS_PER_MONITOR_DPI_AWARE

ParseCmdLine()

_WinAPI_SetProcessDpiAwareness($g_iDpi)

_Example()
Func _Example() ; https://www.autoitscript.com/forum/topic/189341-get-per-monitor-dpi-scaling-factor/
    $g_hGUI = GUICreate(@ScriptName, 600, 400, $g_iLeft, $g_iTop)
    Local $idEdit = GUICtrlCreateEdit("", 0, 30, 600, 370)
    GUICtrlSetFont(-1, 10)
    Local $idBttn0 = GUICtrlCreateButton("Reload as DPI_UNAWARE", 5, 2, 195, 25)
    GUICtrlSetFont(-1, 10)
    Local $idBttn1 = GUICtrlCreateButton("Reload as SYSTEM_DPI_AWARE", 205, 2, 195, 25)
    Local $idBttn2 = GUICtrlCreateButton("Reload as PER_MONITOR_DPI", 405, 2, 195, 25)
    Local $aMonitors = _WinAPI_EnumDisplayMonitors()
    If Not IsArray($aMonitors) Then Exit MsgBox(0, "", "EnumDisplayMonitors error")

    Local $sDPIs, $aDPI
    For $i = 1 To $aMonitors[0][0]
        $aDPI = _WinAPI_GetDpiForMonitor($aMonitors[$i][0], $MDT_DEFAULT)
        $sDPIs &= "DpiForMonitor #" & $i & @TAB & (IsArray($aDPI) ?  $aDPI[0] & ":" & $aDPI[1] : " error" ) & @CRLF

    Next
    GUICtrlSetData($idEdit, $sDPIs & "==================================" & @CRLF, 1)
    GUICtrlSetData($idEdit, FileRead(@ScriptFullPath), 1)

    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case -3
                GUIDelete()
                Exit
            Case $idBttn0
                runAnew($PROCESS_DPI_UNAWARE)
            Case $idBttn1
                runAnew($PROCESS_SYSTEM_DPI_AWARE)
            Case $idBttn2
                runAnew($PROCESS_PER_MONITOR_DPI_AWARE)
        EndSwitch
    WEnd
EndFunc   ;==>_Example

Func runAnew($iDpi)
    Local $aArray = WinGetPos($g_hGUI)
    ShellExecute(@AutoItExe, '"' & @ScriptFullPath & '" ' & $aArray[0] & '/' & $aArray[1] & '/' & $iDpi)
    GUIDelete()
    Exit
EndFunc

Func ParseCmdLine()
    Local $a[4] = [3,-1,-1,0]
    For $n = 1 To $CmdLine[0]
        $a = StringSplit($CmdLine[$n], '/')
        If UBound($a) = 4 Then
            $g_iLeft = $a[1]
            $g_iTop = $a[2]
            $g_iDpi = Int($a[3])
            Return
        EndIf
    Next
EndFunc

Func _WinAPI_SetProcessDpiAwareness($DPIAware)
    DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware)
    If @error Then Return SetError(1, 0, 0)
EndFunc   ;==>_WinAPI_SetProcessDpiAwareness

Func _WinAPI_GetDpiForMonitor($hMonitor, $dpiType)
    Local $X, $Y
    Local $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMonitor, "int", $dpiType, "uint*", $X, "uint*", $Y)
    If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0)
    Local $aDPI[2] = [$aRet[3], $aRet[4]]
    Return $aDPI
EndFunc   ;==>_WinAPI_GetDpiForMonitor

Edit: ..I find this code a better exploration :) 

Edited by argumentum

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...