Piccolo1986 Posted April 8, 2014 Share Posted April 8, 2014 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 Link to comment Share on other sites More sharing options...
Palestinian Posted April 8, 2014 Share Posted April 8, 2014 Use the AutoIt Window Info to identify the input boxes for username and password then search the help file for ControlCommand and related functions Link to comment Share on other sites More sharing options...
Piccolo1986 Posted April 8, 2014 Author Share Posted April 8, 2014 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. Link to comment Share on other sites More sharing options...
Palestinian Posted April 8, 2014 Share Posted April 8, 2014 Try using >this to recognize the input fields Link to comment Share on other sites More sharing options...
Paramjeet Posted April 8, 2014 Share Posted April 8, 2014 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. Link to comment Share on other sites More sharing options...
MotionFlex Posted April 8, 2014 Share Posted April 8, 2014 (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 April 8, 2014 by MotionFlex Link to comment Share on other sites More sharing options...
Paramjeet Posted April 8, 2014 Share Posted April 8, 2014 there will be text or instance and class make combination for control like : [Class:??;INSTANSE:??;Text:??] Link to comment Share on other sites More sharing options...
Palestinian Posted April 8, 2014 Share Posted April 8, 2014 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 Link to comment Share on other sites More sharing options...
MotionFlex Posted April 8, 2014 Share Posted April 8, 2014 (edited) there will be text or instance and class make combination for control like : [Class:??;INSTANSE:??;Text:??] Look, he posted the picture... Edited April 8, 2014 by MotionFlex Link to comment Share on other sites More sharing options...
Solution Piccolo1986 Posted April 9, 2014 Author Solution Share Posted April 9, 2014 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. expandcollapse popup#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 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