Guest Posted September 19, 2012 Share Posted September 19, 2012 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? Link to comment Share on other sites More sharing options...
guinness Posted September 19, 2012 Share Posted September 19, 2012 (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 September 19, 2012 by guinness 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Guest Posted September 19, 2012 Share Posted September 19, 2012 I know. But what steps i need to do to use it? Link to comment Share on other sites More sharing options...
BigDod Posted September 19, 2012 Share Posted September 19, 2012 I know.But what steps i need to do to use it?If you need that then you should ask on a C++ forum 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 Link to comment Share on other sites More sharing options...
guinness Posted September 19, 2012 Share Posted September 19, 2012 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. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2012 Share Posted September 19, 2012 You can do all that in autoit, and I can tell you this, it will not work on a minimized window. There are plenty of other functions to work with GUIs though, much better, easier and cleaner. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Guest Posted September 19, 2012 Share Posted September 19, 2012 (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 thingI 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 September 19, 2012 by Guest Link to comment Share on other sites More sharing options...
JohnOne Posted September 19, 2012 Share Posted September 19, 2012 It's relative, people pick all things up with varying degrees of difficulty. Translate that whole code up there to Autoit, then revisit your plan. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mechaflash Posted September 19, 2012 Share Posted September 19, 2012 Oops I did not notice .. Wow I can not believe how language similar to C++It's Almost the same thingI 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.” Link to comment Share on other sites More sharing options...
UEZ Posted September 19, 2012 Share Posted September 19, 2012 (edited) Try this: expandcollapse popup;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 September 19, 2012 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now