Jump to content

Pixelsearch for icons?


heyhey
 Share

Recommended Posts

For example, I want to script a bot that presses the refresh button (JUST FOR EXAMPLE)

but to do that, I need the bot to recognise the refresh button , and mousemove to it, and then mouseclick it , something like

$refreshbutton=pixelsearch (0,0,1024,768,"graycolor") ; to lazy to search the refresh color just for this script
$refreshbutton2=pixelsearch (0,0,1024,768,"graycolor2")

;then something to make it click in between them, I don't know how though, could you help me out?

I have read all the help files that weare about "pixels" , could not find how to do it, please help me :)

Thanks.

EDIT: just making it more clear, there is an icon with 4 colors in it, sized 4x4 cm (example) , I want something to check if there is a 4x4 square in your screen having 4 color's, and click in the middle of it ;)

Edited by heyhey
Link to comment
Share on other sites

If you have read everything about the functions then what are the values inside $refreshbutton and $refreshbutton2 ?

Reading the help file (which you have done) tells you.

Then move along and read the mouse* functions.

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

I have read them, but "graycolor" in my code is supposed to be the decimal color code of the refresh button, I was to lazy to get that.

Or did you mean something else? I have read and re-read the 4 files about Pixels .

Thanks.

Link to comment
Share on other sites

Yes, your "graycolor" aside, do you understand what values the variables you assigned to PixelSearch hold?

That is the absolute minimum you need to grasp before you can move along.

If the search is successful the variable holds a one dimensional array, [0] and [1] - [x] and [y] co-ordinates.

The reast is maths and mousemove().

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

I still do not understand it ,this is the code I tryed to write :

hotkeyset("^d","zeker")
$icon = PixelSearch(0,0,1200,1200,13227984)
While 1
    Sleep(50)
WEnd
Func zeker()
    MouseMove($icon [0],$icon [1])
    MouseClick("left")
EndFunc

But, there are several pixels with that color in my area I'm working in, so I want a group of 2-3 different pixels in a little square?

Yes, I do know what the values are , they assign where I want the pixelsearch to search the pixels.

EDIT : typo in the code

Thanks.

Edited by heyhey
Link to comment
Share on other sites

Hmm, I have tryed that , but I do not understand (this time I have read the full pages)

This is the code that I tryed :

#include <Imagesearch.au3>
While 1
    sleep(50)
WEnd
If _Imagesearch("C:\moetlukkentoch.png",0,0,@DesktopWidth,@DesktopHeight) Then
    @error=0
EndIf
if @error =0 Then
    MsgBox(0,"","Lol")
Else 
    msgbox(0,"","Fail")
EndIf

I just can't find how the function works :)

Someone had put a link to an autoHotKey explanation of it, but doing it that way did not work either, so the functions differs from AHK's function

I'm sorry, I have tryed it, could you please help me out?

EDIT : Woah, just noticed a double post, I'm sorry ;)

Edited by heyhey
Link to comment
Share on other sites

It doesn't work like PixelSearch. Here is the documentation on _ImageSearch:

You will see it's nothing like: Color, X, Y, W, H at all.

;===============================================================================
;
; Description: Find the position of an image on the desktop
; Syntax: _ImageSearchArea, _ImageSearch
; Parameter(s): 
; $findImage - the image to locate on the desktop
; $tolerance - 0 for no tolerance (0-255). Needed when colors of 
; image differ from desktop. e.g GIF
; $resultPosition - Set where the returned x,y location of the image is.
; 1 for centre of image, 0 for top left of image
; $x $y - Return the x and y location of the image
; $transparency - TRANSBLACK, TRANSWHITE or hex value (e.g. 0xffffff) of
; the color to be used as transparency; can be omitted if
; not needed
;
; Return Value(s): On Success - Returns 1
; On Failure - Returns 0 
;
; Note: Use _ImageSearch to search the entire desktop, _ImageSearchArea to specify
; a desktop region to search
;
;===============================================================================
Link to comment
Share on other sites

After a quick check, (excuse me if I didn't read close enhough, I'm not at home atm) I noticed it said "locate an image on the desktop" , I want this to run on a browser, does that matter?

I'm on my phone atm.

thanks

EDIT:

So, I typed this on my pc (this is how I understanded the description)

#include <Imagesearch.au3>
$x = 0
$y = 0
_Imagesearch("moetlukkentoch.png",30,1,$x,$y)
While 1
    sleep(50)
    MouseMove($x,$y)
WEnd

moetlukkentoch.png = name

30 = tolerance

1 = I want it to move to the middle

$x = didnt understand in the description

$y = same, didn't understand

Can you help me out? I want the mousemove to go to the middle of the image, the image was on top when testing this.

Edited by heyhey
Link to comment
Share on other sites

Sorry if I am annoying ,and I'm sure I am, but could you just make an example for me in the case I tryed ?

(this one)

#include <Imagesearch.au3>
$x = 0
$y = 0
_Imagesearch("moetlukkentoch.png",30,1,$x,$y)
While 1
    sleep(50)
    MouseMove($x,$y)
WEnd

Because I don't understand it at all, I tryed using @error, but I don't have experience on that.

I'm really sorry, I know I sound dumb and I know I am annoying :)

Sorry.

Link to comment
Share on other sites

If you are checking for a certain image to appear in a certain place, then it may be as simple as PixelChecksum()

If you run the below code, it will get a checksum of all the pixels of a 20x20 area at the very top left of your screen (usually the windows icon if its maximized)

it then checks that area and if it changes (you maximize a different window) alerts you

$PixelChecksum = PixelChecksum(0,0,20,20)

While 1
    If PixelChecksum(0,0,20,20) <> $PixelChecksum Then
        MsgBox(0,"Msg","Checksum changed")
        Exit
    EndIf
    Sleep(100)
WEnd

Maybey its what you want, maybe its not.

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

No, I did know about pixelchecksum , but I appreciate your attempt :)

What I want is for instance, when I'm on a page of an uploading/downloading website , I want it to search for the download image, and click on it

(this is just an example, I'm thinking of other scripts where I need imagesearch for also, to bad after 3 hours of trying, I couldn't get imagesearch to work)

Thank you John, Manadar, I hope that I will one time be able to do it ;)

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