autoitnoobies Posted March 14, 2009 Share Posted March 14, 2009 Hello all, I recently being getting into Autoit and love it's capability and potentials. I have a business need to logon to 3rd party software on specific machine and will renew the software license for week. I know it's crappy way of how this was arrange by agreement, but I have to make it work somehow and was able to get to work. But now I got a weird problem, when I create the excutable it will all day on my machine and test the machine as well. I made task schedule for auto this. As you can imagine, the codes are fairly simple. I works great for the day, but the next day the exe just hangs and will not complete. Here's the other thing, the same one that fail will work again later that day. I being searching and coming up empty, I am complete at lost with this. Can some PLEASE help or explain to me what me cause this. Thanks in advance for the great help. Link to comment Share on other sites More sharing options...
Skruge Posted March 14, 2009 Share Posted March 14, 2009 Hello all,I recently being getting into Autoit and love it's capability and potentials. I have a business need to logon to 3rd party software on specific machine and will renew the software license for week. I know it's crappy way of how this was arrange by agreement, but I have to make it work somehow and was able to get to work. But now I got a weird problem, when I create the excutable it will all day on my machine and test the machine as well. I made task schedule for auto this. As you can imagine, the codes are fairly simple.I works great for the day, but the next day the exe just hangs and will not complete. Here's the other thing, the same one that fail will work again later that day.I being searching and coming up empty, I am complete at lost with this. Can some PLEASE help or explain to me what me cause this.Thanks in advance for the great help.Welcome to the forums!Your wording is ambiguous. Are you having issues compiling a script, or are you having issues with an already compiled script?- Scan your system for viruses.- Uninstall and reinstall the latest stable version of AutoIt.- Post your code. Your script could be waiting indefinitely for a condition that never exists, and we have no way of knowing what you're trying to accomplish.Good luck [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
autoitnoobies Posted March 16, 2009 Author Share Posted March 16, 2009 Welcome to the forums!Your wording is ambiguous. Are you having issues compiling a script, or are you having issues with an already compiled script?- Scan your system for viruses.- Uninstall and reinstall the latest stable version of AutoIt.- Post your code. Your script could be waiting indefinitely for a condition that never exists, and we have no way of knowing what you're trying to accomplish.Good luckThanks for response. Sorry if I sound confusing, it was end of week and was doing 3 things at once . Here's the problem I am facing with and I have included the code below, as I said was very basic. 1. I am using AutoIt v3.3.0.0 and we run McAee anitvirus2. I compile code into excutable program and run the .exe with no problem.3. I've made XP Window schedule task in to run the my program daily. I've tested it and ran like it should I have schedule the task on my local machine and also a test machine. It all ran great the that day. Here's the problem, when the task ran the next, it will not complete the task. Instead it just "hangs on the system tray", it appears the send keystroke faile to excute for what reason. This fail on both my local machine and test machine. Anyways, I have included the code below. I hope this clearify my propblem. Thanks again for help.Code:;Excute applicationRun("\\server\Test\Apps.exe");Send keystrokeWhile 1 If WinActive("Good Morning! Login Please ....") Then ;Sleep (1000) Send ("keystroke") Send ("{TAB}") Send ("{Enter}") ;ControlClick("Intented Application Window", 328, 22) ExitLoop EndIfWend;wait for apps window to open and close after 2 secondWinWait("Intented Application Window","")WinWaitActive("Intented Application Window","")Sleep (2000)$handle = WinGetHandle("Intented Application Window", "")WinClose($handle) Link to comment Share on other sites More sharing options...
Mat Posted March 16, 2009 Share Posted March 16, 2009 (edited) ;Sleep (1000) ;ControlClick("Intented Application Window", 328, 22)are those supposed to be comments?edit: Do a full edit on your original post and changer the title, its a bit misleading as skruge pointed out. Edited March 16, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
autoitnoobies Posted March 16, 2009 Author Share Posted March 16, 2009 are those supposed to be comments?edit: Do a full edit on your original post and changer the title, its a bit misleading as skruge pointed out.Sorry, that was just extra stuff I've forgot to delete, here's the corrected code. Thanks!;Excute applicationRun("\\server\Test\Apps.exe");Send keystrokeWhile 1If WinActive("Good Morning! Login Please ....") ThenSend ("keystroke")Send ("{TAB}")Send ("{Enter}")ExitLoop EndIfWend;wait for apps window to open and close after 2 secondWinWait("Intented Application Window","")WinWaitActive("Intented Application Window","")Sleep (2000)$handle = WinGetHandle("Intented Application Window", "")WinClose($handle) Link to comment Share on other sites More sharing options...
GEOSoft Posted March 16, 2009 Share Posted March 16, 2009 On the times when it fails is your window actually active and is the title text actually as given? WinActive("Good Morning! Login Please ....") If that title text changes then you will have to set Opt("WinTitleMatchMode", 2) Example Opt("WinTitleMatchMode", 2) $sTitle = "Login Please" While 1 If WinActive($sTitle) Then If the window that you are looking for does not exist then you will get exactly what you are seeing now, a loop that will not exit until that window does exist. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
autoitnoobies Posted March 16, 2009 Author Share Posted March 16, 2009 On the times when it fails is your window actually active and is the title text actually as given? If that title text changes then you will have to set Opt("WinTitleMatchMode", 2) Example Opt("WinTitleMatchMode", 2) $sTitle = "Login Please" While 1 If WinActive($sTitle) Then If the window that you are looking for does not exist then you will get exactly what you are seeing now, a loop that will not exit until that window does exist. Thanks! Login window title does not change, I originally thought that it was delay issue. The code do process the run command part but it seems to stop there and not passing any of the keystroke section. So I manually launch the excutable and sure enough task program hangs in system tray. To make things more complicated, later in the that afternoon, I tried lauching it and it runs pefectly fine... Any help is greatly appreciated. Link to comment Share on other sites More sharing options...
Skruge Posted March 16, 2009 Share Posted March 16, 2009 Send ("keystroke")Send ("{TAB}")Send ("{Enter}")There's the possibility that another application steals the focus and thus intercepts the keystrokes.You can use SendKeepActive("Good Morning! Login Please ....") to prevent other apps from taking focus. However, Send will not work if nobody is logged in or if the workstation is locked. Is this the real difference between your morning/afternoon cases?A much more reliable way would be to do without Send.If the keystrokes are being sent to an input/edit field, try ControlSetText/ControlSend instead.If the "Tab -> Enter" is pressing a button, try ControlClick.All of the control names should be visible using the AutoIt Window Info Tool. (Au3Info.exe) [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Spiff59 Posted March 16, 2009 Share Posted March 16, 2009 (edited) Some sort of error handling might give you a better idea where you're failing? ;Execute application $FileName = "\\server\Test\Apps.exe" If FileExists($FileName) Then $PID = Run($FileName) Else Msgbox(16,"","Can not find server/file") Endif ;Send keystroke $timer = TimerInit() While 1 If TimerDiff($timer) > 10000 Then Msgbox(16,"", "Loop exceeded 10 seconds") Exitloop Endif If ProcessExists($PID) Then Sleep(100) Send ("keystroke") Send ("{TAB}") Send ("{Enter}") ExitLoop EndIf Wend Edit: Skruge has a good idea, I also wonder if it's possible for your app to report as existing, but not be fully loaded and ready for input from the keyboard? Maybe the Sleep above will make a diff? Edited March 16, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
GEOSoft Posted March 16, 2009 Share Posted March 16, 2009 (edited) I suspect that it has to do with the time allowed for WinActive(). using the standard WinWaitDelay you only have 250ms. Take a look at using WinWaitActive() instead of WinActive() EDIT: As a second thought, when the script "hangs" take a look and make sure that the proper control has focus. You may have to run the Window spy to get the control IDs and set focus first. Edited March 16, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Developers Jos Posted March 16, 2009 Developers Share Posted March 16, 2009 (edited) Add Opt("TrayIconDebug", 1) to the top of the script and when you have a hanging script, just hover the Icon to learn where its hanging. Jos Edited March 16, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
autoitnoobies Posted March 16, 2009 Author Share Posted March 16, 2009 Add Opt("TrayIconDebug", 1) to the top of the script and when you have a hanging script, just hover the Icon to learn where its hanging.JosThanks all for the advice. I have made some few changes base one some of your recommendations and recompiled the program. As expected, it ran perfectly, the big test will be tomorrow morning. I have scheduled the task to run the program in the morning without anyone logging on the machine. I have included the debug part in case the program hangs, hopefully it will help identify the problem.Two side notes: 1. Is the compile .exe secure? I am concern with hardcoding user name and password and passing it on via keystroke. 2. Any good books I can procure for learning?Thanks again all for the help. I will let you know if the program ran successfully. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 17, 2009 Developers Share Posted March 17, 2009 Two side notes: 1. Is the compile .exe secure? I am concern with hardcoding user name and password and passing it on via keystroke.No it is not and you should never use any Domain Admin level account. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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