Jump to content
Sign in to follow this  
civictyper30

Subscript used with non-Array variable

Recommended Posts

civictyper30

Hi, i'm getting a funny error with this following code and I think it's a bug or the variable is being wiped after use, BUT the funny thing is the actions actually work. What i'm trying to do is refresh a website that auto times out after 30 minutes. It works, but throws the error

Line 32 (File...)

MouseClick("left",$flink[0],$flink[1],1,0)

MouseClick("left",$flink^ ERROR

Error: Subscript used with non-Array variable.

The code i wrote is below:

#include <_EnumChildWindows.au3>
#include <Array.au3>
#include <IE.au3>
Local $aPL = ProcessList("iexplore.exe")
Local $aWL = WinList()
Local $handle
Opt("MouseCoordMode",2)
Opt("PixelCoordMode",2)
$ProcessName = "iexplore.exe"
If ProcessExists($ProcessName) Then
For $i = 1 To UBound($aPL) - 1
    For $p = 1 To UBound($aWL) - 1
        If WinGetProcess($aWL[$p][1]) = $aPL[$i][1] Then
   If $aWL[$p][0] == "Nimsoft Service Desk - Windows Internet Explorer" Then
    $handle = $aWL[$p][1]
    WinActivate($handle)
    ;$ClientPos = WinGetPos($handle)
    ;_ArrayDisplay($ClientPos)
    ;$ControlPos = ControlGetPos("Nimsoft Service Desk - Windows Internet Explorer","","Internet Explorer_Server1")
    ;_ArrayDisplay($ControlPos)
    ;MouseMove($ControlPos[0],$ControlPos[1],0)
    $flink = PixelSearch(10,118,30,300,0xFF894A,0,1,$handle)
    ;MsgBox(0,"Test","Test")
    ;_ArrayDisplay($array)
    ;MouseMove($array[0],$array[1],0)
    MouseClick("left",$flink[0],$flink[1],1,0)
    MouseClick("left",$flink[0]+5,$flink[1]+15,1,0)
    ;_IELinkClickByText($handle,"Home")
    ;_IELinkClickByText($handle,"List Tickets")
   EndIf
        EndIf
    Next
Next
;Local $aPL = ProcessList("iexplore.exe")
;For $i = 1 To UBound($aPL) - 1
;WinActivate(
;Next
;MsgBox(0,"Test","Test")
; MsgBox(0,"Running",$ProcessName & " is running.")
;WinActivate("Nimsoft Service Desk", "Nimsoft Service Desk")
;$hWnd=WinGetHandle($aPL[$i][1])
;$aEnumList=_EnumChildWindows($hWnd,0,0,'TabWindowClass')
;_ArrayDisplay($aEnumList,"IE Tabs")
 
;_ArrayDisplay($aPL);un-comment _ArrayDisplay to see process list array
;_ArrayDisplay($aWL);un-comment _ArrayDisplay to see process list array
;WinClose("[CLASS:IEFrame]")
;if WinExists("Internet Explorer", "Do you want to close all tabs or the") Then
; WinActivate("Internet Explorer", "Do you want to close all tabs or the")
; Send("{ENTER}")
;EndIf
EndIf

I cant see why it actually moves the mouse and works but still throws an error. I'm running AutoIt 3 and just d/l the app 2 days ago on a Windows 7 Enterprise x86 system. Any help on this would be appreciated as this error is perplexing me greatly.

Thanks!

Share this post


Link to post
Share on other sites
civictyper30

BTW this script is still not finished so I know there's no sleep in place and what not. I'm just going for the functionality piece right now.

Share this post


Link to post
Share on other sites
BrewManNH

I'm guessing that this line $flink = PixelSearch(10,118,30,300,0xFF894A,0,1,$handle) is where your problem is. You're getting the error because you're not doing any error checking after this line to see if it actually finds the pixel. If it doesn't find the color, it's not going to return an array, so you'll get the error.


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
civictyper30

Well i understand that, but at this time if i do the _ArrayDisplay everything is correclty displayed. The pixel is found. I even renamed the variable from $array to $flink thinking that the naming might be an issue. The array is full and not null, it works, but throws the error.

Adding to this... If i do turn on the _ArrayDisplay (uncomment) i don't get the error, is there possibly a timing issue from PixelSearch then to MouseClick by chance? Anyone ever run into this bug? I'm thinking this would be the case because the Array Display pops up, then i close the window and then the script continues... let me put in a sleep and see what happens.

Edited by civictyper30

Share this post


Link to post
Share on other sites
BrewManNH

Try using this and see what happens, either you'll find the pixel, or you're going to get a Messagebox telling you that it wasn't found.

$flink = PixelSearch(10, 118, 30, 300, 0xFF894A, 0, 1, $handle)
If Not IsArray($flink) Then
    MouseClick("left", $flink[0], $flink[1], 1, 0)
    MouseClick("left", $flink[0] + 5, $flink[1] + 15, 1, 0)
Else
    MsgBox(64, "", "Pixel not found")
EndIf

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
civictyper30

Looks like I was right, the script continues before the PixelSearch is completed. How do I go about submitting a bug report?

Ok... i'm totally confused now. It's working without any issues, without sleep or the _ArrayDisplay. *sigh* thanks for the help!

@Brew Yes I will add that in for error and when I clean up the code. Thank you!

Edited by civictyper30

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
Sign in to follow this  

×