コード例 #1
0
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
        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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
        // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
        // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
        // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //                                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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
        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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 // 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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
        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
ファイル: PatternCmdletBase.cs プロジェクト: krukovskiy/STUPS
 //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) {
     }
 }