Jump to content

Array variable subscript dimension exceeded


 Share

Recommended Posts

Hi all,

im new but i have been scripting and reading for some time now.

At the moment im trying to do some motion detection and shape recognition for fun and exercise.

I have an area of 1024 by 769 pixels which i want to read into an array and do some stuff from there.

Here is my script:

HotKeySet("{PGDn}","_Exit")
HotKeySet("{ins}","Search")
Dim $Bild1[1025][769]
Dim $Bild2[1025][769]
$height = 1024
$width = 769
$diff = 0
$x = 0
$x = 0
$x1 = 0
$y1 = 0
$counter = 0
$click = 0

Func Search()
;Bild einlesen


    While 1
        For $x = 0 To $height Step +50
            ;ConsoleWrite ($counter & @CRLF)
            For $y = 0 To $width Step +50
            $Bild1[$x][$y] = PixelGetColor($x, $y)
            ;ConsoleWrite ($Bild1[$x][$y] &" " &$x &" " &$y& " " & @CRLF)
            Next
        Next
        For $i = 0 to 5000 Step +1
            $x = 0
            $x = 0
            ;ConsoleWrite ($counter & @CRLF)
            ;Bild2 einlesen
            For $x = 0 To $height Step +50
                For $y = 0 To $width Step +50
                    $Bild2[$x][$y] = PixelGetColor($x, $y)
                    If $Bild2[$x][$y] <> $Bild1[$x][$y] Then
                        $x = $x1
                        $y = $y1
                        $diff = $diff + 1
                    EndIf
                Next
            Next

            If $diff > 0 and $diff < 5 Then
               ConsoleWrite ("found" & $diff & @CRLF)
                MouseClick("left",$x1, $y1, 2, 0)
                ConsoleWrite ("found" & $diff & @CRLF)
                Sleep(100)
            EndIf
            $diff = 0
            $counter = $counter + 1
            ConsoleWrite ($counter & @CRLF)

        Next
        if $click = 0 Then
            MouseClick("left", 810,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 1 Then
            MouseClick("left", 710,230,1,0)
            Sleep(1750)
        EndIf
        ;if $click = 2 Then
        ;   MouseClick("left", 630,230,1)
        ;EndIf
        if $click = 3 Then
            MouseClick("left", 550,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 4 Then
            MouseClick("left", 460,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 5 Then
            MouseClick("left", 350,230,1,0)
            Sleep(1750)
        EndIf
        ;if $click = 6 Then
        ;   MouseClick("left", 350,230,1)
        ;EndIf
        if $click = 7 Then
            MouseClick("left", 270,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 8 Then
            MouseClick("left", 210,230,1,0)
            Sleep(1750)
            $click = 0
        EndIf
        $click = $click + 1
    WEnd
EndFunc

While 1
    sleep(500)
Wend

Func _Exit()
    Exit
EndFunc

But it always gets stuck without any error messeages.

What am i doing wrong?

Edited by B4ckBOne
Link to comment
Share on other sites

So i have continued to work on my script and i ran in to something i cant overcome :-/

It gets stuck without telling me why.

So here is what it does:

It writes the pixel color of every 50th vertical and horizontal pixel on a 1024x769 screen.

Thus creating an arry of pixelcolors all over the screen.

Then it compares the Array to a new array at a later time and checks if there has been changes.

If changes detected it clicks on the x and y position the change has been detected.

And then it does some clicks from time to time which work...

Here is what it does not:

it does not click and gets stuck and stops running the while loop.

Now i cant determine where exactly it gets stuck and why.

How you can help if you want to:

Tell me why and where it stops.

HotKeySet("{PGDn}","_Exit")
HotKeySet("{ins}","Search")
Dim $Bild1[1025][769]
Dim $Bild2[1025][769]
$height = 1024
$width = 769
$diff = 0
$x = 0
$x = 0
$x1 = 0
$y1 = 0
$counter = 0
$click = 0

Func Search()
;Bild einlesen


    While 1
        For $x = 0 To $height Step +50
            ;ConsoleWrite ($counter & @CRLF)
            For $y = 0 To $width Step +50
            $Bild1[$x][$y] = PixelGetColor($x, $y)
            ;ConsoleWrite ($Bild1[$x][$y] &" " &$x &" " &$y& " " & @CRLF)
            Next
        Next
        For $i = 0 to 5000 Step +1
            $x = 0
            $x = 0
            ;ConsoleWrite ($counter & @CRLF)
            ;Bild2 einlesen
            For $x = 0 To $height Step +50
                For $y = 0 To $width Step +50
                    $Bild2[$x][$y] = PixelGetColor($x, $y)
                    If $Bild2[$x][$y] <> $Bild1[$x][$y] Then
                        $x = $x1
                        $y = $y1
                        $diff = $diff + 1
                    EndIf
                Next
            Next

            If $diff > 0 and $diff < 5 Then
               ConsoleWrite ("found" & $diff & @CRLF)
                MouseClick("left",$x1, $y1, 2, 0)
                ConsoleWrite ("found" & $diff & @CRLF)
                Sleep(100)
            EndIf
            $diff = 0
            $counter = $counter + 1
            ConsoleWrite ($counter & @CRLF)

        Next
        if $click = 0 Then
            MouseClick("left", 810,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 1 Then
            MouseClick("left", 710,230,1,0)
            Sleep(1750)
        EndIf
        ;if $click = 2 Then
        ;   MouseClick("left", 630,230,1)
        ;EndIf
        if $click = 3 Then
            MouseClick("left", 550,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 4 Then
            MouseClick("left", 460,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 5 Then
            MouseClick("left", 350,230,1,0)
            Sleep(1750)
        EndIf
        ;if $click = 6 Then
        ;   MouseClick("left", 350,230,1)
        ;EndIf
        if $click = 7 Then
            MouseClick("left", 270,230,1,0)
            Sleep(1750)
        EndIf
        if $click = 8 Then
            MouseClick("left", 210,230,1,0)
            Sleep(1750)
            $click = 0
        EndIf
        $click = $click + 1
    WEnd
EndFunc

While 1
    sleep(500)
Wend

Func _Exit()
    Exit
EndFunc
Edited by B4ckBOne
Link to comment
Share on other sites

What is this script ran against? (name of the application please)  I ask for pixel searching is horrible in most cases to solve a problem. Usually there is a better way than pixel searching.

I see you are German so I'm putting the same thing in German as well
 

Was ist das Skript lief gegen ? ( Name der Anwendung, bitte ) Ich bitte um Pixelsuch ist schrecklich in den meisten Fällen , um ein Problem zu lösen . In der Regel gibt es einen besseren Weg, als Pixelsuch .

Link to comment
Share on other sites

The script is runing against a static website that has a floating object apearing randomly and moving around in a random pattern.

Therefore i have come up with this "Minefield" of pixelsearch points that when a point is triggered should be clicked.

But at the moment the script just stops working from time to time without an error.

Maybe the clicking does not work or the reserved memory is full etc..

But it does not spit out any errors.

Thats why i put in the console write, to see the cycles and weathor or not it wants to trigger a click event before it stops.

If the cycle number is not increasing anymore i can detect that the script got stuck.

But it never triggered the click event, even when it should.

Which confuses me very much.

Any help would be appreciated.

Link to comment
Share on other sites

For $i = 0 to 5000 Step +1<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Why 5000?
            $x = 0<<<<<<<<<<<<<<<<< reset once
            $x = 0<<<<<<<<<<<<<<<<<< reset twice?
            ;ConsoleWrite ($counter & @CRLF)
            ;Bild2 einlesen
            For $x = 0 To $height Step +50
                For $y = 0 To $width Step +50
                    $Bild2[$x][$y] = PixelGetColor($x, $y)
                    If $Bild2[$x][$y] <> $Bild1[$x][$y] Then
                        $x = $x1<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< You keep resetting $x to zero... Thus it will never finish
                        $y = $y1<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                        $diff = $diff + 1
                    EndIf
                Next
            Next
 
---------------------------------------------------------------------
 
Also  Why set the same variable to zero twice???
 
 
$height = 1024
$width = 769
$diff = 0
$x = 0<<<<<<<<<<<<<<<<<<
$x = 0<<<<<<<<<<<<<<<<<<
 
----------------------------------------------------
 
I cant test the code... Sorry
 
8)
Edited by Valuater

NEWHeader1.png

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