aleph01 Posted September 27, 2013 Share Posted September 27, 2013 Greetings Forum: I have some code that usually runs fine, but occasionally the ControlSetText lines seem to not run and the ControlClick produces a "bad credentials" error from TrackIt. I've tried putting Sleep() entries, thinking that the script is somehow "getting ahead of itself" if you know what I mean, but still it runs inconsistently. Any and all help is welcome. Thanks, _aleph_ Run ("C:\Users\aleph\AppData\Local\Apps\2.0\J8431LJO.VVZ\OO9HM5PO.BWE\3085..5dfd_0000000000000000_000b.0001_0acfc99753a621ef\TechnicianClient.exe") WinWait ("Track-It! Login") Sleep (1500) WinActivate ("Track-It! Login") Sleep (100) ControlSetText ("Track-It! Login", "", "[CLASS:WindowsForms10.EDIT.app.0.286424b_r18_ad1; INSTANCE:1]", "aleph") ;Sleep (100) ControlSetText ("Track-It! Login", "", "[CLASS:WindowsForms10.EDIT.app.0.286424b_r18_ad1; INSTANCE:2]", "xxxxx") Sleep (100) ;WinActivate ("Track-It! Login") ;Sleep (100) ControlClick ("Track-It! Login", "", "[Class:WindowsForms10.BUTTON.app.0.286424b_r18_ad1; INSTANCE:1]") Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
JohnOne Posted September 27, 2013 Share Posted September 27, 2013 Possible solution. If ControlSetText ("Track-It! Login", "", "[CLASS:WindowsForms10.EDIT.app.0.286424b_r18_ad1; INSTANCE:2]", "xxxxx") Then Do Sleep(10) Until ControlGetText("Track-It! Login", "", "[CLASS:WindowsForms10.EDIT.app.0.286424b_r18_ad1; INSTANCE:2]") = "xxxxx" Sleep(100) EndIf You get the idea. 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...
aleph01 Posted September 30, 2013 Author Share Posted September 30, 2013 Thanks, JohnOne. That was so simple, I feel like a blind man at a light show. OMG!, I'm off for a week and won't be able to test for a while. It's kinda like living with bees in your head, but there they are, whatcha gonna do? I do have a question, though. Is there an advantage to using the If/EndIf loop? Could I just use ControlSetText then the Do/Until loop? Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
JohnOne Posted October 1, 2013 Share Posted October 1, 2013 Sure you can. Just force of habit, I like to test results of functions. If for some reason ControlSetText can not access the control, you are going to be in a bit of a pickle. I always like to have a plan B. I would also code a timeout in the above if I were using it, but just left out for brevity. 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...
aleph01 Posted October 7, 2013 Author Share Posted October 7, 2013 JohnOne, Just wanted to thank you again. The code works like a charm. It's like having a "ControlSetTextWait." Thanks for the code. I grow more proficient by the day with the help of people like you. _aleph_ Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
JohnOne Posted October 8, 2013 Share Posted October 8, 2013 Happy to help. I learnt quite quickly that a bit of extra code and time, can vastly improve the robustness of your script. Some people might call it overkill, but in my own scripts I wrap a lot of native functions I'm going to use, for example, someone might have in their code this... ClipPut("Some data") In my script it would be more like... _ClipPut("Some data") Func _ClipPut($xData) Local $iErrorTimedOut = 1 Local $iTimeout = 100 Local $Timer = TimerInit() Do If TimerDiff($Timer) >= $iTimeout Then Return SetError($iErrorTimedOut, 0, 0) EndIf ClipPut($xData) Until ClipGet() = $xData Return 1 EndFunc ;==>_ClipPut And almost every Control* function in a similar fashion. 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...
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