texan Posted January 13, 2011 Share Posted January 13, 2011 I keep having a random problem with ControlSetText not working on some Windows 7 PCs. Below is the section of code that is causing me a problem. I am trying to sign on to our software application. I wait for the Sign-On window to appear and then enter the password in the Editbox using the ControlSetText command. It always works on my 2000, XP & Vista PCs but on occassion it does not work on the Win7 PCs. Is there some other command I should try? Is there something different on Win7 that may cause this to fail at times? I am just a little lost on what to try next. ;If we find the Sign-On window then try to sign on If WinExists("Sign-On") Then GUICtrlSetData($Label, "Sign-On window found.") Sleep(15000) ;SetText has been failing at times on Win7. Repeat attempt if it does. $Result = WinWaitActive("Sign-On", "", 20) If $Result = 0 Then FailureExit("Sign-On window not active.") EndIf $Result = ControlSetText("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", $Password) If $Result = 0 Then GUICtrlSetData($Label, "Password SetText failed first attempt.") Sleep(5000) $Result = ControlSetText("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", $Password) If $Result = 0 Then FailureExit("SetText of password failed.") EndIf EndIf .... Link to comment Share on other sites More sharing options...
enaiman Posted January 13, 2011 Share Posted January 13, 2011 What about ControlSend? SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Varian Posted January 13, 2011 Share Posted January 13, 2011 ControlCommand() with "EditPaste"ControlCommand("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", "EditPaste", $Password) Link to comment Share on other sites More sharing options...
Zedna Posted January 14, 2011 Share Posted January 14, 2011 Try this ;If we find the Sign-On window then try to sign on If WinExists("Sign-On") Then GUICtrlSetData($Label, "Sign-On window found.") Sleep(15000) ;SetText has been failing at times on Win7. Repeat attempt if it does. WinActivate("Sign-On", "") $Result = WinWaitActive("Sign-On", "", 20) If $Result = 0 Then FailureExit("Sign-On window not active.") EndIf ControlFocus("Sign-On", "", "[CLASS:Edit;INSTANCE:1]") $Result = ControlSetText("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", $Password) If $Result = 0 Then GUICtrlSetData($Label, "Password SetText failed first attempt.") Sleep(5000) ControlFocus("Sign-On", "", "[CLASS:Edit;INSTANCE:1]") $Result = ControlSetText("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", $Password) If $Result = 0 Then FailureExit("SetText of password failed.") EndIf EndIf .... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Varian Posted January 14, 2011 Share Posted January 14, 2011 (edited) You can also keep trying itDo $Result = ControlSetText("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", $Password) Sleep(10) $Return = ControlGetText("Sign-On", "", "[CLASS:Edit;INSTANCE:1]") Until $Result == $Return Or Not ControlGetHandle("Sign-On", "", "[CLASS:Edit;INSTANCE:1]") Edited January 14, 2011 by Varian Link to comment Share on other sites More sharing options...
texan Posted January 20, 2011 Author Share Posted January 20, 2011 ControlCommand() with "EditPaste"ControlCommand("Sign-On", "", "[CLASS:Edit;INSTANCE:1]", "EditPaste", $Password) ^^^ This was the solution. ControlSetText continued to fail at times even after making sure the field had focus. Also, I couldn't do anything that involved using ControlGetText because that always fails, even after successfully using ControlSetText. The field is a password field that only shows ****** so maybe that is why. 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