Sign in to follow this  
Followers 0
will never learn

Password incorrect using ControlSetText()

10 posts in this topic

This is a very odd problem. Totally unexplainable to me...

I am trying to log into a program and therefore use run() to call the login window.

post-15116-12512703633744_thumb.png

Real simple this far.

However, when I am trying to log in using ControlSetText, the password is called incorrect and the login fails.

ControlSetText("Production Anmeldung in proALPHA","",15,"username")
Sleep(300)
ControlSetText("Production Anmeldung in proALPHA","",17,"password")
Sleep(300)
ControlClick("Production Anmeldung in proALPHA","OK",11)

When using one of the two examples of code below, it works...

ControlSetText("Production Anmeldung in proALPHA","",15,"username")
Sleep(300)
ControlSend("Production Anmeldung in proALPHA","",17,"password")
Sleep(300)
ControlClick("Production Anmeldung in proALPHA","OK",11)

ControlSetText("Production Anmeldung in proALPHA","",15,"username")
Sleep(300)
ControlClick("Production Anmeldung in proALPHA","",17)
Sleep(300)
Send("password{ENTER}")

From my testing, ControlSetText() seems to set the text in the Control, but in fact doesn't. If for exampe the window is called and the username is set to, say "user1" and I use ControlSetText() to change it to "user2", I will receive an error message, saying that "user1 is unknown or the password is incorrect". And this even though the text fiel shows "user2".

Can someone explain this to me? Is this a known issue? Are there elegant workarounds?

Because right now I can only image using ControlClick(), Send() with a bunch of Delete and Backspace keys and then ControlSend(). Not very nice...

Looking forward to the experts' answers...

Share this post


Link to post
Share on other sites



Im not sure, but try this:

ControlSetText("Production Anmeldung in proALPHA","",15,"username",1)
Sleep(300)
ControlSetText("Production Anmeldung in proALPHA","",17,"password",1)
Sleep(300)
ControlClick("Production Anmeldung in proALPHA","OK",11)

([optional] when different from 0 (default) will force the target window to be redrawn.)


_____________________________________________________________________________

Share this post


Link to post
Share on other sites

Thanks for the tip.

However, it doesn't change a thing :-(

Just for the archives: my Workaround:

Dim $user
$user = ControlGetText("Production Anmeldung in proALPHA","",15)
Sleep(3000)
If $user <> "username" Then
ControlSend("Production Anmeldung in proALPHA","",15,"{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{BACKSPACE}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}{DEL}")
Sleep(3000)
ControlSend("Production Anmeldung in proALPHA","",15,"username")
EndIf
Sleep(3000)
ControlSend("Production Anmeldung in proALPHA","",17,"password")
Sleep(3000)
ControlClick("Production Anmeldung in proALPHA","OK",11, "primary",1)

Share this post


Link to post
Share on other sites

Tip:

Use {BACKSPACE X} instead of {BACKSPACE}(1) {BACKSPACE}(2) ...{BACKSPACE}(X)


_____________________________________________________________________________

Share this post


Link to post
Share on other sites

Ok. Scrap the workaround. It is still not working, for some reason.

Any other ideas? I am out of clues here :D

Share this post


Link to post
Share on other sites

It's probably the GUI you're trying to automate that is not following good GUI design practices. If you say ControlSend works, I recommend using that.

Share this post


Link to post
Share on other sites

I recently encountered a similar problem with automating an app written in Clarion Topspeed:

I could ControlSetText() for a filename edit control, but on clicking the OK button, the operation failed.

Slowing down the process actually revealed that as soon as the edit field lost focus to the OK button the text was cleared.

In the end, ControlSend() was the way to go.

Share this post


Link to post
Share on other sites

In my opinion everything working fine. Password controls are handled differently in common to prevent exactly this automated entering of passwords. This behaviour is totally different to normal edit or input controls and therefore not expected.

But the workaround with sending x times BS char is not useable. You have to send a few hundreds of BS chars to get rid of very long passwords. I would use

ControlSend("Production Anmeldung in proALPHA","",15,"{HOME}+{END}")

So the whole text will be selected and can be overwritten instantly with your password.

Hope that helps.

D.

Share this post


Link to post
Share on other sites

Resolved!

Here's what's working:

I use ControlFocus() and then ControlSend().

Don't ask me why exactly this works. But this done so repeatedly, so it is a good enough solution for me...

Thanks for y'all's help.

Will

Share this post


Link to post
Share on other sites

Resolved!

Here's what's working:

I use ControlFocus() and then ControlSend().

Don't ask me why exactly this works. But this done so repeatedly, so it is a good enough solution for me...

Thanks for y'all's help.

Will

Depending on how complex your passwords are, it can be critical to use the RAW flag for Send() or ControlSend(), otherwise special characters get interpreted as Send codes. For example, "Adm!n" would be send as A, d, m, ALT-n.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0