Jump to content

Recommended Posts

Posted

Hi Everyone,

I searched on the forum for this error and found about 3 other members having it but I dont know what is causing it in my case.

The error Im getting is "Subscript used with non-Array variable"

The strange thing is that the script can run for hours (2 or 3) and block the popups ok, but when it has ran for some time it throws that error and I cant see why.

Thanks in advance

Opt("TrayIconHide", 1)

While 1
    KillPopUps()
WEnd

Func IsWindowVisible($handle)
    If BitAnd( WinGetState($handle), 2 ) Then 
        Return 1
    Else
        Return 0
    EndIf
EndFunc

Func Manager()

$WindowsList = WinList()

    For $i = 1 to $WindowsList[0][0]
        $windowsize = WinGetClientSize($WindowsList[$i][1])
        $windowpos = WinGetPos($WindowsList[$i][1])
        
        If $var[$i][0] = "" Then        
                
                If $windowsize[0] = 555 And $windowsize[1] = 234 And IsWindowVisible($WindowsList[$i][1]) Then
                    WinActivate($WindowsList[$i][1])
                    MouseClick("left", 125+$windowpos[0], 240+$windowpos[1], 1, 0)
                EndIf
                
            EndIf
            
        Next
        
    
    Sleep(1000)
EndFunc

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\End User\Desktop\popupblocker.au3"

C:\Documents and Settings\Emilio\Desktop\popupblocker.au3 (33) : ==> Subscript used with non-Array variable.:

If $windowsize[0] = 555 And $windowsize[1] = 234 And IsWindowVisible($WindowsList[$i][1]) Then

If $windowsize^ ERROR

>Exit code: 1 Time: 17169.448

  • Moderators
Posted

dotnetfreak,

It looks as if the WinGetClientSize call is failing - and so you do not have an array as a return.

Simple solution - use IsArray to check that you do have a valid array before proceeding.

Longer term solution - find out why you have a window returned from WinList that then fails with WinGetClientSize . One thing that springs to mind - cancelling a pop-up which takes other windows with it so that a window in the list no longer exists when you come to check it. Perhaps a check with WinExists before trying WinGetClientSize is also necessary?

I know it seems like a lot of error-checking, but that is what you need at times... ;-)

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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...