Jump to content

My Windows Info Mouse thing is off on the colors


Recommended Posts

So i am trying to make it when i press my hotkey it opens up my application it goes through the startup menu. But my coordinates are right but the color detection seems to be off when i hover my cursor above what should be 0x2E4E6E it comes up as the color way below it (0xFFFFFF) Any way to maybe re-center it or something?

Link to comment
Share on other sites

  • Moderators

Why would you not just set it up to launch the application's executable on your hotkey press? Why bother trying to mimic the mouseclick at all?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

Ok, so you're saying when the app launches there is a menu, your initial post made it sound like you wanted to click on the app from the system Start Menu.

Since you are already using the AutoIt Window Info Tool,  why are you going with the mouse clicks instead of using ControlClick or ControlSend on the element? Is it not returning info?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

On my laptop (OS:WIN_10 Running:(3.3.14.5)), under the system's 'Display Settings' (Right mouse click on desktop), the 'Scale and Layout' has the size as 125% (Recommended). And the 'Display Resolution' is 1920 x 1080 (Recommended). The actual desktop as returned from @DesktopWidth and @DesktopHeight is 1536 x 864 because of the 125% scale.

I have noticed that if the 'Scale and Layout' value is other than 100%, then the $iScale variable will need to be added to a script so that the screen coordinates and the pixel coordinates will match - as per following example.
 
What I wasn't aware of is that the Autoit AU3Info tool is also influenced by the 'Display Settings' > 'Scale and Layout' value being other than 100%.
By changing the 'Scale and Layout' value to 100%, the color in the Autoit AU3Info tool will work correctly.

#include <WinAPI.au3>
#include <WinAPIGdi.au3>
; https://www.autoitscript.com/forum/topic/114695-how-do-i-use-pixel-search/?do=findComment&comment=802164

Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client


Global $iScale = _WinAPI_EnumDisplaySettings('\\.\DISPLAY1', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth ; PhysicalScreenWidth / LogicalScreenWidth
HotKeySet("{ESC}", "Terminate")

Local $exit = 1

While $exit
    Sleep(10)
    TtColXY()
WEnd

; TtColXY() Tooltip shows colour, and cursor position relative to screen and window.
Func TtColXY()
    $aPos = MouseGetPos()
    Local $tPosS = _WinAPI_GetMousePos() ; similar to MouseGetPos() ;Screen mouse position
    $hHwnd = _WinAPI_WindowFromPoint($tPosS)
    Local $tPosC = _WinAPI_GetMousePos(True, $hHwnd)
    $sColor = "0x" & Hex(PixelGetColor(DllStructGetData($tPosS, "X") * $iScale, DllStructGetData($tPosS, "Y") * $iScale), 6)
    ConsoleWrite(StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\2") & @LF)
    ConsoleWrite(Dec(StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\2")) & @LF)
    $iPosX = ($aPos[0] - 130) * ($aPos[0] > @DesktopWidth * 0.90) + ($aPos[0] <= @DesktopWidth * 0.90) * ($aPos[0] + 3)
    $iPosY = ($aPos[1] - 70) * ($aPos[1] > @DesktopHeight * 0.96) + ($aPos[1] <= @DesktopHeight * 0.96) * ($aPos[1] + 3)
    ToolTip("Color is: " & $sColor & @CRLF & "R:" & Dec(StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\2")) & _
            " G:" & Dec(StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\3")) & _
            " B:" & Dec(StringRegExpReplace($sColor, "(..)(..)(..)(..)", "\4")) & @CRLF & _
            "Screen: X: " & DllStructGetData($tPosS, "X") & " Y: " & DllStructGetData($tPosS, "Y") & @CRLF _
             & "Client: X: " & DllStructGetData($tPosC, "X") & " Y: " & DllStructGetData($tPosC, "Y"), $iPosX, $iPosY)
    Return
EndFunc   ;==>TtColXY

Func Terminate()
    $exit = 0
EndFunc   ;==>Terminate

 

Edited by Malkey
'Display Settings' (Right mouse click on desktop) - NOT "Left mouse click"
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...