Jump to content

wait for image search (help please)


Recommended Posts

Trying to make a simple do until function using image search. problem is i have no idea what i'm doing wrong.

I'm very new to coding (<1week) so any help with working example of the following with details explaining how xyz is done to help me learn would be great help.

#include <ImageSearch.au3>

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("^{PAUSE}", "Terminate")


;The part Below i need help with.

$Search = _WaitForImageSearch("C:\Users\IIIRAZORIII\Desktop\image.bmp")

Do
MouseMove(300,300,0)
sleep(300)
until $Search = 1







Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is Paused',1047,0," Warning",0,4)
WEnd
ToolTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc

I'm sorry i understand this gets asked alot, but the examples i've seen i don't understand. and the syntax within the attached file, i'm not sure what, if any changes i have to make.

thank you in advance

ImageSearch.au3

Edited by IIIRAZORIII
Link to comment
Share on other sites

  • Moderators

What application are you trying to manipulate? There may be a much easier way to accomplish this rather than using imagesearch.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

at this stage i have no program yet, just trying to learn common features i have seen within vtask studio.

got frustrated with no toggle pause with that program, so trying to learn autoit : )

anyways i'm going try and compile a shopping list of mutli items into list format within excel, data entry will be very large and nothing is set position.

image searching will work nice, (if i can get it working)

atm thought just learning how xyz works and why is the stage i'm currently at and the example and details i been readin don't really help explain much to someone who is complety new to coding.

Link to comment
Share on other sites

  • Moderators

Well, understand that we follow a "teach a man to fish" method here, rather than spoon-feeding code (best way to learn). Rather than generalized "I wanna learn everything in AutoIt" questions, the best format for gaining assistance on this forum is always going to be something like this:

I am trying to do a, b, and c in program xyz on this Operating System using this version of AutoIt (detailed explanation)
I have attempted to solve my problem by doing this (post code)
I expected the script to do this, but instead, it is doing this (give error codes)
Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

i am trying to get wait for image search to work, in

SciTE-Lite

Version 2.28

On Windows 7 x64

so far i have on been able to get the following to work.

#include <ImageSearch.au3>
HotKeySet("s", "Start")

$x = 0
$y = 0

func Start()
$Search = _ImageSearch("C:\Users\IIIRAZORIII\Desktop\image.bmp", 0, $x , $y, 0)
If $Search = 1 Then
MouseMove($x, $y,0)
EndIf
EndFunc

While 1
Sleep(100)
WEnd

within the same UDF attatched within the first post there is a" WaitForImageSearch" function that i'm unable to get working as i don't understand the syntax or instructions given.

i was hoping someone would be able to post a working script using the the "WaitForImageSearch" function so i can learn the syntax with a working example. allowing me to make edits for trial and error to see what works and what doesn't. In order to be able to do this i need a working prototype. and hence the reason i'm asking for help.

i expect the script below to wait for x image

if the image is true the mouse moves telling me its working (could use message box as i've seen most do)

if false the script will repeat untill x image is found

#include <ImageSearch.au3>

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("^{PAUSE}", "Terminate")


;The part Below i need help with.

$Search = _WaitForImageSearch("C:\Users\IIIRAZORIII\Desktop\image.bmp")

Do
MouseMove(300,300,0)
sleep(300)
until $Search = 1







Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is Paused',1047,0," Warning",0,4)
WEnd
ToolTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc

anyways hope this is the correct way for asking for help now. thank you

Edited by IIIRAZORIII
Link to comment
Share on other sites

i'm just curious, why the lack of help for newcomers, every thread i read they are blasted for asking for help with simple things.

i understand there is a helpfile, but it doesn't include everything and i'm sure all the pro's had similar questions when they started out.

anyways if there is something i'm doing wrong, please let me know. just seems like myself and other people new to coding are being stone walled with every question.

Link to comment
Share on other sites

Just your impatience... You are like having a yappy Chihuahua at the foot of the forum.

_WaitForImageSearch($findImage,$waitSecs,$resultPosition,ByRef $x, ByRef $y,$tolerance,$HBMP=0)

try this... (60 second search)

Global $iX, $iY
$search = _WaitForImageSearch("C:\Users\IIIRAZORIII\Desktop\image.bmp", 60, 1, $iX, $iY, 0)
If $search = 1 Then MouseMove($iX, $iY)

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Link to comment
Share on other sites

Sorry you may be right, just feel like jumping through hoops sometimes. been trying to work this out for last 3 days via google threads youtube vids etc etc,this thread was the last port of call.

anyways, i got this error

: ==> Subscript used with non-Array variable.:

if $result[0]="0" then return 0

if $result^ ERROR

also got the same when changing

$search

to

$result

there is more than one image on my desktop visable as its the autoit icon i'm using for testing. i also increased the tolerance to 16 with no avail.

tryed this also same error though

$search = _WaitForImageSearch("C:\Users\IIIRAZORIII\Desktop\image.bmp", 60, 1, $iX, $iY, 30)
If IsArray($search) = 1 Then MouseMove($iX, $iY)
Edited by IIIRAZORIII
Link to comment
Share on other sites

The array and subscript means that the variable wasn't an array at the time of the check.

This usually happens when a function that returns an array doesn't return an array in a given instance.

Use isarray($arrayName) to test if the variable is an array before testing the indexs.

example: (in this example $arrayName[0] will not be evaluated if $arrayName is not an array)

if isarray($arrayName) then
$arrayName[0]+= 1
endif

I didn't learn to program over night, this forum didn't even exist yet.

or the internet as it is today for that matter.

Take your time, keep moving, backup your work.

This forum can help you, but not if you piss people off.

Best of luck,

X and Y

Edited by Xandy
Link to comment
Share on other sites

  • Moderators

IIIRAZORIII,

i'm just curious, why the lack of help for newcomers, every thread i read they are blasted for asking for help with simple things.

i understand there is a helpfile, but it doesn't include everything and i'm sure all the pro's had similar questions when they started out.

Someone asks this question about once a month - and I always give the same answer:

I do not believe there is a lack of help for newcomers - in fact several of us make a special effort to respond to new members - but there is a lack of willingness among the more experienced coders here to help those who appear to make no effort to help themselves. This attitude usually manifests itself in asking for example code without the OP having made any effort to produce something - or by asking questions which could be very simply answered by a little study of the Help file. As has been pointed out previously, our philosophy is "teach to fish" rather than merely acting as fishmongers. ;)

In this case you are asking for help on a specific function within a UDF from the Examples section. How many people here do you think use that particular UDF? I certainly never have. In fact, why did you not post this question in the UDF thread itself? That way the author would certainly see it - and who better to help you? :whistle:

So I am not at all surprised that you got little assistance at the start - but please note that you are now being helped. Do not take any of this personally - we are very willing to offer help on specific problems that you encounter, but are not really into giving tutorials on the basics. There are several tutorials in the Wiki to do that. ;)

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