Jump to content
Sign in to follow this  
newsak2005

MousePixelGetColor

Recommended Posts

newsak2005

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

Share this post


Link to post
Share on other sites
newsak2005

๋JohnOne

Thanks for your advice.

Share this post


Link to post
Share on other sites
guinness

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:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
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
Sign in to follow this  

×