Sign in to follow this  
Followers 0
gil900

I can not understand how to use the code...

10 posts in this topic

I found on Google Someone wrote a function similar to PixelGetColor But it also works on a minimized window ..

#include  <iostream>
#define _WIN32_WINNT 0x0501
#include 

#define PixelGetColor(x, y) PixelGet(mDC, x, y)
int CreateContext(char *window_name, HDC *hDC, HDC *mDC, HBITMAP *hBM) {
RECT win_stats;

HWND hwnd = FindWindow(NULL, window_name);

if(!GetClientRect(hwnd, &win_stats)) {
return 1;
}

*hDC = GetDC(hwnd);
*mDC = CreateCompatibleDC(*hDC);
*hBM = CreateCompatibleBitmap(*hDC, win_stats.right, win_stats.bottom);
SelectObject(*mDC, *hBM);
PrintWindow(hwnd, *mDC, 0);
return 0;
}

void DeleteContext(HDC *hDC, HDC *mDC, HBITMAP *hBM) {
ReleaseDC(NULL, *hDC);
DeleteDC(*mDC);
DeleteObject(*hBM);
}

COLORREF PixelGet(HDC mDC, int x, int y) {
return GetPixel(mDC, x, y);
}

I found it here:

http://www.codeproject.com/Questions/446577/Autoit-GetPixelColor-on-a-hidden-minimized-window

But I run the code I get an error ..

What should I do?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You need to read that post again because you missed a vital clue as to why this doesn't work.

Hint: It's C++ code.

Edit: I think it best you describe what you want to do and brush up on AutoIt by reading the help file.

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

I know.

But what steps i need to do to use it?

If you need that then you should ask on a C++ forum


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I know.

But what steps i need to do to use it?

From your post you said you executed the code, which suggests to me you thought this was AutoIt code.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

From your post you said you executed the code, which suggests to me you thought this was AutoIt code.

Oops I did not notice .. Wow I can not believe how language similar to C++

It's Almost the same thing

I have a question, if I want to start learning C++ so it should be relatively easy?

I've written a few small programs and Small algorithms(Up to 300 lines) in AutoIt3.

So I just want to know How difficult it would be for me to learn it. it is a good opportunity to ask.

Edited by gil900

Share this post


Link to post
Share on other sites

Oops I did not notice .. Wow I can not believe how language similar to C++

It's Almost the same thing

I have a question, if I want to start learning C++ so it should be relatively easy?

I've written a few small programs and Small algorithms(Up to 300 lines) in AutoIt3.

So I just want to know How difficult it would be for me to learn it. it is a good opportunity to ask.

Just Do It


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Try this:

;coded by UEZ 2012
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>

_GDIPlus_Startup()

Global $i, $iW = 150, $iH = 50, $x, $iy
Global $hGUI = GUICreate("Test", $iW, $iH)
GUISetBkColor(0, $hGUI)
GUICtrlCreateLabel(".", 1, 0)
GUICtrlSetColor(-1, 0x0000FF)
GUISetState()

$aPC = _PixelGetColors($hGUI, 0, 0, 8, 40)
_ArrayDisplay($aPC)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

_GDIPlus_Shutdown()
GUIDelete()
Exit

Func _PixelGetColors($hWnd, $iX, $iY, $iW, $iH) ;coded by UEZ 2012
    If Not IsHWnd($hWnd) Then Return SetError(1, 0, "")
    Local $aWinSize = WinGetClientSize($hWnd)
    Local $iW_hWnd = $aWinSize[0], $iH_hWnd = $aWinSize[1]
    Local $hDC_Capture = _WinAPI_GetWindowDC($hWnd)
    Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Capture)
    Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC_Capture, $iW_hWnd, $iH_hWnd)
    Local $hObjectOld = _WinAPI_SelectObject($hMemDC, $hHBitmap)
    DllCall("user32.dll", "int", "PrintWindow", "hwnd", $hWnd, "handle", $hMemDC, "int", 0)
    Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap)
    _WinAPI_DeleteDC($hMemDC)
    _WinAPI_SelectObject($hMemDC, $hObjectOld)
    _WinAPI_ReleaseDC($hWnd, $hDC_Capture)
    _WinAPI_DeleteObject($hHBitmap)
;~  _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "Test.bmp")
    Local $x, $y, $aPixelColors[$iH - $iY][$iW - $iX], $aRes
    For $y = $iY To $iY + $iH - 1
        For $x = $iX To $iX + $iW - 1
            $aRes = DllCall($ghGDIPDll, "uint", "GdipBitmapGetPixel", "handle", $hBitmap, "int", $x, "int", $y, "uint*", 0)
            $aPixelColors[$y][$x] = Hex($aRes[4], 8)
        Next
    Next
    _GDIPlus_BitmapDispose($hBitmap)
    Return $aPixelColors
EndFunc

Unfortunately the PrintWindow doesn't do an exact copy.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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  
Followers 0