Jump to content

Autofill text into user and password field


Go to solution Solved by Piccolo1986,

Recommended Posts

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

Link to comment
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.

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
Link to comment
Share on other sites

  • Solution

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...