Jump to content
c7aesa7r

GetPixel Background Window

Recommended Posts

#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>


$Title = "New Tab - Brave"
$Hwnd = WinGetHandle($Title)
ConsoleWrite("Handle "&$Hwnd&@CRLF)

Local $BMP

$xTime = TimerInit()

$X = 0
$Y = 0

$Color = GetColor($x, $y, $hwnd)
ConsoleWrite("Pixel COlor "&$Color&@CRLF)


While 1

     $aPixelColor = _GDIPlus_BitmapGetPixel($BMP, $X, $Y)

     $X = $X + 1

     $R = Hex($aPixelColor, 6)

     ConsoleWrite(Dec($R) & @CRLF)

     If $X = 1920 Then ExitLoop

WEnd


$yTime = TimerDiff($xTime)
ConsoleWrite("Time " & $yTime)



Func GetColor($iX,$iY,$WinHandle)

    _GDIPlus_Startup()

    Local $aPos = WinGetPos($WinHandle)
    $iWidth = $aPos[2]
    $iHeight = $aPos[3]
    Local $hDDC = _WinAPI_GetDC($WinHandle)
    Local $hCDC = _WinAPI_CreateCompatibleDC($hDDC)

    $hBMP = _WinAPI_CreateCompatibleBitmap($hDDC, $iWidth, $iHeight)


    _WinAPI_SelectObject($hCDC, $hBMP)
    DllCall("User32.dll", "int", "PrintWindow", "hwnd", $WinHandle, "hwnd", $hCDC, "int", 0)
    _WinAPI_BitBlt($hCDC, 0, 0, $iWidth, $iHeight, $hDDC, 0, 0, $__SCREENCAPTURECONSTANT_SRCCOPY)


    $BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
    $aPixelColor = _GDIPlus_BitmapGetPixel($BMP, $iX, $iY)


    ;_WinAPI_ReleaseDC($WinHandle, $hDDC)
    ;_WinAPI_DeleteDC($hCDC)
    ;_WinAPI_DeleteObject($hBMP)
    ;_GDIPlus_ImageDispose($BMP)
    ;_GDIPlus_Shutdown()

    $P = Hex($aPixelColor, 6)
    Return Dec($P)
EndFunc   ;==>GetColor

 

While 1
     
     ;$BMP = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
     $aPixelColor = _GDIPlus_BitmapGetPixel($BMP, $X, $Y)

     $X = $X + 1

     $R = Hex($aPixelColor, 6)

     ConsoleWrite(Dec($R) & @CRLF)

     If $X = 1920 Then
     $X = 0
     $Y = $Y + 1
     EndIf
     If $Y = 1080 Then ExitLoop
     
     Wend

Any way to speed the searching?

Took: Time 79340.229 on a 1920x1080

 

 

Do someone know if FastFind:

1. Possible to search pixel on background windows? 

2. Search pixel inside a file image

 3. Instead capturing a print, load it from a file

https://www.autoitscript.com/forum/topic/126430-advanced-pixel-search-library/

 

Is possible capture images from background windows, if could make fastfind use it instead capturing the screen, then could be possible use ff to search pixels on back windows

Edited by c7aesa7r

Share this post


Link to post
Share on other sites

c7easa7r, 

It looks as if you are trying to automate a game: "Brave". Is this in fact the case? 

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You are obsessed about people asking for game automate?

Brave is a browser like chrome,firefox,etc, you could had searched before, as some of you always like to tell people to go read help file. 🤭

Edited by c7aesa7r

Share this post


Link to post
Share on other sites
5 minutes ago, c7aesa7r said:

you are obsessed about people asking for game automate? brave is a browser like chrome,firefox,etc, you could had searched before, as some of you always like to tell people to go read help file. 🤭

And you could realize that a simple question was being asked, by someone who has the authority to do so, and choose not to be childish in answering.

Or, you could have specified that you are trying to automate the Brave browser and you would have been directed toward UIAutomation as a stable way to do what you're after rather than trying to hack at it with Pixel Searches. :)

 

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

c7easa7r, 

There is no need to get all excited - the game reference came up first when I searched. You might note that I asked politely and did not just lock the thread, so I fail to see why you took such an aggressive stance. Just chill a bit. 

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I thank you if could stop the drama, and I don’t took an aggressive stance, it’s up to you, keep focus on the topic

JLogan Ui automation wouldn’t help.

Looking for a way to search pixel in back windows, my actual script takes so long to scan the screen

Share this post


Link to post
Share on other sites
41 minutes ago, c7aesa7r said:

I thank you if could stop the drama, and I don’t took an aggressive stance, it’s up to you, keep focus on the topic

What a load of bullocks and you know it, so let me add to you drama: you did have a very impolite answer to the simple question asked and you choose to remain sort of agressive in  your last answer so what about trying to dim it or else i/we have no hesitation to shut you up....and yes this is also an agressive tone but that happens when you behave as an idiot. ;)

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Could you explain what is it you try to achieve beside the technical issue ?  Maybe understanding the end result of your automation would help us to provide a better solution ?

Share this post


Link to post
Share on other sites

Jos I don’t care about anything you say or think so
Nine I’m trying search for pixels in back windows, I already achieved it with the script I post,  but takes long for a full scan 

Edited by c7aesa7r

Share this post


Link to post
Share on other sites
Just now, c7aesa7r said:

Nine I’m trying search for pixels in back windows, I already achieved it with the script I post,  but takes long

I know that, I looked at your code.  But why ?  I hardly can think of a browser application you could automate by searching pixel colors to be honest.

Share this post


Link to post
Share on other sites
32 minutes ago, c7aesa7r said:

Jos I don’t care about anything you say or think so

Come back when you have given up on the crap attitude. Not in the mood for babysitting today.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
1 hour ago, c7aesa7r said:

Jos I don’t care about anything you say or think so

Same here so keep it and you'll get naughty spot time ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...