Example #1
0
        public static GuiConnection CreateConnection(string description, string user, string password, string language)
        {
            CSapROTWrapper sapROTWrapper = new CSapROTWrapper();
            object         SapGuilRot    = sapROTWrapper.GetROTEntry("SAPGUI");
            object         engine        = SapGuilRot.GetType().InvokeMember("GetSCriptingEngine", System.Reflection.BindingFlags.InvokeMethod,
                                                                             null, SapGuilRot, null);

            GuiApplication app = (GuiApplication)engine;
            GuiConnection  conn;

            if (app.Connections.Count == 0)
            {
                conn = app.OpenConnection(description);
                GuiSession       session     = conn.Children.ElementAt(0) as GuiSession;
                GuiTextField     name        = (GuiTextField)session.FindById("wnd[0]/usr/txtRSYST-BNAME");
                GuiPasswordField pass        = (GuiPasswordField)session.FindById("wnd[0]/usr/pwdRSYST-BCODE");
                GuiTextField     lang        = (GuiTextField)session.FindById("wnd[0]/usr/txtRSYST-LANGU");
                GuiMainWindow    mainWindows = (GuiMainWindow)session.FindById("wnd[0]");

                name.Text = user;
                pass.Text = password;
                lang.Text = language;
                mainWindows.SendVKey(0);
            }
            else
            {
                conn = (GuiConnection)app.Connections.ElementAt(0);
            }

            return(conn);
        }
        public string Get_TextBox_Value_ByID(string strControlID)
        {
            GuiSession SapSession = getCurrentSession();
            //GuiTextField txtControl = (GuiTextField)SapSession.ActiveWindow.FindById(strControlID, "GuiTextField");
            GuiTextField txtControl = (GuiTextField)SapSession.ActiveWindow.FindById(strControlID, "GuiTextField");

            return(txtControl.Text);
        }
        public bool TextInputByID(string strControlID, string strValue)
        {
            GuiSession   SapSession = getCurrentSession();
            GuiTextField txtControl = (GuiTextField)SapSession.ActiveWindow.FindById(strControlID, "GuiTextField");

            txtControl.SetFocus();
            txtControl.Text = strValue;
            return(true);
        }
        private bool TextInput_NameEx(string strControlID, string strValue)
        {
            GuiSession   SapSession = getCurrentSession();
            GuiTextField txtControl = (GuiTextField)SapSession.ActiveWindow.FindByNameEx(strControlID, 1);

            txtControl.SetFocus();
            txtControl.Text = strValue;
            return(true);
        }
Example #5
0
        public void Execute(ActionContext context)
        {
            GuiTextField textField = (GuiTextField)context.GetSession().FindById(path);

            if (textField != null)
            {
                textField.Text = TextProvider.GetText();
            }
        }
Example #6
0
        //public RemoveTextBlockToRightAction(char separator)
        //  : this(new char[] { separator }) { }

        public void Execute(ActionContext context)
        {
            GuiTextField textField = context.GetSession().GetInFocus() as GuiTextField;

            if (textField == null)
            {
                return;
            }
            string text = textField.Text;

            text           = remove.Remove(textField.Text, textField.CaretPosition);
            textField.Text = text;
        }
 public void Execute(ActionContext context)
 {
     int          index              = GetCurrentIndex(context);
     GuiTextField typeField          = (GuiTextField)context.GetSession().FindById("abc");
     GuiTextField modifierField      = (GuiTextField)context.GetSession().FindById("abc");;
     GuiCheckBox  valueField         = (GuiCheckBox)context.GetSession().FindById("abc");;
     GuiTextField referenceTypeField = (GuiTextField)context.GetSession().FindById("abc");;
     //   GuiClassVariable parameter = new GuiClassVariable(
     //         typeField,
     //        modifierField,
     //         valueField,
     //        referenceTypeField
     //     );
     string parameterName = "ir_scenario";
     //new MethodParameterSignatureSuggestion().Suggest(parameterName, parameter);
 }
Example #8
0
        public const int KEYEVENTF_KEYUP       = 0x0002; //Key up flag

        public void Execute(ActionContext context)
        {
            GuiTextField textField = context.GetSession().GetInFocus() as GuiTextField;

            if (textField == null)
            {
                return;
            }
            string text = textField.Text;

            text = remove.Remove(textField.Text, textField.CaretPosition);

            int oldPosition = textField.CaretPosition;
            int difference  = textField.Text.Length - text.Length;
            int newPosition = textField.CaretPosition - difference;

            textField.CaretPosition = newPosition;
            textField.Text          = text;
        }
Example #9
0
 		public void login(string myclient, string mylogin, string mypass, string mylang)
 		{
 			GuiTextField client  = (GuiTextField)SapActive.SapSession.ActiveWindow.FindByName("RSYST-MANDT", "GuiTextField");
             GuiTextField login  = (GuiTextField)SapActive.SapSession.ActiveWindow.FindByName("RSYST-BNAME", "GuiTextField");
             GuiTextField pass  = (GuiTextField)SapActive.SapSession.ActiveWindow.FindByName("RSYST-BCODE", "GuiPasswordField");
             GuiTextField language  = (GuiTextField)SapActive.SapSession.ActiveWindow.FindByName("RSYST-LANGU", "GuiTextField");
 			
 			client.SetFocus();
 			client.text = myclient;
 			login.SetFocus();
 			login.text = mylogin;
 			pass.SetFocus();
 			pass.text = mypass
 			myland.SetFocus();
 			mylang.text = mylang; 
 			
 			//Press the green checkmark button which is about the same as the enter key 
 			GuiButton btn = (GuiButton)SapSession.FindById("/app/con[0]/ses[0]/wnd[0]/tbar[0]/btn[0]");
 			btn.SetFocus(); 
 			btn.Press();
 			
 		}
        /// <summary>
        /// This function will login into the SAP with provided credentials(same as manual login)
        /// </summary>
        /// <param name="SapSession"></param>
        /// <param name="myclient"></param>
        /// <param name="mylogin"></param>
        /// <param name="mypass"></param>
        /// <param name="mylang"></param>
        public string login(string servername, string myclient, string mylogin, System.Security.SecureString mypass, string mylang)
        {
            //GuiApplication appSAP = (GuiApplication)Marshal.GetActiveObject("SAPGUI");
            //GuiConnection connSAP = appSAP.OpenConnection(server, Sync: true);
            //GuiSession SapSession = (GuiSession)connSAP.Sessions.Item(0);

            //    System.IO.StreamWriter m_fswLogFile;
            //DateTime m_dtLastTimeLog = DateTime.MinValue;
            //int m_intTimeLogInterVal;

            //String strFilePath = "D:\\AA_Log_SAPAUto_Metabot.txt";

            //if (!System.IO.File.Exists(strFilePath)) {
            //    System.IO.File.Create(strFilePath).Close();
            //}
            ////Open the log file
            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("Parameters");
            //m_fswLogFile.WriteLine(server);
            //m_fswLogFile.WriteLine(mylogin);
            //m_fswLogFile.WriteLine(mypass);
            //m_fswLogFile.WriteLine(mylang);
            //m_fswLogFile.WriteLine(SAPWindowName);
            //m_fswLogFile.Close();
            //m_fswLogFile = null;

            //Close the SAP if its opened, then open the new process
            KillProcess("saplogon");

            //Set the Exe Path and SAP Window name
            string          strSAPLoginPadPath = @"C:\Program Files (x86)\SAP\FrontEnd\SapGui\saplogon.exe";
            FileVersionInfo fi2                = FileVersionInfo.GetVersionInfo(strSAPLoginPadPath);
            string          strVersion         = fi2.ProductVersion.Substring(0, 3);
            String          strloginWindowName = "SAP Logon " + strVersion;

            //Open the SAP Logon Window
            StartProcess(strSAPLoginPadPath);

            //Wait for the window to be loaded.
            System.Threading.Thread.Sleep(1000);
            AutomationElement desktop = AutomationElement.RootElement;
            AutomationElement ele     = null;

            while (ele is null)
            {
                try
                {
                    ele = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, strloginWindowName));
                }
                catch { }
            }

            CSapROTWrapper sapROTWrapper = new CSapROTWrapper();
            object         rot           = sapROTWrapper.GetROTEntry("SAPGUI");
            object         engine        = rot.GetType().InvokeMember("GetScriptingEngine", System.Reflection.BindingFlags.InvokeMethod, null, rot, null);
            GuiConnection  connection    = (engine as GuiApplication).OpenConnection(servername);
            GuiSession     SapSession    = connection.Children.ElementAt(0) as GuiSession;

            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("Going to get the controls for login");

            //m_fswLogFile.Close();
            //m_fswLogFile = null;

            GuiTextField client   = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-MANDT", "GuiTextField");
            GuiTextField login    = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-BNAME", "GuiTextField");
            GuiTextField pass     = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-BCODE", "GuiPasswordField");
            GuiTextField language = (GuiTextField)SapSession.ActiveWindow.FindByName("RSYST-LANGU", "GuiTextField");

            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("Enter credentials for login");

            //m_fswLogFile.Close();
            //m_fswLogFile = null;
            client.SetFocus();
            client.Text = myclient;
            login.SetFocus();
            login.Text = mylogin;
            pass.SetFocus();
            pass.Text = new System.Net.NetworkCredential(string.Empty, mypass).Password;
            language.SetFocus();
            language.Text = mylang;

            //m_fswLogFile = new System.IO.StreamWriter(strFilePath, true);
            //m_fswLogFile.AutoFlush = true;
            //m_fswLogFile.WriteLine("click login");

            //m_fswLogFile.Close();
            //m_fswLogFile = null;
            //Press the green checkmark button which is about the same as the enter key
            GuiButton btn = (GuiButton)SapSession.FindById("/app/con[0]/ses[0]/wnd[0]/tbar[0]/btn[0]");

            btn.SetFocus();
            btn.Press();

            //Validate whether the login successfull or Not
            //If the error is "Already logged in by the same user, then click
            GuiStatusbar statusBar  = (GuiStatusbar)SapSession.FindById("wnd[0]/sbar");
            string       strMsg     = statusBar.Text;
            string       strMsgType = statusBar.MessageType;

            if (strMsg.Contains("User already logged on at another terminal") == true || strMsg.Contains("用户已经登录到其它终端") == true)//(strMsg == "W" || strMsgType == "E" ) //'Warning or Error
            {
                //Check whether is it showing the same terminal or different terminal
                string strWinText = ((GuiFrameWindow)SapSession.FindById("wnd[1]")).Text;
                strWinText = Environment.MachineName;
                if (strWinText.Contains(Environment.MachineName) == true)
                {
                    //This represents, the login in the same machine, then click continue with current login option
                    ((GuiRadioButton)SapSession.FindById("wnd[1]/usr/radMULTI_LOGON_OPT1")).Select();
                    ((GuiButton)SapSession.FindById("wnd[1]/tbar[0]/btn[0]")).Press();
                }
                else
                {
                    SapSession.ActiveWindow.Close();
                    return("SAP Error while logging in the SAP system, Error:\n" + strMsg);
                }
            }
            else if (strMsg.Length > 0 && strMsgType == "E")
            {
                SapSession.ActiveWindow.Close();
                return("SAP Error while logging in the SAP system, Error:\n" + strMsg);
            }

            return("success");
        }
Example #11
0
        /** Creates the UI componenets required to display the gui */
        private void CreateUIComponents()
        {
            var window = new GuiWindow(800, 560);

            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = new Color(0.5f, 0.5f, 0.5f);
            PositionComponent(window, 0, 0);
            Add(window);

            // ------------------

            nameInput               = new GuiTextField(0, 0, 200);
            nameInput.Value         = CharacterNameGenerator.GenerateName();
            nameInput.LabelText     = "Name";
            nameInput.LabelPosition = LabelPosition.Left;
            window.Add(nameInput, 0, 20);

            var randomButton = new GuiButton("random", -1, 20);

            window.Add(randomButton, (int)nameInput.Bounds.xMax + 10, 25);

            // ------------------

            var genderListFrame = new FramedListBox <MDRGender>(200, 100, "Gender");

            window.Add(genderListFrame, 260, 100);

            portraitSelector          = new GuiPictureSeletor();
            portraitSelector.Pictures = CoM.Instance.Portraits.GetEntries().ToArray();
            window.Add(portraitSelector, 460, 70 + 18 + 20);

            allRacesToggle                 = new GuiToggleButton();
            allRacesToggle.LabelText       = "Show All";
            allRacesToggle.LabelPosition   = LabelPosition.Right;
            allRacesToggle.X               = (int)portraitSelector.Bounds.xMax + 10;
            allRacesToggle.Y               = (int)portraitSelector.Bounds.y + 30;
            allRacesToggle.Value           = false;
            allRacesToggle.OnValueChanged += delegate {
                updatePortraits();
            };
            window.Add(allRacesToggle);

            // ------------------

            var raceListFrame = new FramedListBox <MDRRace>(200, 240, "Race");

            window.Add(raceListFrame, 20, 240);

            statList = new GuiStatList(new MDRStats());
            window.Add(statList, 220 + 20, 240);

            var characterInfo = new GuiWindow(250, 240, "Info");

            window.Add(characterInfo, 470 + 40, 240);

            characterInfoText          = new GuiLabel(0, 0, "");
            characterInfoText.Align    = GuiAlignment.Full;
            characterInfoText.WordWrap = true;
            characterInfo.Add(characterInfoText);

            // ------------------

            // ------------------

            GuiButton cancelButton = new GuiButton("Cancel", 100);

            window.Add(cancelButton, 20, -20);

            GuiButton doneButton = new GuiButton("Save", 100);

            window.Add(doneButton, -20, -20);


            raceList = raceListFrame.ListBox;
            foreach (MDRRace race in CoM.Races)
            {
                raceList.Add(race);
            }

            genderList = genderListFrame.ListBox;
            genderList.Add(MDRGender.Male);
            genderList.Add(MDRGender.Female);

            genderList.OnSelectedChanged += delegate {
                updateGender();
            };
            raceList.OnSelectedChanged += delegate {
                updateRace();
            };

            doneButton.OnMouseClicked += delegate {
                if (statList.FreePoints != 0)
                {
                    Engine.ConfirmAction(saveAndClose, "This character still has " + Util.Colorise(statList.FreePoints, Color.green) + " stat points left to spend.\nAre you sure you want to save the character without spending them?");
                }
                else
                {
                    saveAndClose();
                }
            };

            cancelButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
            randomButton.OnMouseClicked += delegate {
                nameInput.Value = CharacterNameGenerator.GenerateName();
            };

            updateRace();
            updateGender();
        }
Example #12
0
        private void SetCell(int columnIndex, string value)
        {
            GuiTextField field = table.GetCell(rowIndex, columnIndex) as GuiTextField;

            field.Text = value;
        }
        private void SetCell(int columnIndex, string value)
        {
            GuiTextField field = row.ElementAt(columnIndex) as GuiTextField;

            field.Text = value;
        }
Example #14
0
        /**
         * Creates a control for given property.
         *
         * ToggleButtons will be used for boolean properties.
         * For the moment other types of properties are not supported.
         *
         * @param source The source object this property belongs to.
         * @param property The property to create a control for.
         */
        private GuiLabeledComponent CreateControl(object source, PropertyInfo property)
        {
            GuiLabeledComponent result = null;

            var rangeAttribute = getAttribute <SettingRange>(property);

            if (property.PropertyType == typeof(System.Boolean))
            {
                var toggleButton = new GuiToggleButton();
                toggleButton.Value = (bool)property.GetValue(source, null);
                if (property.CanWrite)
                {
                    toggleButton.OnValueChanged += delegate {
                        property.SetValue(source, toggleButton.Value, null);
                    }
                }
                ;
                result = toggleButton;
            }
            else if (property.PropertyType.IsEnum)
            {
                var radioGroup = new GuiRadioButtonGroup();

                radioGroup.EnableBackground = false;
                radioGroup.ButtonSpacing    = 2;
                radioGroup.ButtonSize       = new Vector2(80, 32);

                var enumNames = Enum.GetNames(property.PropertyType);
                foreach (string enumValueName in enumNames)
                {
                    if (!enumValueName.StartsWith("_"))
                    {
                        radioGroup.AddItem(enumValueName);
                    }
                }

                radioGroup.SelectedIndex = (int)property.GetValue(source, null);

                if (property.CanWrite)
                {
                    radioGroup.OnValueChanged += delegate {
                        property.SetValue(source, radioGroup.SelectedIndex, null);
                    };
                }

                result = radioGroup;
            }
            else if (property.PropertyType == typeof(System.Single) && (rangeAttribute != null))
            {
                var slider = new GuiSlider();
                slider.Min   = rangeAttribute.Min;
                slider.Max   = rangeAttribute.Max;
                slider.Value = (float)property.GetValue(source, null);
                if (property.CanWrite)
                {
                    slider.OnValueChanged += delegate {
                        property.SetValue(source, slider.Value, null);
                    }
                }
                ;
                result = slider;
            }
            else if (
                // fallback to edit box
                (property.PropertyType == typeof(int)) ||
                (property.PropertyType == typeof(float)) ||
                (property.PropertyType == typeof(string)))
            {
                int editWidth = (property.PropertyType == typeof(string)) ? 325 : 60;

                var editBox = new GuiTextField(0, 0, editWidth);

                object propertyValue = property.GetValue(source, null);
                if (propertyValue != null)
                {
                    editBox.Value = propertyValue.ToString();
                    if (editBox.Value.Length > 35)
                    {
                        editBox.FontSize = 12;
                    }
                    if (editBox.Value.Length > 55)
                    {
                        editBox.FontSize = 10;
                    }
                    if (editBox.Value.Length > 75)
                    {
                        editBox.FontSize = 8;
                    }
                }

                if (property.CanWrite)
                {
                    editBox.OnValueChanged += delegate {
                        if (property.PropertyType == typeof(int))
                        {
                            property.SetValue(source, Util.ParseIntDefault(editBox.Value, 0), null);
                        }
                        else if (property.PropertyType == typeof(float))
                        {
                            property.SetValue(source, Util.ParseFloatDefault(editBox.Value, 0), null);
                        }
                        else if (property.PropertyType == typeof(string))
                        {
                            property.SetValue(source, editBox.Value, null);
                        }
                    }
                }
                ;

                result = editBox;
            }

            if (result != null)
            {
                if (!property.CanWrite)
                {
                    result.SelfEnabled = false;
                }
                result.LabelText     = property.Name;
                result.LabelPosition = LabelPosition.Left;
                result.Name          = property.Name;
            }


            return(result);
        }