示例#1
0
        internal void InvokeDockGet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
        {
            //dockPattern.Current.DockPosition
            try {
                DockPattern dockPattern = _control.GetCurrentPattern(DockPattern.Pattern) as DockPattern;
                if (null != dockPattern) {
                    WriteObject(this, dockPattern.Current.DockPosition);
                } else {
                    WriteVerbose(this, "couldn't get DockPattern");
                    WriteObject(this, false);
                }
            }
            catch {

            }
        }
示例#2
0
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 //writev
 internal void InvokeCollapse(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         ExpandCollapsePattern collapsePattern = _control.GetCurrentPattern(ExpandCollapsePattern.Pattern) as ExpandCollapsePattern;
         if (collapsePattern != null) {
             collapsePattern.Collapse();
             if (this.PassThru && null != (inputObject as AutomationElement)) {
                 WriteObject(this, inputObject);
             } else {
                 WriteObject(this, true);
             }
         } else {
             WriteVerbose(this, "couldn't get ExpandCollapsePattern");
             WriteObject(this, false);
         }
     } catch (Exception eCollPatternException) {
     }
 }
示例#3
0
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 //writev
 internal void InvokeToggle(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         TogglePattern togglePattern = _control.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;
         if (togglePattern != null) {
             togglePattern.Toggle();
             if (this.PassThru && null != (inputObject as AutomationElement)) {
                 WriteObject(this, inputObject);
             } else {
                 WriteObject(this, true);
             }
         } else {
             WriteVerbose(this, "couldn't get TogglePattern");
             WriteObject(this, false);
         }
     } catch (Exception eTogglePatternException) {
     }
 }
示例#4
0
 //writev
 internal void InvokeTextSet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         TextPattern textPatternSet = _control.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
         if (textPatternSet != null) {
             textPatternSet.GetSelection().SetValue(((Commands.InvokeUIATextPatternSetCommand)this).Text, 0);
             WriteObject(this, true);
         } else {
             WriteVerbose(this, "couldn't get TextPattern");
             WriteObject(this, false);
         }
     } catch (Exception eTextSetPatternException) {
     }
 }
示例#5
0
        // 20130109
        //if (this.PassThru && CheckControl(this)) {
        // 20130105
        //this.RightClick,
        //this.MidClick,
        //this.Alt,
        //this.Shift,
        //this.Ctrl,
        //this.DoubleClick,
        //this.X,
        //this.Y);
        //if (this.PassThru) {
        // 20130109
        //if (this.PassThru && CheckControl(this)) {
        // 20130105
        //this.WriteObject(this, this.InputObject);
        //this.RightClick,
        //this.MidClick,
        //this.Alt,
        //this.Shift,
        //this.Ctrl,
        //this.DoubleClick,
        //this.X,
        //this.Y);
        //if (this.PassThru) {
        // 20130109
        //if (this.PassThru && CheckControl(this)) {
        internal void InvokeInvoke(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
        {
            try {
                InvokePattern invokePattern = _control.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                if (invokePattern != null) {

                    invokePattern.Invoke();

                    if (this.PassThru && null != (inputObject as AutomationElement)) {

                        WriteObject(this, inputObject);

                    } else {

                        WriteObject(this, true);

                    }
                } else {

                    if (Preferences.PerformWin32ClickOnFail) {

                        ClickControl(this, _control, false, false, false, false, false, false, false, 0,
                                     0);

                        if (this.PassThru && null != (inputObject as AutomationElement)) {

                            this.WriteObject(this, inputObject);

                        } else {

                            this.WriteObject(this, true);

                        }
                    } else {

                        WriteVerbose(this, "couldn't get InvokePattern");

                        WriteObject(this, false);

                    }
                }
            } catch (Exception eInvokePatternException) {

                this.WriteVerbose(this, eInvokePatternException.Message + "\r\n" + eInvokePatternException.GetType().Name);
                if (Preferences.PerformWin32ClickOnFail &&
                    "ElementNotAvailableException" != eInvokePatternException.GetType().Name) {

                    ClickControl(this, _control, false, false, false, false, false, false, false, 0,
                                 0);

                    if (this.PassThru && null != (inputObject as AutomationElement)) {

                        this.WriteObject(this, inputObject);

                    } else {

                        this.WriteObject(this, true);

                    }
                } else {

                }
                // no reaction

            }
        }
示例#6
0
        // 20130109
        //if (this.PassThru && CheckControl(this)) {
        //writev
        internal void InvokeWindow(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
        {
            try {
                WindowPattern windowPattern = _control.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;
                if (windowPattern != null) {

                    // Close windowPattern.Close
                    // get windowPattern.Current.CanMaximize
                    // get windowPattern.Current.CanMinimize
                    // get windowPattern.Current.IsModal
                    // get windowPattern.Current.IsTopmost
                    // get windowPattern.Current.WindowInteractionState
                    // get windowPattern.Current.WindowVisualState
                    // set windowPattern.SetWindowVisualState(WindowVisualState.Maximized
                    // set windowPattern.SetWindowVisualState(WindowVisualState.Mini
                    // set windowPattern.SetWindowVisualState(WindowVisualState.Normal
                    // invoke windowPattern.WaitForInputIdle(int ms)

                    windowPattern.SetWindowVisualState(WindowVisualState.Minimized);
                    System.Threading.Thread.Sleep(1000);
                    windowPattern.SetWindowVisualState(WindowVisualState.Normal);
                    windowPattern.WaitForInputIdle(1000);
                    System.Threading.Thread.Sleep(1000);
                    windowPattern.SetWindowVisualState(WindowVisualState.Minimized);
                    System.Threading.Thread.Sleep(1000);
                    windowPattern.SetWindowVisualState(WindowVisualState.Normal);
                    if (this.PassThru && null != (inputObject as AutomationElement)) {
                        WriteObject(this, inputObject);
                    } else {
                        WriteObject(this, true);
                    }
                } else {
                    WriteVerbose(this, "couldn't get WindowPattern");
                    WriteObject(this, false);
                }
            } catch (Exception eWindowPatternException) {
            }
        }
示例#7
0
        // 20130109
        //if (this.PassThru && CheckControl(this)) {
        // 20130109
        //if (this.PassThru && CheckControl(this)) {
        //writev
        internal void InvokeValueSet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
        {
            try {
                ValuePattern valuePatternSet = _control.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
                if (valuePatternSet != null) {

                    this.WriteVerbose(this, "using ValuePattern");
                    valuePatternSet.SetValue(((Commands.InvokeUIAValuePatternSetCommand)Child).Text);
                    if (this.PassThru && null != (inputObject as AutomationElement)) {
                        WriteObject(this, inputObject);
                    } else {
                        WriteObject(this, true);
                    }
                } else {

                    WriteVerbose(this, "couldn't get ValuePattern. SendKeys is used");
                    _control.SetFocus();
                    System.Windows.Forms.SendKeys.SendWait(((Commands.InvokeUIAValuePatternSetCommand)Child).Text);
                    if (this.PassThru && null != (inputObject as AutomationElement)) {
                        WriteObject(this, inputObject);
                    } else {
                        WriteObject(this, true);
                    }
                }
            } catch (Exception eValueSetPatternException) {
            }
        }
示例#8
0
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 //writev
 internal void InvokeTransformRotate(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         TransformPattern transformRotatePattern = _control.GetCurrentPattern(TransformPattern.Pattern) as TransformPattern;
         if (transformRotatePattern != null) {
             transformRotatePattern.Rotate(((Commands.InvokeUIATransformPatternRotateCommand)Child).TransformRotateDegrees);
             if (this.PassThru && null != (inputObject as AutomationElement)) {
                 WriteObject(this, inputObject);
             } else {
                 WriteObject(this, true);
             }
         } else {
             WriteVerbose(this, "couldn't get TransformPattern");
             WriteObject(this, false);
         }
     } catch (Exception eTransformRotatePatternException) {
     }
 }
示例#9
0
 // 20130108
 // deleted as useless
 //                            if (this.PassThru && CheckControl(this)) {
 //                                WriteObject(this, inputObject);
 //                            //} else {
 //                            // WriteObject(this, true);
 //                            }
 //writev
 internal void InvokeSelection(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         SelectionPattern selPattern = _control.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
         if (selPattern != null) {
             System.Windows.Automation.AutomationElement[] selection = selPattern.Current.GetSelection();
             WriteObject(this, selection);
         } else {
             WriteVerbose(this, "couldn't get SelectionPattern");
             WriteObject(this, false);
         }
     } catch (Exception eSelectionPatternException) {
     }
 }
示例#10
0
 //WriteObject(this, selItemPattern1.Current.IsSelected);
 //                        else{
 //                            WriteVerbose(this, "couldn't get SelectionItemPattern");
 //                            WriteObject(this, false);
 //                        }
 //writev
 internal void InvokeSelectedItem(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         SelectionItemPattern selItemPattern1 = _control.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
         if (selItemPattern1 != null) {
             if (selItemPattern1.Current.IsSelected) {
                 WriteObject(this, InputObject);
             }
         }
     } catch (Exception eSeleItemStatePatternException) {
     }
 }
示例#11
0
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 internal void InvokeScrollItem(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         ScrollItemPattern sciPattern = _control.GetCurrentPattern(ScrollItemPattern.Pattern) as ScrollItemPattern;
         if (sciPattern != null) {
             try {
                 sciPattern.ScrollIntoView();
                 if (this.PassThru && null != (inputObject as AutomationElement)) {
                     WriteObject(this, inputObject);
                 } else {
                     WriteObject(this, true);
                 }
             } catch {
                 WriteObject(this, false);
             }
         }
     } catch {
         WriteObject(this, false);
     }
 }
示例#12
0
 //                                if (((InvokeUIAScrollPatternCommand)this).Large) {
 //                                    System.Windows.Automation.ScrollAmount.LargeIncrement = (System.Windows.Automation.ScrollAmount)10;
 //                                } else {
 //                                    System.Windows.Automation.ScrollAmount.SmallIncrement = (System.Windows.Automation.ScrollAmount)1;
 //                                }
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 internal void InvokeScroll(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         ScrollPattern scPattern = _control.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;
         if (scPattern != null) {
             try {
                 bool horizontal = ((InvokeUIAScrollPatternCommand)this).Horizontal;
                 bool vertical = ((InvokeUIAScrollPatternCommand)this).Vertical;
                 int horPercent = ((InvokeUIAScrollPatternCommand)this).HorizontalPercent;
                 int verPercent = ((InvokeUIAScrollPatternCommand)this).VerticalPercent;
                 System.Windows.Automation.ScrollAmount horAmount, verAmount = System.Windows.Automation.ScrollAmount.NoAmount;
                 horAmount = (System.Windows.Automation.ScrollAmount)((InvokeUIAScrollPatternCommand)this).HorizontalAmount;
                 verAmount = (System.Windows.Automation.ScrollAmount)((InvokeUIAScrollPatternCommand)this).VerticalAmount;
                 if ((horPercent + verPercent) > 0) {
                     scPattern.SetScrollPercent(horPercent, verPercent);
                 }
                 if (horizontal) {
                     if (horAmount > 0) {
                         scPattern.ScrollHorizontal(horAmount);
                     }
                 }
                 if (vertical) {
                     if (verAmount > 0) {
                         scPattern.ScrollVertical(verAmount);
                     }
                 }
                 if (this.PassThru && null != (inputObject as AutomationElement)) {
                     WriteObject(this, inputObject);
                 } else {
                     WriteObject(this, true);
                 }
             } catch {
                 WriteObject(this, false);
             }
         }
     } catch {
         WriteObject(this, false);
     }
 }
示例#13
0
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 //writev
 internal void InvokeRangeValueSet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         RangeValuePattern rvPatternSet = _control.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;
         if (rvPatternSet != null) {
             try {
                 rvPatternSet.SetValue(((Commands.InvokeUIARangeValuePatternSetCommand)Child).Value);
                 if (this.PassThru && null != (inputObject as AutomationElement)) {
                     WriteObject(this, inputObject);
                 } else {
                     WriteObject(this, true);
                 }
             } catch {
                 WriteObject(this, false);
             }
         }
     } catch (Exception eRVSetPatternException) {
     }
 }
示例#14
0
 // if (this.PassThru && CheckControl(this)) {
 // WriteObject(inputObject);
 //} else {
 // WriteObject(true);
 //}
 //writev
 internal void InvokeRangeValueGet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         RangeValuePattern rvPatternGet = _control.GetCurrentPattern(RangeValuePattern.Pattern) as RangeValuePattern;
         if (rvPatternGet != null) {
             WriteObject(this, rvPatternGet.Current.Value);
         }
     } catch (Exception eRVGetPatternException) {
     }
 }
示例#15
0
 //writev
 internal void InvokeToggleStateGet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         TogglePattern togglePattern1 = _control.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;
         if (togglePattern1 != null) {
             bool toggleState = false;
             if (togglePattern1.Current.ToggleState == ToggleState.On) {
                 toggleState = true;
             }
             WriteObject(this, toggleState);
         } else {
             WriteVerbose(this, "couldn't get TogglePattern");
             WriteObject(this, false);
         }
     } catch (Exception eToggleStatePatternException) {
     }
 }
示例#16
0
        internal void InvokeToggleStateSet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject, bool on)
        {
            try {
                TogglePattern togglePattern1 = _control.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;
                if (togglePattern1 != null) {
                    //bool toggleState = false;
                    if (togglePattern1.Current.ToggleState == ToggleState.On && on) {
                        // nothing to do
                    } else if (togglePattern1.Current.ToggleState == ToggleState.Off && on) {
                        togglePattern1.Toggle();
                    } else if (togglePattern1.Current.ToggleState == ToggleState.On && !on) {
                        togglePattern1.Toggle();
                    } else if (togglePattern1.Current.ToggleState == ToggleState.Off && !on) {
                        // nothing to do
                    }
            //                    if (ToggleState.On == togglePattern1.Current.ToggleState) {
            //                        toggleState = true;
            //                    }
            //                    WriteObject(this, toggleState);
                    if (this.PassThru && null != (inputObject as AutomationElement)) {
                        WriteObject(this, inputObject);
                    } else {
                        WriteObject(this, true);
                    }
                } else {
                    WriteVerbose(this, "couldn't get TogglePattern");
                    WriteObject(this, false);
                }
            } catch (Exception eToggleStatePatternException) {
                //!!!!!!!!!!!!
                if (Preferences.PerformWin32ClickOnFail) {

                    ClickControl(this, _control, false, false, false, false, false, false, false, 0,
                                 0);

                    if (this.PassThru && null != (inputObject as AutomationElement)) {

                        this.WriteObject(this, inputObject);

                    } else {

                        this.WriteObject(this, true);

                    }
                }
            }
        }
示例#17
0
 // 20130109
 //if (this.PassThru && CheckControl(this)) {
 //writev
 internal void InvokeSelectionItem(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         SelectionItemPattern selItemPattern = _control.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
         if (selItemPattern != null) {
             selItemPattern.Select();
             if (this.PassThru && null != (inputObject as AutomationElement)) {
                 try {
                     SelectionPattern selPatternTemp = _control.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
                     if (selPatternTemp != null) {
                         AutomationElement[] selection = selPatternTemp.Current.GetSelection();
                         WriteObject(this, selection);
                     } else {
                         WriteObject(this, true);
                     }
                 } catch {
                 }
             } else {
                 WriteObject(this, true);
             }
         } else {
             WriteVerbose(this, "couldn't get SelectionItemPattern");
             WriteObject(this, false);
         }
     } catch (Exception eSelePatternException) {
     }
 }
示例#18
0
 //if (this.PassThru && CheckControl(this)) {
 //    WriteObject(this, inputObject);
 //} else {
 //    //WriteObject(this, true);
 //}
 //writev
 internal void InvokeValueGet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         ValuePattern valuePatternGet = _control.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
         object result = null;
         if (valuePatternGet != null) {
             result = valuePatternGet.Current.Value;
             WriteVerbose(this, "the result is " + result);
             WriteObject(this, result);
         } else {
             WriteVerbose(this, "couldn't get ValuePattern");
             WriteObject(this, result);
         }
     } catch (Exception eValueGetPatternException) {
     }
 }
示例#19
0
 //writev
 internal void InvokeSelectionItemState(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         SelectionItemPattern selItemPattern1 = _control.GetCurrentPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;
         if (selItemPattern1 != null) {
             WriteObject(this, selItemPattern1.Current.IsSelected);
         } else {
             WriteVerbose(this, "couldn't get SelectionItemPattern");
             WriteObject(this, false);
         }
     } catch (Exception eSeleItemStatePatternException) {
     }
 }
示例#20
0
 //tableItemPattern.Current.
 internal void InvokeTableItem(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         TableItemPattern tableItemPattern = _control.GetCurrentPattern(TableItemPattern.Pattern) as TableItemPattern;
         if (tableItemPattern != null) {
             //tableItemPattern.Current.
         }
     } catch (Exception eTableItemPatternException) {
     }
 }
示例#21
0
 // textPattern.DocumentRange.// temporarily
 //string resultText = string.Empty;
 //writev
 internal void InvokeTextGet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         TextPattern textPatternGet = _control.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
         if (textPatternGet != null) {
             int textLength = ((Commands.InvokeUIATextPatternGetCommand)this).TextLength;
             if (((Commands.InvokeUIATextPatternGetCommand)this).VisibleArea) {
                 TextPatternRange[] textRanges = textPatternGet.GetVisibleRanges();
                 for (int i = 0; i < textRanges.Length; i++) {
                     WriteObject(this, textRanges[i]);
                 }
             } else {
                 string resultText = textPatternGet.DocumentRange.GetText(textLength);
                 WriteObject(this, resultText);
             }
         } else {
             WriteVerbose(this, "couldn't get TextPattern");
             WriteObject(this, false);
         }
     } catch (Exception eTextGetPatternException) {
     }
 }
示例#22
0
        internal void InvokeDockSet(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject, DockPosition position)
        {
            try {
                DockPattern dockPattern = _control.GetCurrentPattern(DockPattern.Pattern) as DockPattern;
                if (null != dockPattern) {
                    dockPattern.SetDockPosition(position);

                    if (this.PassThru && null != (inputObject as AutomationElement)) {
                        WriteObject(this, inputObject);
                    } else {
                        WriteObject(this, true);
                    }
                } else {
                    WriteVerbose(this, "couldn't get DockPattern");
                    WriteObject(this, false);
                }
            }
            catch {

            }
        }
示例#23
0
 //gridItemPattern.Current.
 // not yet implemented
 // GridItemPattern giPattern =
 // _control.GetCurrentPattern(GridItemPattern.Pattern)
 // as GridItemPattern;
 //
 // giPattern.Current.
 internal void InvokeGridItem(System.Windows.Automation.AutomationElement _control, AutomationElement inputObject)
 {
     try {
         GridItemPattern gridItemPattern = _control.GetCurrentPattern(GridItemPattern.Pattern) as GridItemPattern;
         if (gridItemPattern != null) {
             //gridItemPattern.Current.
         }
     } catch (Exception eGridItemPatternException) {
     }
 }