当前位置: 首页>>代码示例>>C#>>正文


C# WinWindow.SetFocus方法代码示例

本文整理汇总了C#中WinWindow.SetFocus方法的典型用法代码示例。如果您正苦于以下问题:C# WinWindow.SetFocus方法的具体用法?C# WinWindow.SetFocus怎么用?C# WinWindow.SetFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WinWindow的用法示例。


在下文中一共展示了WinWindow.SetFocus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SelectWinTab

 public static void SelectWinTab(string wintitle ,string tabname)
 {
     WinWindow wnd = new WinWindow();
     wnd.SearchProperties.Add(WinWindow.PropertyNames.Name, wintitle, PropertyExpressionOperator.Contains);
     wnd.SearchProperties.Add(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains);
     wnd.SetFocus();
     wnd.Maximized = true;
     WinTabPage wtbpg = new WinTabPage(wnd);
     wtbpg.SearchProperties.Add(WinTabPage.PropertyNames.Name, tabname, PropertyExpressionOperator.Contains);
     Mouse.Click(wtbpg);
 }
开发者ID:prasannarhegde2015,项目名称:C-Advanced-Learning,代码行数:11,代码来源:Program.cs

示例2: ClickWinButton

 public static void ClickWinButton(string wintitle, string tabname)
 {
     WinWindow wnd2 = new WinWindow();
     wnd2.SearchProperties.Add(WinWindow.PropertyNames.Name, wintitle, PropertyExpressionOperator.Contains);
     wnd2.SearchProperties.Add(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains);
     wnd2.SetFocus();
     wnd2.Maximized = true;
     Console.WriteLine("got focus of window"+ wnd2.Name);
     Console.WriteLine("Button Name " + tabname);
     WinButton wbtn = new WinButton(wnd2);
     UITestControlCollection allbtns = wbtn.FindMatchingControls();
     Console.WriteLine("buttons count insiode widnows was " + allbtns.Count);
     foreach (UITestControl indbutton in allbtns)
     {
         Console.WriteLine("Found button " + indbutton.Name);
     }
     wbtn.SearchProperties.Add(WinButton.PropertyNames.Name, tabname, PropertyExpressionOperator.Contains);
     Mouse.Click(wbtn);
 }
开发者ID:prasannarhegde2015,项目名称:C-Advanced-Learning,代码行数:19,代码来源:Program.cs

示例3: AddData


//.........这里部分代码省略.........
                                        {
                                            if (_controlValue.Length > 0)
                                            {
                                                logTofile(_eLogPtah, "control value : " + _controlValue);
                                                AutomationElement udtitem = GetUIAutomationDataItem(_searchBy, _controlName, _index);
                                                SelectionItemPattern selpat = (SelectionItemPattern)udtitem.GetCurrentPattern(SelectionItemPattern.Pattern);
                                                selpat.Select();
                                                switch (_controlValue.ToLower())
                                                {
                                                    case "d":
                                                        DoubleClickControl(udtitem);
                                                        break;
                                                    case "l":
                                                        ClickControl(udtitem);
                                                        break;
                                                    case "r":
                                                        RightClickControl(udtitem);
                                                        break;
                                                    case "1":
                                                        ClickControl(udtitem);
                                                        break;
                                                }
                                            }
                                        }
                                        break;

                                    case "uiautomationspinner":
                                    case "uspinner":
                                        {
                                            if (_controlValue.Length > 0)
                                            {
                                                logTofile(_eLogPtah, "control value:" + _controlValue);
                                                AutomationElement uspinner = GetUIAutomationSpinner(_searchBy, _controlName, _index);
                                                uspinner.SetFocus();

                                            }
                                        }
                                        break;
                                    /*  case "wpflistview":
                                          wpfapp.GetWPFDataGrid(_globalWindow, _searchBy, _controlName).Focus();
                                          break; */

                                    /*  case "wpfcombobox":
                                          if (_controlValue.Length > 0)
                                          {
                                              wpfapp.GetWPFComboBox(_globalWindow, _searchBy, _controlName, _index).Select(_controlValue);
                                              uilog.AddTexttoColumn("Control Detected", "Yes");
                                              uilog.AddTexttoColumn("Action Performed on Control", "select Combo item" + _controlValue);
                                          }
                                          break; */
                                    case "uiautomationcombobox":
                                    case "ucombobox":
                                        bool itemClicked = false;
                                        AutomationElement combo = GetUIAutomationComboBox(_searchBy, _controlName, _index);
                                        try
                                        {
                                            combo.SetFocus();
                                            ExpandCollapsePattern expandPat = (ExpandCollapsePattern)combo.GetCurrentPattern(ExpandCollapsePattern.Pattern);
                                            if (expandPat != null)
                                            {
                                                logTofile(_eLogPtah, "Expanding the combobox");
                                                expandPat.Expand();
                                                Thread.Sleep(100);
                                            }
                                        }
                                        catch
开发者ID:prasannarhegde2015,项目名称:EJcehck2,代码行数:67,代码来源:UIAutomation.cs


注:本文中的WinWindow.SetFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。