Jump to content

Can someone help me with dimming arrays


Recommended Posts

As you can see by this script so far, it is searching for a pixil, then it's clicking it. But when running this I get this message. "subscript used with a non-array variable"

So I played around a bit and found I had to dim the array? I read up on dimming arrays and variables, it went completely over my head. So if anyone could explain and or help in any way, that would be great. :(

This is as far as I got because of the trouble, not much so far, but hoping someone can help me out so I can finish this.

HotKeySet("^!q", "MyExit")




While 1;

$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
    mouseclick ("left", $coord[0], $coord[1], 1, 10)
    



Wend

Func MyExit()

Exit 
    
EndFunc
Link to comment
Share on other sites

Firstly, you are clicking at the coords whether you find the colour or not. $Coord[0] and $Coord[1] will only exist if the colour is found, which its not. To check if the PixelSearch was successful use @error like so.

HotKeySet("^!q", "MyExit")

While 1
   $Coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
   If Not @error Then
      MouseClick ("Left", $Coord[0], $Coord[1], 1, 10)
   Else
      MsgBox(4096,"Error!","The colour wasn't found!")
   EndIf 
Wend

Func MyExit()
   Exit 
EndFunc

If there wasn't an error (colour was found) then it clicks. If the colour wasn't found you get the message box.

qq

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