Moderators big_daddy Posted December 21, 2005 Moderators Share Posted December 21, 2005 (edited) Not sure why some computers get this error and others don't? This is the section giving the error:Case $msg = $Button1 GUISetState(@SW_HIDE); == Hides Audit Information Window == Run("\\main\trackit\audit32.exe") WinWaitActive("Track-It! Audit") Send("!n") Sleep(200) Send($Name & "{tab}" & "{tab}" & "{tab}" & $Phone & "{Tab}" & $Email & "{Tab}" & "{Tab}" & $Department) Send("!n") Sleep(200) Send("{Tab}" & $InvLabel) Send("!n") Do ToolTip("Please Wait...", $x, $y, "Audit in progress") Local $FGT = FileGetTime('C:\TrackitAudit.id'); == Get the last-modified time of the file == Local $FileDateAsString = $FGT[0] & '/' & $FGT[1] & '/' & $FGT[2] & ' ' & $FGT[3] & ':' & $FGT[4] & ':' & $FGT[5]; == Convert that to a format expected by _DateDiff()== Local $Age = _DateDiff('s', $FileDateAsString, _NowCalc()); == Determine the number of seconds since the last-modified time == Sleep(2000); == Pauses for 2 seconds so it is not too much on the PC == Until $Age < (60); == Wait until the file is less than 1 minute old == ; == Writes the information provided by the user to the ini file == IniWrite ( "C:\TrackIT.ini", "Name", "Key", $Name ) IniWrite ( "C:\TrackIT.ini", "Phone", "Key", $Phone ) IniWrite ( "C:\TrackIT.ini", "Email", "Key", $Email ) IniWrite ( "C:\TrackIT.ini", "InvLabel", "Key", $InvLabel ) IniWrite ( "C:\TrackIT.ini", "Department", "Key", $Department ) WinClose("Track-It! Audit") ExitThis is the full script: Updated Edited December 22, 2005 by big_daddy Link to comment Share on other sites More sharing options...
LxP Posted December 21, 2005 Share Posted December 21, 2005 It seems to me that the file may not exist at that point. This will wait until the file exists:··· ToolTip("Please Wait...", $x, $y, "Audit in progress") While Not FileExists('C:\TrackitAudit.id') Sleep(1000) WEnd Local $FGT = FileGetTime('C:\TrackitAudit.id') ···Also, may I suggest this optimisation:; Send($Name & "{tab}" & "{tab}" & "{tab}" & $Phone & "{Tab}" & $Email & "{Tab}" & "{Tab}" & $Department) Send($Name, 1) Send('{TAB 3}') Send($Phone, 1) Send('{TAB}') Send($Email, 1) Send('{TAB 2}') Send($Department, 1)This ensures that if one of those variables contains a 'special' character (such as + or #), that character is sent instead of holding down the Shift or Win key. Even better would be to use ControlSetText(), which would look something like this code-wise (where you need to replace 'ControlID' with the actual control IDs as per AutoIt Window Info):ControlSetText('Track-It! Audit', '', 'ControlID', $Name) ControlSetText('Track-It! Audit', '', 'ControlID', $Phone) ControlSetText('Track-It! Audit', '', 'ControlID', $Email) ControlSetText('Track-It! Audit', '', 'ControlID', $Department)This doesn't require hijacking of the keyboard and therefore leaves less room for error. Your script will also run faster and you even have the option of hiding the window while it does its work since ControlSetText() works on inactive windows. I suspect that the !n is selecting a button too -- you can replace those calls with ControlClick() in that case. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 22, 2005 Author Moderators Share Posted December 22, 2005 ··· ToolTip("Please Wait...", $x, $y, "Audit in progress") While Not FileExists('C:\TrackitAudit.id') Sleep(1000) WEnd Local $FGT = FileGetTime('C:\TrackitAudit.id') ···I didn't even think about the first time the audit ran that the file wouldn't be there already. Nice catch...DONE Also, may I suggest this optimisation: ; Send($Name & "{tab}" & "{tab}" & "{tab}" & $Phone & "{Tab}" & $Email & "{Tab}" & "{Tab}" & $Department) Send($Name, 1) Send('{TAB 3}') Send($Phone, 1) Send('{TAB}') Send($Email, 1) Send('{TAB 2}') Send($Department, 1) This does make it run a lot smoother. I had read that you could do that I had just forgot. DONE Even better would be to use ControlSetText(), which would look something like this code-wise (where you need to replace 'ControlID' with the actual control IDs as per AutoIt Window Info): ControlSetText('Track-It! Audit', '', 'ControlID', $Name) ControlSetText('Track-It! Audit', '', 'ControlID', $Phone) ControlSetText('Track-It! Audit', '', 'ControlID', $Email) ControlSetText('Track-It! Audit', '', 'ControlID', $Department) This is how I was going to do it from the start, but each time the program is ran all the ControlID's are different. If you have any other ideas on this I'm game. I suspect that the !n is selecting a button too -- you can replace those calls with ControlClick() in that case. Didn't do this for the same reason as above. Thank you for all the help. I'm going to update the link in my first post with the changes. P.S. If I get some free time I'll try to make you an avatar. Link to comment Share on other sites More sharing options...
LxP Posted December 22, 2005 Share Posted December 22, 2005 This is how I was going to do it from the start, but each time the program is ran all the ControlID's are different.Do the ClassNameNNs also change each time the program is run? If so, I suspect that it's a .NET application.You may wish to identify the controls via their position using the _ControlGetHandleByPos() UDF. Being able to set the content of a control via its ID is guaranteed to be more failsafe so it's worth pursuing. 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