Jump to content

Image (multiple pixels) search


Go to solution Solved by Trejuzz,

Recommended Posts

Hello everyone, :bye:

I'm trying to learn AutoIt language, but I'm struggling a little, because I can't find a proper learning source, anyways I'm trying to know it better and all it's features, pixel search is really cool one, but the problem with it is that if I'm trying to find exact color (0x000000 for example) it finds a lot of them, what if I want to click on Steam logo or something? Only image search came to my mind, however I have been trying to run it, it doesn't... Can someone please look at my code and tell me what's wrong with it?

#include <ImageSearch.au3>

Global $x, $y

HotKeySet("q", "drag")
HotKeySet("-","exits")

while 1
   sleep(200)
WEnd

Func drag()
   $search = _ImageSearch ("5.png",0,$x,$y,0)
   if $search > 0 Then
      MouseClick ("left", $x,$y)
   EndIf
EndFunc


Func exits()
   Exit
EndFunc
Edited by Melba23
Fixed font
Link to comment
Share on other sites

I think your thread is going to get banned because you are doing something with a game. I think the problem is how you are calling your image. You need to tell autoit the directory location of 5.png. Try:

  1.  $search = _ImageSearch (@scriptDir & "5.png",0,$x,$y,0)

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Developers

I think your thread is going to get banned because you are doing something with a game. I

isn't is strange you state this and still answer the question?

@op, have you read the forum rules?

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

Link to comment
Share on other sites

isn't is strange you state this and still answer the question?

@op, have you read the forum rules?

Yes I did.

 

I think your thread is going to get banned because you are doing something with a game. I think the problem is how you are calling your image. You need to tell autoit the directory location of 5.png. Try:

  •  $search = _ImageSearch (@scriptDir & "5.png",0,$x,$y,0)

I have been trying to make a statistic program from log file, which is presented in image format. I did try your suggestions, nothing changed tho. Edited by Melba23
Fixed font
Link to comment
Share on other sites

  • Solution

So I played with the code a bit and seems that when I write ones insted of zeros, everything is working.

Can anyone tell me, what those parameters exactly mean?

$search = _ImageSearch ("5.png",1,$x,$y,1)
$search = _ImageSearch ("5.png",0,$x,$y,0)
Edited by Melba23
Fixed font
Link to comment
Share on other sites

From ImageSearch.au3 32 bit:

Func _ImageSearch($findImage,$resultPosition,$x, $y,$tolerance, $HBMP=0)
; 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

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Link to comment
Share on other sites

  • Moderators

Trejuzz,

Please use the standard font in future. Thanks for you cooperation. :)

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

 

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