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 ?

https://streamable.com/l3pit

 

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

Edited by Miliardsto
Link to comment
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)
Next

 

Link to comment
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 comment
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])
EndIf
Next

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 comment
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 comment
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
  endif
Wend

Self-explanatory.

Link to comment
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 comment
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
 Share

×
×
  • Create New...