Jump to content

Reading pixel colors from few windows at same time

Recommended Posts

Im wondering if its possible to read pixel colors from not only from top window.

For example I got a few windows with images how (in attachment video) . Is it possible to read pixel color for example 200px, 200px from top left ?

Can i make something like winlist for the same window names and then get handles for every listed exact name window and then read for every window pixel color for example: 200px, 200px from top left ?



2018-12-10 01-02-38.mp4

Edited by Miliardsto
Link to post
Share on other sites

You could do something like this :

#include <ScreenCapture.au3>

Opt ("MustDeclareVars", 1)

Global $ahWnd = WinList ("Something here"), $aHBitMap[$ahWnd[0][0]]

For $i = 1 to $ahWnd[0][0]
  WinActivate ($ahWnd[$i][1])
  WinWaitActive ($ahWnd[$i][1])
  $aHBitMap[$i-1] = _ScreenCapture_CaptureWnd ("",$ahWnd[$i][1],0,0,200,200,False)


Link to post
Share on other sites

Is there a possibility to check Pixelgetcolor from for example 3 windows at the same time, in real time, without using screen capturing?

1 window is on top

2,3 windows below the first one

These pixels colours would be changing from time to time and in loop I want to check their colors using timers every 5 seconds for example.

So making scrrenshots would not be appropriate in this case.

Link to post
Share on other sites


$hWnd = WinList ("Window","")
For $i = 1 to $hWnd[0][0]
$Coord = PixelSearch(200, 200, 10, 10, "color" ,"","",$hWnd[$i][1])
If Not @error Then
    MsgBox(64, "", "X and Y are: " & $Coord[0] & "," & $Coord[1])

you can use the handle of windows in the pixelsearch 

Edited by Aelc

why do i get garbage when i buy garbage bags? <_<

Link to post
Share on other sites

You can use AdlibRegister ("function", 5000) to launch a function every 5 secs that would check the pixels like @Aelc showed you. Or you can use TimerInit () along with TimerDiff ($hTimer) in a loop until you reach 5 secs.

Link to post
Share on other sites
Global $hTimer = TimerInit (), $iTime
While True
  Do something here or Sleep (50)
  $iTime = TimerDiff ($hTimer)
  if $iTime >= 5000 then ; when it reach 5 secs, execute something
    Do someother things here
    $hTimer = TimerInit () ; reinit timer


Link to post
Share on other sites

Several things

  1. If you want to look at a pic as you show in the video, then why not just look at the pic and not windows explorer view?
  2. Why do you need to use pixel searching in the first place? Have you tried to ID the control in question? Using pixel searching is VERY UNSTABLE and causes many scripts to break.
  3. What is the ACTUAL application you are wanting to automate? I ask for in MANY CASES there is a script that will do it so having to reinvent the wheel is a waste of time when we can point you in the right direction. 
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By kcvinu
      Hi all,
      I want to show a color dialog box to user from my script. Is it possible ? I searched in help file but can't find anything related to a color dialog. 
    • By Miliardsto
      hello Im wondering if it is possible to process image in autoit like this
      1. firstly there is colorfull wallpaper
      2. Fill all colors (exception rose color) - with white
      3. Fill rose color with black color
      I see Gdi functions have things to manipulate images
    • By AndyS01
      I want to create a slider that has values representing colors, like the slider on the _ChooseColor() GUI in the Misc.au3 UDF, but the max value for a slider is 32767.  
      Here is my test code:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SliderConstants.au3> #include <Misc.au3> $hGUI = GUICreate("Test", 100, 560) $BtnID = GUICtrlCreateButton("Choose", 10, 10, 50, 25) ;~ GUICtrlSetOnEvent($BtnID, "handle_choose_btn") $flags = BitOR($TBS_AUTOTICKS, $TBS_VERT) $iSliderID = GUICtrlCreateSlider(10, 50, 40, 420, $flags) $hSlider_hWnd = GUICtrlGetHandle($iSliderID) $iMaxVal = 32767 GUICtrlSetLimit($iSliderID, $iMaxVal, 0) ; change min/max value GUISetState() GUIRegisterMsg($WM_VSCROLL, "WM_V_Slider") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_PRIMARYUP ToolTip("") case $BtnID handle_choose_btn() EndSwitch WEnd ; React to a slider movement Func WM_V_Slider($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If $lParam = $hSlider_hWnd Then $iValue = GUICtrlRead($iSliderID) ConsoleWrite("+++: $iValue = " & $iValue & @CRLF) ToolTip(getRGB($iValue)) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_V_Slider ; Extract the RGB components from the color value Func getRGB($iColorVal) Local $hexstr, $b, $g, $r, $rgb $hexstr = StringFormat("%06X", $iColorVal) $r = StringMid($hexstr, 1, 2) $g = StringMid($hexstr, 3, 2) $b = StringMid($hexstr, 5, 2) $rgb = StringFormat("" & $iColorVal & " - rgb: %02s %02s %02s", $r, $g, $b) Return ($rgb) EndFunc ;==>getRGB Func handle_choose_btn() $color = _ChooseColor(2, 255, 0, $hGUI) ConsoleWrite("+++: $color = " & Hex($color, 8) & @CRLF) EndFunc ;==>handle_choose_btn  
    • By duzers
      I have to write script  ( as simple as possible) to read messages from other scripts (something like queue to run). How to start? Which groups of functions? Any ida?
    • By xiantez
      Hey Community,
      I was changing around my color scheme manually for syntax highlighting. I really enjoy using a dark background color. However, this seems to be problematic because my blinking cursor is also very dark. Is there a setting in the ScITE config where I can manipulate the blinking cursor to be a different color like "white" so it is easy to spot when coding. The closest thing I found was "Caret Line Color", but this just changes the line highlight.  Your help is greatly appreciated!!

  • Create New...