Jump to content

Recommended Posts

Posted (edited)

MousePixelGetColor

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

HotKeySet("{ESC}", "_hkExit")
Opt("MustDeclareVars", 1)
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
Opt("TrayIconHide", 1)

Local $hWnd = GUICreate("MousePixelGetColor", 70, 55, -100, -100, _
BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_DLGFRAME,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS), _
BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
TraySetIcon("shell32.dll", 47)
Local $hGraphic = GUICtrlCreateGraphic(0, 0, 67, 37)
Local $hLabel = GUICtrlCreateLabel("", 8, 42, 60, 17)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
Local $exit = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"_trayExit")
TraySetState()
AdlibRegister("_timer")

Do
    If GUIGetMsg()=-3 Then ExitLoop
    _WinAPIEx_ShowWindow($hWnd, 5) ;GUISetState()
Until GUIGetMsg()=-3

Func _timer()
    Local $iX = _AU3_MouseGetPosX() ;_WinAPI_GetMousePosX()
    Local $iY = _AU3_MouseGetPosY() ;_WinAPI_GetMousePosY()
    Local $iC = _AU3_PixelGetColor($iX, $iY);PixelGetColor()
    GUICtrlSetBkColor($hGraphic, $iC[0])
    GUICtrlSetData($hLabel, '0x'&Hex($iC[0], 6))
    _WinAPIEx_MoveWindow($hWnd, $iX+10, $iY-40, 70, 55, True) ;WinMove()
EndFunc

Func _WinAPIEx_ShowWindow($hWnd, $iCmdShow = 5)
    Local $aResult = DllCall("user32.dll", "bool", "ShowWindow", "hwnd", $hWnd, "int", $iCmdShow)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
EndFunc

Func _AU3_PixelGetColor($iX, $iY)
    Local $RetC = DllCall("AutoItX3.dll", "int", "AU3_PixelGetColor", "long", $iX, "long", $iY)
    If @error <> 0 Then Return SetError(1, 0, 0)
    Return $RetC
EndFunc

Func _AU3_MouseGetPosX()
    Local $RetX = DllCall("AutoItX3.dll", "int", "AU3_MouseGetPosX")
    If @error <> 0 Then Return SetError(1, 0, 0)
    Return $RetX[0]
EndFunc

Func _AU3_MouseGetPosY()
    Local $RetY = DllCall("AutoItX3.dll", "int", "AU3_MouseGetPosY")
    If @error <> 0 Then Return SetError(1, 0, 0)
    Return $RetY[0]
EndFunc

Func _WinAPIEx_MoveWindow($hWnd, $iX, $iY, $iWidth, $iHeight, $fRepaint = True)
    Local $aResult = DllCall("user32.dll", _
                             "bool", "MoveWindow", _
                             "hwnd", $hWnd, _
                             "int", $iX, _
                             "int", $iY, _
                             "int", $iWidth, _
                             "int", $iHeight, _
                             "bool", $fRepaint)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
EndFunc

Func _trayExit()
    GUIDelete()
    Exit
EndFunc

Func _hkExit()
    GUIDelete()
    Exit
EndFunc ;==> MousePixelGetColor.
Edited by newsak2005
Posted

A description isn't the name of the program/function but what does it do? If I ran this what would I expect, because right now I have many ideas but not a definite answer.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
  • Recently Browsing   0 members

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