Jump to content

@SW_HIDE pixelsearch.


Recommended Posts

Is it possible to pixelsearch a @SW_HIDE window. If it's possible, how can I use ofLight's pixelfindall with this hidden window.

;=================================   PixelFindAll   ==============================
; Function Name:    _PixelFindAll
; Description:      Finds all instances of a pixel within a given area and returns array with Total and all locations X and Y.
;                   Allows you to limit results by skiping pixels within a given distance to each other.
; Requires:                         None
; Parameters:       $Pixel          Colour value of pixel to find (in decimal or hex).
;                   $XDist          Horizontal distance from found pixel to skip before continueing search (moving right)
;                   $YDist          Vertical distance from found pixel to skip before continueing search (moving down)
;                   $sv             Shade Varience
;                   $SB_l           left coordinate of total area to search. Default is 0 (far left side of screen)
;                   $SB_t           top coordinate of total area to search. Default is 0 (top most Side of screen)
;                   $SB_r           Right coordinate of total area to search. Default is @DesktopWidth (Far Right side of screen)
;                   $SB_b           Bottom coordinate of total area to search. Default is @DesktopHeight (Bottom most side of screen)
; Syntax:         _PixelFindAll($pixel[, $XDist, $YDist, $sv, $SB_l, $SB_t, $SB_r, $SB_b])
; Author(s):    
; Returns:      $Array[0][0] = 0 on failure
;===============================================================================
Func _PixelFindAll($pixel,$XDist=0,$YDist=0,$sv=0,$SB_l=0,$SB_t=0,$SB_r=@DesktopWidth,$SB_b=@DesktopHeight)
    Dim $Array[2][2], $Count = "0", $SB_l_Max = $SB_l, $SB_b_Max = $SB_b
    $Array[0][0] = "0"

    While 1
        $xy = PixelSearch($SB_l,$SB_t,$SB_r,$SB_b,$pixel,$sv)
        If @error And $SB_b = $SB_b_Max Then
            SetError(1)
            
            Dim $Array2[2][2]
            $Array2[0][0] = "0"
            $Count = "0"

            For $i = 1 to $Array[0][0]
                $Write = 1              
                For $j = $i+1 to $Array[0][0]
                    $VarX = _CompareNumbers($Array[$i][0], $Array[$j][0], $XDist)
                    If $VarX = 0 Then
                        $VarY = _CompareNumbers($Array[$i][1], $Array[$j][1], $YDist)
                        If $VarY = 0 Then $Write = 0
                    EndIf
                Next
                If $Write = 1 Then
                    $Count = $Count+1
                    $Array2[0][0] = $Count
                    ReDim $Array2[$Count+1][2]
                        $Array2[$Count][0] = $Array[$i][0]
                        $Array2[$Count][1] = $Array[$i][1]              
                EndIf
            Next

            Return $Array2
        ElseIf @error Then
            $SB_t = $SB_b + 1
            $SB_b = $SB_b_Max
            $SB_l = $SB_l_Max
        Else
            $Count = $Count+1
            $Array[0][0] = $Count
            ReDim $Array[$Count+1][2]
            $Array[$Count][0] = $xy[0]
            $Array[$Count][1] = $xy[1]

            $SB_t = $xy[1]
            $SB_b = $SB_t
            $SB_l = $xy[0]+1+$YDist 
        EndIf
    WEnd
EndFunc;==========================  PixelFindAll   ===============================

Func _CompareNumbers($Number1, $Number2, $byhowmuch);SUB Function of PixelFindAll
    ;Verify that $Number1 is more than $byhowmuch from $Number2
    ;Returns 0 if within $byhowmuch
    If $Number1 = $Number2 Then
        Return 0
    ElseIf $Number1 > $Number2 Then
        If ($Number1-$byhowmuch) >= $Number2 Then Return 1
    ElseIf $Number1 < $Number2 Then
        If ($Number1+$byhowmuch) <= $Number2 Then Return 1
    EndIf
    Return 0
EndFunc
Link to comment
Share on other sites

I have just tried to do the above without any luck. I can't even get autoit to read the colour even if paint is minimized. Any suggestions?

HotKeySet("{F1}", "Terminate")
HotKeySet("{F2}", "Hide")
HotKeySet("{F3}", "Show")
HotKeySet("{F5}", "_Search")

Func _Search()
$7 = 0
$colour = 0xFC0E73
$search = PixelSearch(0, 0, @DesktopWidth, @DesktopHeight, $colour, 0, 1, "Untitled - Paint")
If Not @error Then
    MsgBox(0,"Error","Found Colour")
EndIf
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func Hide()
    WinSetState ("Untitled", "", @SW_HIDE)
EndFunc

Func Show()
    WinSetState ("Untitled", "", @SW_SHOW)
EndFunc

WinWaitClose("")
Link to comment
Share on other sites

I don't think you get what he's saying. To be able to search for a pixel in a window that window has to be drawn on screen. For example a window completely hidden doesn't count as being on screen. However; a window that is not hidden but below another window still counts as being drawn on screen and you can search for a pixel on a window that is not top-most.

Hooking into paint would let you do a lot of things but I don't think it would let you use pixelsearch on its window when you've made it hidden.

Link to comment
Share on other sites

I do understand, but even if paint is open and theres a window infront of paint the colour won't pick up. So basically paint is not top-most but still active on the desktop and no colour detected. Reason I'm asking is cause I have a script written and want to be able to still use my pc whilst still using autoit, but the application that autoit controls requires to be fullscreen.

Link to comment
Share on other sites

It wont find a pixel if there is a window hiding it.

It wont find a pixel if the window is minimized.

It wont find a pixel if the window is hidden.

The window does not have to be the active one, but the pixel simply has to be visible.

You are flogging a dead horse, if you want to use your computer while your bot is running then use a virtual machine of some sort.

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

How about _IEAttach with pixelsearch is this possible? The code below does find the embedded object even while IE is minimized. I currently do use virtualbox, but it's so slow. So would prefer to get my script to work with current desktop.

#include <IE.au3>

Dim $aIE[1]
$aIE[0] = 0

$i = 1
While 1
    $oIE = _IEAttach ("MySite", "embedded", $i)
    If @error = $_IEStatus_NoMatch Then ExitLoop
    ReDim $aIE[$i + 1]
    $aIE[$i] = $oIE
    $aIE[0] = $i
    $i += 1
WEnd

MsgBox(0, "Browsers Found", "Number of browser instances in the array: " & $aIE[0])


WinWaitClose("")
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...