Sign in to follow this  
Followers 0
Piccolo1986

Autofill text into user and password field

10 posts in this topic

Hi AutoIt nation :-D

I'm really new to Autoit (I've some C# experience so I'm no bloody beginner) and need some help with one of my first scripts.

In my office we use SAP and because it's a multi user account I often have to log on and off.

When I want to start SAP I first have to start the "Log on Pad" choose the right connection, then the main programm will launch where I have to enter user and password.

I tried to automate it, in that way that I just have to click the skript and i automatically will be logged on.

But the script can't enter text into the user and password field, but when I start it by hand I just have to hack it into the keyboard and it works, there is no need to "activate" those fields.

What am I doing wrong?

ShellExecute("C:\Program Files\SAP\FrontEnd\SAPgui\saplgpad.exe")

WinWait("SAP Logon Pad 730")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{Enter}")

WinWait("SAP")
Send("USER")
Send("{TAB}")
Send("PASSWORD")
Send("{Enter}")

Exit

post-85448-0-38446000-1396941927_thumb.p

post-85448-0-73478800-1396941927_thumb.p

Share this post


Link to post
Share on other sites



Use the AutoIt Window Info to identify the input boxes for username and password then search the help file for ControlCommand and related functions

Share this post


Link to post
Share on other sites

That was one of my first ideas, but that didn't work, because it's not possible to identify those two fields, the whole area shows the same informations in the AutoIt window Info, see screenshot.

post-85448-0-63864600-1396946315_thumb.p

Share this post


Link to post
Share on other sites

Try using >this to recognize the input fields

Share this post


Link to post
Share on other sites

ControlSetText ( "title", "text", controlID, "new text" [, flag] )

Try to spy that text box get the control and use this above function.

I am not having this SAP app otherwise could give you complete script.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

ControlSetText ( "title", "text", controlID, "new text" [, flag] )

Try to spy that text box get the control and use this above function.

I am not having this SAP app otherwise could give you complete script.

If you read his above post, you would of seen that the control itself doesn't have an ID. It captures the whole window.

@OP Do what Palestinian said.

Edited by MotionFlex

Share this post


Link to post
Share on other sites

there will be text or instance and class make combination for control like :
 
[Class:??;INSTANSE:??;Text:??]

Share this post


Link to post
Share on other sites

The only recognizable control in that application is the entire page, the input boxes/fields are not recognized as individual controls by the AutoIt Window Info, I don't think it's possible to use the ControlSetText

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

there will be text or instance and class make combination for control like :

 

[Class:??;INSTANSE:??;Text:??]

 

Look, he posted the picture...

post-85448-0-63864600-1396946315.png

Edited by MotionFlex

Share this post


Link to post
Share on other sites

Finally I did it.

Not the way you guys mentioned, the thing with the java ui elements was way too tricky.

I just activated the needed window, and then navigate with tabulators trough it.

I also expanded the functionality a little bit.

#NoTrayIcon
Opt("WinTitleMatchMode", 3)

ShellExecute("C:\Program Files\SAP\FrontEnd\SAPgui\saplgpad.exe")

;start the main window
$Logon = WinWait("SAP Logon Pad 730")
Send("{DOWN}")
Send("{DOWN}")
Send("{DOWN}")
Send("{Enter}")

;wait for the main window and activate it
$Main = WinWait("SAP")
WinActivate($Main)

Sleep (300)

;insert user and password
Send("USER")
Send("{TAB}")
Send("PASSWORD")
Send("{Enter}")

Sleep(300)

;sometimes a popup appears after log in, if another user is logged in, so I have to solve that
If WinExists("Lizenzinformation bei Mehrfachanmeldung") Then
   Send("{TAB}")
   Send("{UP}")
   Send("{Enter}")
EndIf

While 1
;after a specific time I get a popup that my session has run out, this sucks so I "changed" it into a tooltip over the taskbar
   If WinExists ("SAP GUI for Windows 730") Then
      WinKill("SAP GUI for Windows 730")
          WinKill($Logon)
      Local $Taskbarheight = WinGetPos("[CLASS:Shell_TrayWnd; W:" & @DesktopWidth & "]")
      Local $Screensize = WinGetPos("Program Manager")
      ToolTip("SAP wurde automatisch beendet", $Screensize[2]-210, $Screensize[3]-40-$Taskbarheight[3],"SAP Timeout",1,0)
      Sleep(5000)
      ExitLoop
   EndIf
   
;if I normaly close the main window the logonpad should also be closed
   if Not WinExists($Main) Then
      WinKill($Logon)
      ExitLoop
   EndIf
   Sleep(50)
WEnd

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