Jump to content

Recommended Posts

Why is it giving me and error when i do the ImageSearch, The bmp is in the same location as the Script so why is it doing this?

 

Error Below

$result = _ImageSearch('gift.bmp',1,$x,$y,100)
$result = _ImageSearch('gift.bmp',1,^ ERROR

Script Below 

#include <ImageSearch.au3>


HotKeySet("{ENTER}","start")





While 1
   Sleep(1)
   WEnd





Func start()
   While 1
     $result = _ImageSearch('gift.bmp',1,$x,$y,100)
      If $result = 1 Then
         MouseClick("Left",$x,$y,1,10)
      EndIf

   WEnd
EndFunc

 

 

Edited by Melba23
Added tags

Share this post


Link to post
Share on other sites

$x and $y aren't declared.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

What error are you getting?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

That's the entire error message?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

That's the entire error message?

Sorry 

 

"C:\Users\Owner\Desktop\Autoit Stuff\Ourworld\BMP\nestin.au3" (17) : ==> Variable used without being declared.:
$result = _ImageSearch("gift.bmp",1,$x,$y,100)
$result = _ImageSearch("gift.bmp",1,^ ERROR
>Exit code: 1    Time: 2.769

 

Share this post


Link to post
Share on other sites

So what about showing the script that gets the error with the lines defining $x and $y  as you clearly have done something wrong? ;)

Jos

 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

This is the whole Script : 

#include <ImageSearch.au3>

HotKeySet("{ENTER}","start")




While 1
   Sleep(1)
   WEnd



$x = 0
$y = 0

Func start()
  While 1
      WinActivate("ourWorld")
     $result = _ImageSearch("gift.BMP",1,$x,$y,100)
      If $result = 1 Then
         MouseClick("Left",$x,$y,1,10)
      EndIf

   WEnd
EndFunc

 

Edited by Melba23
Removed quote and added tags

Share this post


Link to post
Share on other sites

So did you try to understand how your script is running and what would be a logical location to put those 2 lines?
Actually the whole script doesn't make any sense looking at the logic.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jos, Why don't you help me understand instead of always trying to be a smart ass?

Edited by Melba23
Removed quote

Share this post


Link to post
Share on other sites

Obviously i don't understand so why ask me... That is kinda why i'm here FOR HELP! Come'on Jos use your brain.

Edited by Melba23
Removed quote

Share this post


Link to post
Share on other sites

Scripts are ran from top to bottom, unless there's a function call in between.

In your script, starting from the top, it goes like this.

; step 1 add the contents of the ImageSearch UDF and execute anything that's not contained inside a function
#include <ImageSearch.au3>
; step 2 Set the hotkey
HotKeySet("{ENTER}", "start")


; Step 3 Start the While loop
While 1
; Step 4 Sleep for 10ms (the minimum amount you can sleep for)
    Sleep(1)
; Step 5 Go back to the top of the While loop (Step 3)
WEnd
; Step 6 There is no step 6 because you're stuck inside the While loop
$x = 0
$y = 0
; Function called by the HotKey
Func start()
    ; Step 1 Start the While loop
    While 1
        ; Step 2 Wait for the windows titled "ourWorld" to be the active window - You may never leave this step if the window never becomes active
        WinActivate("ourWorld")
        ; Step 3 Search for the image "gift.bmp" and assign the return to $result
        $result = _ImageSearch("gift.BMP", 1, $x, $y, 100)
        ; Step 4 Check to see if $result is -1
        If $result = 1 Then
            ; Step 5 If $result = -1 then click the left mouse button at $x and $y
            MouseClick("Left", $x, $y, 1, 10)
        EndIf
        ; step 6 Go back to step 1 forever.
    WEnd
EndFunc   ;==>start

2 errors in your script, maybe 3, First $x and $y aren't declared because they're after the first While loop, Second you have no way to get out of the function call because it's running another endless loop there. 3rd optionally, you don't put a timeout on the WinWaitActive so it could be sitting there forever before the imagesearch ever runs. A 4th optional error is that you have no way of stopping the script from running for as long as the computer is on.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thank you for actually taking to time to explain! I think i got it now

Edited by Melba23
Removed quote

Share this post


Link to post
Share on other sites

The error im getting now is 

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





; step 1 add the contents of the ImageSearch UDF and execute anything that's not contained inside a function
#include <ImageSearch.au3>
; step 2 Set the hotkey
HotKeySet("{ENTER}", "start")


; Step 3 Start the While loop

; Step 6 There is no step 6 because you're stuck inside the While loop

          $x = 0
         $y = 0

While 1
   Sleep(1)
   WEnd

; Function called by the HotKey

Func start()
    ; Step 1 Start the While loop
    While 1
        ; Step 2 Wait for the windows titled "ourWorld" to be the active window - You may never leave this step if the window never becomes active
        WinActivate("ourWorld")

        ; Step 3 Search for the image "gift.bmp" and assign the return to $result
        $result = _ImageSearch("gift.BMP", 1, $x, $y, 100)
        ; Step 4 Check to see if $result is -1
        If $result = 1 Then
            ; Step 5 If $result = -1 then click the left mouse button at $x and $y
            MouseClick("Left", $x, $y, 1, 10)
        EndIf

        ; step 6 Go back to step 1 forever.
    WEnd

EndFunc   ;==>start

 

Edited by Melba23
Removed quote and added tags

Share this post


Link to post
Share on other sites

Reptos,

When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see in the other posts.

And when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - we know what we wrote and it just pads the thread unnecessarily.

Thanks for your 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

 

Share this post


Link to post
Share on other sites

Please use code tags when posting code, it looks like "<>" in the tool bar of the reply screen.

Also, don't quote what I posted, I know what I wrote and it's harder to follow the thread with unnecessary quoting.

 

That error you posted looks like it's coming from the UDF and not your script. Try adding a local declaration in front of your $result variable, as you may be overwriting an array inside the UDF because you don't declare your variables properly.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Obviously i don't understand so why ask me... That is kinda why i'm here FOR HELP! Come'on Jos use your brain.

I am sorry, but you have been in this mode since the day to signed up 10 days ago, and are not showing any initiative to understand what you are doing and seems to keep on asking the same thing.

Start reading and learning and you will get help. ;)

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I am sorry, but you have been in this mode since the day to signed up 10 days ago, and are not showing any initiative to understand what you are doing and seems to keep on asking the same thing.

Start reading and learning and you will get help. ;)

Jos

Jos you're those type of people that think they are Mr know it all. I came here to get help. I'm new at all of this literally. You stated " are are not showing any initiative " please choose your words wisely because that did not make any since. Maybe you need to "Start Reading" and learn how to type correctly. Now my intention was not to come here and argue it was simply to come and learn things that i did not know. Some people have certain learning deference's, you may learn quicker than i do that is why i keep asking for help maybe on the same topic. I'm done arguing with you for now have a great day!

Share this post


Link to post
Share on other sites

Good to see you are taking the time to read and properly articulate your sentences. As to the content of it:  It is clear you do not know what you are saying but will not hold it against you. ;)

Good luck with your scripting endeavors.

Jos    

 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Similar Content

    • By SolemnStrike
      Hey, 
      I know the title sounds weird, but i couldn't find better words for it...
      I finally managed to have a working image search (yes yes i know image search is evil :p).
      I noticed that even if the script is compiled, the images have to be in my script folder.
      But i don't want that the images i'm searching for on the screen can be viewed, edited etc by every user.
      Is there a way to... uhm... put them in a file like .rar, but one that can't be easily opened? 🤔
       
      Edit: Now that i think of .rar, maybe using a .rar which is protected by a password... Can autoit search, open, extract, use and delete that? (I guess so, I didn't search for this yet, going to google that asap)
    • By lenclstr746
      Hi guys,
      Some functions of my script are running slowly. Very slow. What is the reason?
      My Code:
      <snip>
    • By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • By Ian_Mac
      Func dg_get_images() $x1=0 $y1=0 ;MsgBox(0,"start","start") do $result = _ImageSearch("C:\Users\Server\Desktop\my project\image.png",1,$x1,$y1,0) until $result = 1; if $result=1 Then MouseMove($x1,$y1,3) MouseClick("left", $x1,$y1, 1) WinWait("[Title:TightVNC File Transfer]", "", 10) EndIf  this code works when i search the image, but when i change the location of the desktop icon it can't find the desktop icon anymore.   i wanna try image search area. but i don't know how to use it because i cant understand the parameter for the image search area.  please help me how to solve it thank you in advance.
    • By knuxfighter
      Hello. I've been working with Imagesearch library lately and it did a good work, although I moved to a new PC and didn't copy the old files with me so I downloaded the Imagesearch from the following post
       hoping that it will work. It doesn't though. First time I when I use (run as subscript to my code) the Imagesearch.au3, Scite finds errors (missing spaces). Ctrl+T (scite tidy) fixes these missing spaces but the script returns the following error on every run after:
      _ImageSearch('search.bmp', 0, $x, $y, 0) outputs
       
      "C:\Users\Knuckles\Desktop\AutoIt\include\ImageSearch.au3" (44) : ==> Subscript used on non-accessible variable.: If $result[0] = "0" Then Return 0 If $result^ ERROR no matter if I put the searched bmp in the script folder or folder img in the script directory. Also, it doesn't matter if the searched image on screen or not, it returns the same.

      Can you provide me any help please? I remember having these problems 2 years ago when I first met the imagesearch library also (I fixed it somehow though in that time). Seems nothing changed.

      Using this version posted in the following post gives the same error:
      Also I run windows 10 64bit and I have no shell options for script editing, running as x86 or whatever as I used to have on windows xp/7. I went through some steps like deleting a key in registry and I even reinstalled autoit and scite but that only resulted to au3 as unrecognized file format and not in getting back the menus and the icon on au3 files. Any thoughts on this?

      Edit: Installing 64-bit AutoIt and using 64bit ImageSearch is no change.
      code.au3

      FOUND WORKING: http://www.codebot.de/index.php/Thread/12713-Imagesearch-au3-funktioniert-nicht/
       but why is this one working and the original aren't? :(
×
×
  • Create New...