computergroove Posted September 20, 2014 Share Posted September 20, 2014 Global $Number = 4 Global $IPAddress1 = "192.168.1.37" Global $IPAddress2 = "192.168.1.40" Global $IPAddress3 = "192.168.1.41" Global $IPAddress4 = "192.168.1.47" Global $IPArray[$Number + 1] = [ $Number, $IPAddress1, $IPAddress2, $IPAddress3, $IPAddress4 ] Global $Timer = TimerInit() While 1 If $TimerD >= 1800000 Then;30 minutes restart vnc CloseVNC() Sleep(1000) StartVNC() Sleep(1000) $Timer = TimerInit() EndIf WEnd Func StartVNC() Local $VNCXPos1 = 77;XPosition of Opened VNC Window For $i = 1 To $Number Run(@ProgramFilesDir & "\RealVnc\VNC Viewer\vncviewer.exe") WinWait("VNC Viewer") Send($IPArray[$i]);<----- Here is where I'm getting an error Sleep(50) Send("{ENTER}") Sleep(1000) Send("Password" & "{ENTER}") Sleep(200) MouseClickDrag("Left", 715, 345, $VNCXPos1, 11, 10) $VNCXPos1 += 320 Next EndFunc I have a loop where I run 4 vnc windows and when I start the script it works fine but it appears that when it attempts to startVNC() after 30 minutes I get an error on the Send($IPArray[$i]) The console outputs this: "C:\Documents and Settings\user\Desktop\Test.au3" (243) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $IPTemp1 = $IPArray[$i] $IPTemp1 = ^ ERROR and the script crashes. What am I missing? Using message box to see the value of $IPArray[$i] only shows the 4 ip addresses with no issues. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2014 Share Posted September 20, 2014 Show CloseVNC() func. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 computergroove, Here is where you are getting the error "$IPTemp1 = $IPArray[$i]". Show all functions as J1 suggests. Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
computergroove Posted September 20, 2014 Author Share Posted September 20, 2014 Func CloseVNC() For $g = 1 To $Number; Close all instances of VNC Viewer at start of script ProcessClose("vncviewer.exe") Sleep(500) Next EndFunc ;==>CloseVNC @Kylomas I tried to set $IPArray[$i] to a variable then call the variable and I got the same message. Forgot to modify the output. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
kylomas Posted September 20, 2014 Share Posted September 20, 2014 (edited) Still don't see this "$IPTemp1 = $IPArray[$i]"... edit: clarification Edited September 20, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
computergroove Posted September 20, 2014 Author Share Posted September 20, 2014 "C:Documents and SettingsuserDesktoptest.au3" (245) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Send($IPArray[$i]) Send(^ ERROR Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Gianni Posted September 20, 2014 Share Posted September 20, 2014 (edited) change this For $i = 1 To $Number with this For $i = 1 To $Number -1 edit: forghet it, sorry Edited September 20, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
mikell Posted September 20, 2014 Share Posted September 20, 2014 Did you post the whole code ? sending to Notepad with the same code produces no error Global $Number = 4 Global $IPAddress1 = "192.168.1.37" Global $IPAddress2 = "192.168.1.40" Global $IPAddress3 = "192.168.1.41" Global $IPAddress4 = "192.168.1.47" Global $IPArray[$Number + 1] = [ $Number, $IPAddress1, $IPAddress2, $IPAddress3, $IPAddress4 ] Global $Timer = TimerInit() Sleep(3000) ; delay to activate a blank notepad While 1 If TimerDiff($Timer) >= 2000 Then StartVNC() Sleep(1000) $Timer = TimerInit() EndIf WEnd Func StartVNC() For $i = 1 To $Number Send($IPArray[$i]) Sleep(50) Next EndFunc Link to comment Share on other sites More sharing options...
JohnOne Posted September 20, 2014 Share Posted September 20, 2014 My guess is that the global array is either being redimmed or it's type is being changed elsewhere in the code. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
computergroove Posted September 21, 2014 Author Share Posted September 21, 2014 It isn't being changed in the script but I am not sure about redimmed. I only define the array in the beginning of the script. It is called to open vnc only. I added a timerinit and timerdiff to automatically restart the vnc windows after 30 minutes and that's when it started happening. It works correctly the first time and when it restarts vnc after 30 minutes the first time thats when it fails. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
kylomas Posted September 21, 2014 Share Posted September 21, 2014 (edited) Ditto mikell. Here is your code changed to use Notepad instead of vnc... expandcollapse popupGlobal $Number = 4 Global $IPAddress1 = "192.168.1.37" Global $IPAddress2 = "192.168.1.40" Global $IPAddress3 = "192.168.1.41" Global $IPAddress4 = "192.168.1.47" Global $IPArray[$Number + 1] = [ $Number, $IPAddress1, $IPAddress2, $IPAddress3, $IPAddress4 ] Global $Timer = TimerInit() local $cycle_time = 1000 * 10 ConsoleWrite($cycle_time & @CRLF) While 1 If timerdiff($Timer) >= $cycle_time Then ; <---- use timerdiff() to get milleseconds since last timerinit() CloseVNC() Sleep(1000) StartVNC() Sleep(1000) $Timer = TimerInit() EndIf WEnd Func StartVNC() Local $VNCXPos1 = 77;XPosition of Opened VNC Window For $i = 1 To $Number Run("notepad.exe") WinWait("Untitled - Notepad") send($IPArray[$i]) ;<----- Here is where I'm getting an error Sleep(50) Send("{ENTER}") Sleep(1000) Send("Password" & "{ENTER}") Sleep(200) MouseClickDrag("Left", 715, 345, $VNCXPos1, 11, 10) $VNCXPos1 += 320 Next EndFunc Func CloseVNC() For $g = 1 To $Number; Close all instances of VNC Viewer at start of script ProcessClose("notepad.exe") Sleep(500) Next EndFunc ;==>CloseVNC kylomas edit: duration changed to re-cycle every 10 seconds Edited September 21, 2014 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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