darrenmoore Posted November 18, 2014 Posted November 18, 2014 Hello AutoIt Forum I'm new to autoit and I'm running into a error that I do not understand. The Error is "Subscript used on non-accessible variable. I have two occurrences of the same code one occurrence that doesn't throw an error and the other that does. Throws Error Snippet: Local $hWnd = WinWait("Intel® CCF Manager Setup", "", 10) Local $aClientSize = WinGetClientSize($hWnd) MouseClick("primary", $aClientSize[0] - 535, 50) <-- The error happens here Does Not Throw Error Snippet: Local $hWnd = WinWait("Thug Caller Dashboard", "", 10) Local $aClientSize = WinGetClientSize($hWnd) MouseClick("primary", $aClientSize[0] - 160, 40) <-- This line does not throw an error. It is obvious that the two lines are very similar what am I missing? Any feedback would be greatly appreciated. Darren Moore
Moderators SmOke_N Posted November 18, 2014 Moderators Posted November 18, 2014 Local $hWnd = WinWait("Intel® CCF Manager Setup", "", 10) Local $aClientSize = WinGetClientSize($hWnd) If @error Or Not IsArray($aClientSize) Then MsgBox(16 + 262144, "Error", "OoOps!") Exit Else MouseClick("primary", Int($aClientSize[0]) - 535, 50) <-- The error happens here EndIf Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
jdelaney Posted November 18, 2014 Posted November 18, 2014 One additional error handle: Local $hWnd = WinWait("Intel® CCF Manager Setup", "", 10) If Not IsHWnd($hWnd) Then MsgBox(16 + 262144, "Error", "Window not present within 10 seconds") Exit 1 EndIf Local $aClientSize = WinGetClientSize($hWnd) If @error Or Not IsArray($aClientSize) Then MsgBox(16 + 262144, "Error", "OoOps!") Exit Else MouseClick("primary", Int($aClientSize[0]) - 535, 50) <-- The error happens here EndIf IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
darrenmoore Posted November 18, 2014 Author Posted November 18, 2014 Thank you for the snippets. Tried type casting approach and still getting the error.
Moderators SmOke_N Posted November 18, 2014 Moderators Posted November 18, 2014 (edited) Hopefully you removed the "<-- error" before running, but if you ran the code as is, you got the error at the array stage, you did not get the error at the mouseclick stage. Don't really care about the type casts, it's about ensuring that the array is an array at that point. Edit: Unless you're trying to use a variable within a function as an array without declaring it first? But your code doesn't suggest that, but then again, you just copied code out of the help file basically. How did you determine "where the error happens"? Where is that code? Edited November 18, 2014 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
darrenmoore Posted November 19, 2014 Author Posted November 19, 2014 Here's my entire file below. I was able to determine the error by when I run the file I get a error message that gives the error that I stated initially(Error: subscript used on non accessible variable) . And lets me know that yes the array is not an array. And that is why I posted the question as I am new to AutoIt. How do I make sure the array is actually an array? Any input you may have would be helpful. #RequireAdmin #include <MsgBoxConstants.au3> #include <Array.au3> ;set mouse coords to be relative to client area of the active window (default is relative to entire screen). AutoItSetOption("MouseCoordMode", 2) StartCD() InstallCD() Func StartCD() ; Run CallerDashboard ShellExecute(@DesktopDir & "CallerDashboard-installer") EndFunc Func InstallCD() ;Sleep(1500) SendKeepActive("Thug Caller Dashboard") WinWait("Thug Caller Dashboard", "", 10) MouseClick("primary", 340, 250, 1) ;this starts the installer Sleep(5000) ;waiting for CCF Manager wizard steps WinWait("Thug Design - CallerDashboard Setup", "", 30) Send("{Enter}") Local $hWnd = WinWait("Intel® CCF Manager Setup", "", 10) Local $aClientSize = WinGetClientSize($hWnd) ;$aClientSize = Width:600 Height:470 MouseClick("primary", $aClientSize[0] - 535, 50) EndFunc
BrewManNH Posted November 19, 2014 Posted November 19, 2014 You should check to see if the WinWait and WinGetClientSize return a valid handle and array before trying to access the array. 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 GudeHow 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now