Jump to content

windows 7 pixelsearch quetion


Recommended Posts

Hi does anyone know if the pixelsearch() func is as slow in winodws 7 as it is in vista, i have diabled Aero theme, (which speed it up dramatically).

gonna try the beta windows 7 and would like to know if its as lightning fast with the Glass theme on.

Many Thanks.

Link to comment
Share on other sites

try this:

#Include <WinAPI.au3>
#include <Color.au3>

Global $x1 = 50, $y1 = 50, $x2 = 100, $y2 = 300, $color = 0xFFFFFF, $speed = 1, $win_handle = "[ACTIVE]"

Global $time_start = TimerInit()
$pixel_coord = _pixel_search_win7($x1, $y1, $x2, $y2, $color, $speed, $win_handle);X-start, Y-start, X-end, Y-end, Color, Speed, WinHandle
if NOT @error Then
    $time = TimerDiff($time_start)
    MsgBox(0, "Win7", $pixel_coord[0] & ", " & $pixel_coord[1] & @CRLF & "time [ms]: " & Round($time, 2))
Else
    MsgBox(0, "", "color not found")
EndIf

$time_start = TimerInit()
$pixel2 = PixelSearch($x1, $y1, $x2, $y2, $color, $speed, -1, $win_handle)
if NOT @error Then
    $time = TimerDiff($time_start)
    MsgBox(0, "PixelSearch", $pixel2[0] & ", " & $pixel2[1] & @CRLF & "time [ms]: " & Round($time, 2))
Else
    MsgBox(0, "", "color not found")
EndIf

Func _pixel_search_win7($i_Left, $i_Top, $i_Right, $i_Bottom, $i_Color, $i_Speed = 1, $i_Win_handle = 0)
    if $i_Speed = -1 then $i_Speed = 1
    if $i_Win_handle = -1 then $i_Win_handle = 0
    Local $hGDI = DllOpen("gdi32.dll"), $color, $found = false
    Dim $ret_val[2]
    Local $hDC = _WinAPI_GetDC($i_Win_handle)
    For $i = $i_Top To $i_Bottom Step +$i_Speed
        For $j = $i_Left To $i_Right Step +$i_Speed
            $color = DllCall($hGDI, "int", "GetPixel", "int", $hDC, "int", $j, "int", $i)
            if "0x" & Hex($color[0], 6) = $i_Color Then
                $found = True
                $ret_val[1] = $i
                $ret_val[0] = $j
                ExitLoop
            EndIf
        Next
        if $found = True then ExitLoop
    Next
    _WinAPI_ReleaseDC($i_Win_handle, $hDC)
    DllClose($hGDI)
    if $found = true Then
        Return $ret_val
    Else
        SetError (1)
    EndIf
EndFunc

anyway, always use winhandle it'll speed up the search :)

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...