ToyBoi Posted March 6, 2009 Share Posted March 6, 2009 Hello, for those who are tldr, is there a way for autoit to detect that the script hasn't done anything in , say 1 minute, and quit IE and restart it? (not the whole script, but a certain point in the loop where it got stuck.)I have this script which logs into about 50 servers individually and retrieves info.expandcollapse popupfor $a = 0 to 48 $oIE = _IECreate($IP[$a],0,1,0,1) sleep(2000) if WinActive("Connect to" ) then send ($username) sleep (500) send ("{Tab}") send ($password) sleep(500) Send("{enter}") sleep(2000) endif ;enters the username and password while WinActive("Connect to" ) sleep(400) send ($password) sleep(400) Send("{enter}") _IELoadWait ($oIE) wend _IENavigate($oIE, $IP[$a] & "/0/page15.htm") _IELoadWait ($oIE) Sleep(1000) $oTable = _IETableGetCollection ($oIE,1) $aTableData = _IETableWriteToArray ($oTable, True) WinActivate("[TITLE:Microsoft Excel]", "") _ExcelSheetActivate($oExcel, $ServerName[$a]) _ExcelWriteSheetFromArray($oExcel, $aTableData, 1, 1, 0, 0) sleep(300) _IEQuit ($oIE) sleep(2500) nextwhat happens is that for every server I start a new IE, and it will ask me for the user name and password pop upsometimes this log in pop up shows up once, and I will have to enter both the username and password. Sometimes it shows up a second time right after asking for the password only, again. then it authenticates me in and I can do my stuffThe problem is that after trying my code few times, I noticed that almost every time I run it, at some random server, it will get stuck at this stage (This problem so far only happens once per runtime)Which means I have to manually enter the password for the program to keep running or it will just sit there. I would like to be able to walk away or do something else which this program runs, so I thought if I can come up with a way for autoit to detect that it hasn't done anything in a minute. It will just close this IE instance and restart IE at that specific server and try again.Sorry this is long, but thanks for any help Link to comment Share on other sites More sharing options...
JSThePatriot Posted March 6, 2009 Share Posted March 6, 2009 I would recommend (probably just a dirty trick) using a global variable, and the AdLib() function. The function you declare in the AdLib() can count how many seconds go by without that global variable being set, and if it reaches 60, it restarts that part of the code or something. Thanks, Jarvis AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
ToyBoi Posted March 6, 2009 Author Share Posted March 6, 2009 I would recommend (probably just a dirty trick) using a global variable, and the AdLib() function. The function you declare in the AdLib() can count how many seconds go by without that global variable being set, and if it reaches 60, it restarts that part of the code or something. Thanks, Jarvis do you mean AdlibEnable ? AdlibEnable("myadlib",120000) ;... Exit Func myadlib() sleep(8000) If WinActive("Connect to") Then _IEQuit ($oIE) EndIf EndFunc I have no idea where to place this function, and I need some help on how I can have autoit restart at the point it got stuck. say it got stuck at $a = 7 (7th valuable of the array) Link to comment Share on other sites More sharing options...
GreenCan Posted March 6, 2009 Share Posted March 6, 2009 (edited) @ToyBoiI found this a while ago. As JSThePatriot, I believe that this could do it.in combination with a restart function, see http://www.autoitscript.com/forum/index.ph...st&p=652658AdLibEnable("_UpdateTimer", 100) Global $nTimer = 0 Global $OldMousePosition = MouseGetPos() GLobal $NewMousePosition While(1) sleep(10) WEnd Func _UpdateTimer() $nTimer += 100 ;100 ms $NewMousePosition = MouseGetPos() if (($NewMousePosition[0] == $OldMousePosition[0]) and ($NewMousePosition[1] == $OldMousePosition[1])) Then ; The user is still idle (you might also want to check for key presses Else ; The user moved, we should start the timer over. $OldMousePosition = $NewMousePosition $nTimer = 0 EndIf if ($nTimer >= 5000) Then _OnTimerFinish() $nTimer = 0 EndIf EndFunc Func _OnTimerFinish() MsgBox(0, "", "You were idle for 5 seconds, and I cought you!") AdLibDisable() Exit EndFunc Edited March 6, 2009 by GreenCan Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image Link to comment Share on other sites More sharing options...
ToyBoi Posted March 6, 2009 Author Share Posted March 6, 2009 (edited) thanks Greencan and JSThePatriot, @ Greencan. I do not wish to restart the entire script because that would be a waste of time, but wherever it got stuck my for loop is basically for $a = 1 to 48 . . . . next $a when i use adlibenable to find out that it got stuck at $a = 7, how do I have it restart at that point. the restart function thread I understand would restart from scratch Edited March 6, 2009 by ToyBoi Link to comment Share on other sites More sharing options...
JSThePatriot Posted March 6, 2009 Share Posted March 6, 2009 You would want your program setup with functions. If you had your main for loop in a function that accepted parameters then you could supply it the number you were stuck on. You would need to make $a into a global variable so you would be able to get that number out to supply it back in. Regards, Jarvis AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
GreenCan Posted March 6, 2009 Share Posted March 6, 2009 Are these servers in your network or are they websites? You could avoid these pop-ups by mapping each drive DriveMapAdd ( "device", "remote share" [, flags [, "user" [, "password"]]] ) do the stuff you need and delete the map afterwards. DriveMapDel ( "device" ) Alternatively, you can also automate the login in IE, something like this: #include <IE.au3> $sUsername = "blabla" $sPassword = "blablabla" $oIE = _IECreate("http://etcetc.htm",0,0,0,1) sleep(1000) ControlSend("Username", "", "Edit2", $sUsername ,0) ControlSend("Password", "", "Edit3", $sPassword & "{ENTER}" ,0) GreenCan Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image Link to comment Share on other sites More sharing options...
ToyBoi Posted March 9, 2009 Author Share Posted March 9, 2009 Are these servers in your network or are they websites? You could avoid these pop-ups by mapping each drive DriveMapAdd ( "device", "remote share" [, flags [, "user" [, "password"]]] ) do the stuff you need and delete the map afterwards. DriveMapDel ( "device" ) Alternatively, you can also automate the login in IE, something like this: #include <IE.au3> $sUsername = "blabla" $sPassword = "blablabla" $oIE = _IECreate("http://etcetc.htm",0,0,0,1) sleep(1000) ControlSend("Username", "", "Edit2", $sUsername ,0) ControlSend("Password", "", "Edit3", $sPassword & "{ENTER}" ,0) GreenCan Hi Greencan yes these are servers in our own network, so can i still map each drive? and what is the difference between your login automation and mine? note sometimes, the server will ask for the password twice, the second time it will only ask for the password. if WinActive("Connect to" ) then send ($username) sleep (500) send ("{Tab}") send ($password) sleep(500) Send("{enter}") sleep(2000) endif ;enters the password only while WinActive("Connect to" ) sleep(400) send ($password) sleep(400) Send("{enter}") _IELoadWait ($oIE) wend 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