Sign in to follow this  
Followers 0
nOne

advanced pixelsearch

6 posts in this topic

hi folks

here my first script im posting, hope someone can use it :(

it is able to search for a given aerea of pixels in a spezific window

you can store the field in an file to use it later or store it in an array

but its a litte slow on big fields because it scanes every pixel and compares it

with those you have spezified first, im trying to get it faster but havent got a good idea yet

(it took my 2ghz amd to scan through 800x600 72 secs)

probably one of you has an idea ? :lol:

the commands are descriped in the .au3 file

Link to the Script

probably test it with this testscript

#include "pixelfunc.au3"
         MsgBox(0,"Start position", "place cursor on START" & @LF & "position and press enter")
        $frompos = MouseGetPos()

        $fromx=$frompos[0]
        $fromy=$frompos[1]

        MsgBox(0,"End position", "place cursor on END" & @LF & "position and press enter")
        $topos = MouseGetPos()

        $tox=$topos[0]
        $toy=$topos[1]

        $windowname="Untiteled - Notepad"
        $file="test.txt"
        
        $pixel=_Pixelfieldtofile($fromx, $fromy, $tox, $toy, $file)
       ;$pixel=_Pixelfieldtoarray($fromx, $fromy, $tox, $toy)
        MsgBox(0,"status", $pixel)
        $pixelarray=_Pixelfieldsearchfromfile($file, $windowname)
       ;$pixelarray=_Pixelfieldsearchfromarray($pixel, $windowname)
        if isarray($pixelarray) Then
           MouseMove($pixelarray[0],$pixelarray[1],10)
           MsgBox(0,"returnwert", "fromx = " & $fromx & @LF & "fromy = " & $fromy & @LF & "tox = " & $tox & @LF & "toy = " & $toy & @LF & @LF & "startx = " & $pixelarray[0] & @LF & "starty = " & $pixelarray[1] & @LF & "endx = " & $pixelarray[2 ] & @LF & "endy = " & $pixelarray[3])        
           MouseMove($pixelarray[2],$pixelarray[3],10)
           MsgBox(0,"returnwert", "fromx = " & $fromx & @LF & "fromy = " & $fromy & @LF & "tox = " & $tox & @LF & "toy = " & $toy & @LF & @LF & "startx = " & $pixelarray[0] & @LF & "starty = " & $pixelarray[1] & @LF & "endx = " & $pixelarray[2 ] & @LF & "endy = " & $pixelarray[3])        
        else
           MsgBox(0,"returnwert", "wert = " & $pixelarray)
        endif

im sorry for my grammar, its terrible :ph34r:

Share this post


Link to post
Share on other sites



Interesting, can be used to find a icon in the systray?

Share this post


Link to post
Share on other sites

am i correct in assuming that this will locate a string of text via pixel colors on the screen? or could we get a better description of what it does?

Thanks

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

to make it faster, try implementing a step feature, where the user inputs step # and script would search for every other pixel if step = 2 or every 3 pixels if step = 4 etc.

is "untitled" supposed to be misspelled?

Edited by mcfr1es

Roger! You son of a big pile o' Monkey Nuts.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OR NOT stringisint($userfile)

very funny ... :lol:

i've never seen an integer file :lol:

another bug:

Func _Pixelfieldsearchfromfile($userfile, $windowname, $mode)

   $file = FileOpen($userfile, 0)

   if @error = -1 Then
      FileClose($file)
      return -1

The error code is written in $file. (and btw: why close a file which hasnt been opened?)

Func _Pixelfieldsearchfromfile($userfile, $windowname, $mode)

   $file = FileOpen($userfile, 0)

   if $file = -1 Then
      return -1

there's missing a parameter in your example (at least it didnt work here without it):

$pixelarray=_Pixelfieldsearchfromfile($file, $windowname)

has to be:

$pixelarray=_Pixelfieldsearchfromfile($file, $windowname, 1)

Just an idea: To let the user know, where your search is u could move the mouse to the corresponding line (not to exact pixel, else it would get slower). So you can see, if it is still running and how far it got.

All in all it's a nice idea. Keep on working on it.

Greetings,

ZeD

P.S. LOL, i just saw the post is some months old. i guess he's not looking here any more :(:ph34r:

Edited by ZeDMIN

Share this post


Link to post
Share on other sites

Im just writing a script which compares the Pixels from the place where u got them with the pixels that are currently on the screen (at the same position) - thats much faster - but if the position has changed it doesnt work...

Script (Based on none's script coming soon)

It can be used for checking a active Window (maybe for Games) if a special element is active

Share this post


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
Sign in to follow this  
Followers 0