Jump to content

Can't seem to figure out where the error is


Recommended Posts

Hello autoit form, I'm looking to make a basic image search script that'll keep looping until i stop it myself. 

I keep getting error at line 36 which doesn't make any sense to me. Keeps telling me Variable used without being declared...But I've declared it.

Any help would be appreciate it 

 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.2
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here


#include <ImageSearch.au3>

HotKeySet("{END}", "End")
HotKeySet("{F1}", "Prison")

While 1
    Sleep(1)
WEnd



$x = 0
$y = 0
$x1 = 0
$y1 = 0
$x2 = 0
$y2 = 0

 Func Prison()

        $prison = _ImageSearch("Search.bmp",0,$x,$y,0)
        $prison1 = _ImageSearch("Recycle.bmp",0,$x1,$y1,0)
        $prison2 = _ImageSearch("Play.bmp",0,$x2,$y2,0)

 If $prison = 1 Then
             MouseClick("left", $x, $y,1,10)
             sleep(2000)
             ElseIf $prison1 = 1 Then
             MouseClick("left", $x1, $y1,1,10)
              sleep(2000)
                ElseIf $prison2 = 1 Then
             MouseClick("left", $x2, $y2,1,10)
               sleep(2000)
                 EndIf
    EndFunc

           While 1
    sleep(100)
Wend

Func End()
    Exit
EndFunc

 

Edited by User751139
Link to comment
Share on other sites

  • Developers

You just repeated what you said in the original post, so you either think I didn't read it or ....  (Lets not go there..) ;)

Assume you are running your script from SciTE so show me the the output from the SciTE output pane so I can see what is happening.

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

Looks like it's a google chrome problem anyways,

 

I'm not sire what you are asking Jos. I put it in the simplest term as possible. My code is above when I try to execute the script by clicking the hoykey "F1" in this case I get the error ms gpop up as below:

 

popup.jpg

Im not using SciTe

 

Edited by User751139
Link to comment
Share on other sites

  • Developers

Ok,

Reason is simple as the code portion you declare the variables is never reached. Move it above your While-Wend loop.

Also ensure you read our forum rules as this all looks again very Game automation related!

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

actually this is for SCCM advertisement when i'm deplying an image i'm trying to automate the task so i don't have to click a million times. Thanks

 

I've followed your advise, but it seems to only look for the first image, and then it just stops. Doesn't bother going over to the next 3 images

Edited by User751139
Link to comment
Share on other sites

  • Developers

Come on... I hope you are not automating SCCM deployments with an ImageSearch logic.

Also your Func name would indicated otherwise... but it's good you are on your way and can now start the debugging process.

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

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