Quantcast
Channel: Windows Desktop Development for Accessibility and Automation forum
Viewing all 585 articles
Browse latest View live

UI Automation using Windows Service

$
0
0
I was using UI automation using windows forms, it was working fine , but when i am trying to use it with Windows Service , i cannot access automation element .Please suggest what i am missing

Need a sample on how to select a tab item from tab control using UI Automation APIs

$
0
0

I'm currently working with a WPF application in which I need to select items from a tab control. I can't find any articles about the tab control.  When I used the SelectionItemPattern it tells me that it doesn't support it.

I can find the tab control  fine, however, I can't do anything with it.  Treewalker return null when I use it.  I just need a simple sample on how to use it since I can't find it in Microsoft documentation (e.g. select item from tab control and click it or select it.)

I'm at a loss for a lack of information on tab control and the info available seems to be old or misleading. Any pointers toward it is appreciated.


NR

How to set value under the "TextPattern" by AutomationElement technique?

$
0
0

Some widget of the software I want to control by AutomationElement technique owns only TextPattern and ScrollPattern. But I want to change its value by program not inputing mannually. So, how could I implement this function?

The supported patterns is as attachment!

How to get current user logon and logout time in windows 7 using VB.NET or C#

$
0
0

I want get current user logon and logout time and print them it to a Textbox. I am using VB.NET and SQL Server. Please guide me how to get this.

Thanks in advance.

Unable to Show Tree in Inspect

$
0
0

Hello,

I'm using Windows 8.1 and Inspect.exe to view UI control information.  However, I'm unable to see the option to show the UI tree in inspect.  I can only see the currently focused item.

Is there an issue with Inspect in Windows 8.1 that prevents this?  I've tried running Inspect in admin mode as well with no luck.


Get bounding rectangle for treeitem including icon

$
0
0

Hi,

I have a requirement of getting bounding rectangle for a treeitem in a treeview. The treeview control used is a VB6 treeview (TreeView20WndClass).

I came across TVM_GETITEMRECT. But, it says that if wParam is true, it will get rectangle only for the text part and if it is false, it will get rectangle for the entire line that the item occupies in the tree-view control.

But, I want to get the rectangle the region including both text part and icon. I am unable to find a way for this.

Or is it possible to get the rectangle for the icon?

Any help is highly appreciated.

Regards,

kvk1985

UIAComWrapper vs UIAutomationClient for GUI Automation

$
0
0

Hi,

I am working on 2 different projects related to GUI Automation. One uses UIAutomationClient & the other one uses UIAComWrapper. I have a vague idea that both provide accessibility to controls based on Interop.UIAutomationClient but there are few differences. For example, in my experience UIAComWrapper is very fast and it also provides ability to access controls through legacy IAccessible. There are other differences too that are related to control patterns. Sometimes UIAutomationClient gives different patterns for the same control while UIAComWrapper provides different patterns.

Here I may also add that I use UIVerify to analyze controls, which internally uses UIAComWrapper to access controls. I work on VS 2010. I want more information about UIAComWrapper. I see so much material about UIAutomationClient on internet but so little about UIAComWrapper. I need to know why/how UIAComWrapper is so much faster than UIAutomationClient while they internally use the same assembly? Why do these 2 show different control patterns? Why was UIAComWrapper introduced when UIAutomationClient was already there to serve the purpose.

Can anyone elaborate the differences between these 2 while they are used for the same purpose i.e. GUI Automation? or suggest me some helpful links.?

Question about the update "Windows 10 Version 1607"

$
0
0

Hello, 

I am a developer of this device mentioned in the page below.

https://www.plus-vision.com/en/product/copyboard/n20/feature04.html#save02

We built the solution, called "Direct computer connection",
by that, our device can present the scanned image as a file in mass disk of the connected host PC in usb mass storage protocol.

But, after completing the latest windows update, "Windows 10 Version 1607 for x64-Based Systems",
We found the windows stopped fetching the latest sector data of mass disk, after our device informed the host PC with "NOT_PRESENT" in "TEST UNIT READY"command response once. (Before that update, it works well!)

Can you reply me asap?

Thanks


エイジ


Automation

$
0
0

I have to find all the controls in a specific url and print the name property of those controls.

                                                   

  [TestMethod]
        public void CodedUITestMethod1()
        {
            Console.WriteLine("inside method1");
            BrowserWindow browser = BrowserWindow.Launch(new Uri("https://technet.microsoft.com/en-us/"));
            browser.Maximized = true;

            Playback.Wait(10000);


            PropertyCondition autoid =new PropertyCondition(AutomationElement.AutomationIdProperty, "megabladeMainMenu");
            AutomationElement control = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, autoid);

            Properties(control);
        }


            private void Properties(AutomationElement element)
            {
            Console.WriteLine("inside method2");
            if (element == null)
            {
                Console.WriteLine("null");
                return;
            }

              AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(element);

                while (elementNode != null)
                {

                    string controlName = (elementNode.Current.Name == "") ? "Unnamed Control" : elementNode.Current.Name;
                    string autoIdName = (elementNode.Current.AutomationId == "") ? "No AutomationID" : elementNode.Current.AutomationId;
                    Console.WriteLine("Name Property : " + controlName);
                    Console.WriteLine("automation Id : " + autoIdName);
                } 

            elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
            Properties(elementNode);
        }

Tried it this way but the automation element being passed is recognized as null.Can I get any suggestions regarding this problem.

UI automation

$
0
0

I have to find all the controls in a specific url and print the name property of those controls.

                                                  

  [TestMethod]
        public void CodedUITestMethod1()
        {
            Console.WriteLine("inside method1");
            BrowserWindow browser = BrowserWindow.Launch(new Uri("https://technet.microsoft.com/en-us/"));
            browser.Maximized = true;

            Playback.Wait(10000);


            PropertyCondition autoid =new PropertyCondition(AutomationElement.AutomationIdProperty, "megabladeMainMenu");
            AutomationElement control = AutomationElement.RootElement.FindFirst(TreeScope.Subtree, autoid);

            Properties(control);
        }


            private void Properties(AutomationElement element)
            {
            Console.WriteLine("inside method2");
            if (element == null)
            {
                Console.WriteLine("null");
                return;
            }

              AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(element);

                while (elementNode != null)
                {

                    string controlName = (elementNode.Current.Name == "") ? "Unnamed Control" : elementNode.Current.Name;
                    string autoIdName = (elementNode.Current.AutomationId == "") ? "No AutomationID" : elementNode.Current.AutomationId;
                    Console.WriteLine("Name Property : " + controlName);
                    Console.WriteLine("automation Id : " + autoIdName);
                } 

            elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
            Properties(elementNode);
        }

Tried it this way but the automation element being passed is recognized as null.Can I get any suggestions regarding this problem.

Exception with UIA

$
0
0

Environment: Win10 Pro 64bit

Screenario:

   When a pop up shows up , our tool tries to click the 'Yes' button by Invoke(). However , sometimes , a exception is thrown up .I want to know the root cause and the solution !!!

My workaround:

   I wrapped my code with CacheReuest , this helps no exception is thrown , however , the button maybe  not be clicked.

Thrown exception:

Abort Automation , reason : Operation is not valid due to the current state of the object. for developers : at MS.Internal.AutomationProxies.Misc.ThrowWin32ExceptionsIfError(Int32 errorCode) at MS.Internal.AutomationProxies.Misc.SendInput(Int32 inputs, INPUT& ki, Int32 size) at MS.Internal.AutomationProxies.Input.SendKeyboardInputVK(Int16 vk, Boolean press) at MS.Internal.AutomationProxies.Misc.SetFocus(IntPtr hwnd) at MS.Internal.AutomationProxies.WindowsButton.Invoke() at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at MS.Internal.Automation.UiaCoreApi.CheckError(Int32 hr) at TVSUPluginAutomation.testcases.tvsu_triggerPopup_base.clickPopWin(Int32 timeout) at TVSUPluginAutomation.testcases.tvsu_DownloadAndInstall_multi14_1installedFirst.InstallRemander() at TVSUPluginAutomation.testcases.tvsu_DownloadAndInstall_multi14_1installedFirst.run() at TVSUPluginAutomation.testcases.baseClass.executeTestCase()

My Code:

 protected AutomationElement findPopWinX(int timeout = 5000)
        {
            using (new IdentityScope("", CommonClass.configXML.SelectSingleNode("/root/LocalServer/User").InnerText, CommonClass.configXML.SelectSingleNode("/root/LocalServer/Pass").InnerText, LogonType.NewCredentials, LogonProvider.WinNT50))
            {
                DateTime now = DateTime.Now;
                int _timeout = timeout;

                while (DateTime.Now < now.AddMilliseconds(_timeout))
                {
                    List<AutomationElement> all = new List<AutomationElement>();
                    AutomationElementCollection elementCollection = AutomationElement.RootElement.FindAll(TreeScope.Children, Condition.TrueCondition);
                    AutomationElement ok = null, cancel = null, staticText = null;
                    foreach (AutomationElement child in elementCollection)
                    {
                        try
                        {

                            ok = child.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "1"));
                            cancel = child.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "2"));
                            staticText = child.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "65535"));
                            if (child.Current.ClassName == "#32770" && ok != null && cancel != null && staticText != null)
                            {
                                return child;
                            }

                        }
                        catch (Exception)
                        {

                        }
                    }
                }
            }
            return null;
        }
        protected bool clickPopWin(int timeout = 5000)
        {
            AutomationElement a = findPopWinX();
            if (a==null)
            {
                return false;
            }
            AutomationElement ok = a.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "1"));
            if (ok==null)
            {
                return false;
            }
            InvokePattern pat = ok.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
            pat.Invoke();
            return true;
        }


Marcus.



How to check whether IRawElementProviderFragmentRoot is in playback mode or assertion mode?

$
0
0

Currently i am working on providing the Coded UI support for my custom control. I have implemented the Coded UI implementation as like the steps provided in the following link, https://blogs.msdn.microsoft.com/winuiautomation/2010/05/10/custom-ui-automation-providers-in-depth-part-1/ https://blogs.msdn.microsoft.com/winuiautomation/2010/06/04/custom-ui-automation-providers-in-depth-part-4/

I can achieve the Coded UI assertion. But i cannot able to check whether the provider is in play back mode or not? Because i have the following situation. i.e. if it is in playback mode i want to perform one operation otherwise default one,

if(Playback mode)
want to do some operationelsedo the default

This is the part of my code and my needed place to check that condition,

publicclassCustomUIAProvider:IRawElementProviderFragmentRoot,ISelectionProvider,IScrollProvider{publicIRawElementProviderFragmentNavigate(NavigateDirection direction){switch(direction){caseNavigateDirection.NextSibling://here i want to check my condition}}}

The below code is the root code for triggering the provider for Coded UI assertion and playback, this code has been written incontrol WndProc method,

protectedoverridevoidWndProc(refMessage msg){switch(msg.Msg){case WM_GETOBJECT:
                msg.Result=AutomationInteropProvider.ReturnRawElementProvider(Handle, msg.WParam, msg.LParam,this.Provider);return;}}

Case The case is that Navigate method is always triggering for both the operations (Playback mode and Assertion mode). So i cannot find the scenarios.

Can anyone help on this?


Regards, Neelakandan

Why can not assert my custom control while using VS2015 enterprise?

$
0
0

I have implemented the Code-UI support for my custom control. It was working fine in vs2012,vs2013 but i can not assert my control when using the VS2015 enterprise version. 

The below code is the root code for triggering the provider for Coded UI assertion and playback, this code has been written in control WndProc method,

protected override void WndProc(ref Message msg)
{
    switch (msg.Msg)
    {
          case WM_GETOBJECT:
                msg.Result = AutomationInteropProvider.ReturnRawElementProvider(Handle, msg.WParam, msg.LParam, this.Provider);
                return;
    }
}

i have found some differentiation from the msg.WParam and msg.LParam value between VS2013 and VS2015 which was mentioned below,

 

VS2013                                                 VS2015

WParam – 1480                                      WParam – {0}

LParam – {0}                                          LPara – {-25}

Is this wrong, Please suggest me the solution.

Thanks,

Mohanraj G 

Why InvokeRequired property value differed between VS2012 and VS2013?

$
0
0

I am developing UI automation for my control. The below code working fine in VS2012.

MyControl.PointToClient(p);

But this code not working in VS2013. It was throws an following exception 

Also i have used the below code to Invoke the control

public new Point PointToClient(Point p)
{
   if (MyControl.InvokeRequired)
   {
       pointToClientCallBack ptcb = new pointToClientCallBack(PointToClient);
       GetWindow().Invoke(ptcb, new object[] { p });
   }
   return MyControl.PointToClient(p);
}
delegate Point pointToClientCallBack(Point p);

after i invoked my control, InvokeRequired property is in true.

So, can you please suggest me the right way to solve this problem.

Thanks,

Mohanraj G.

SmartBeart Test Complete automation software cannot locate Unique AutomationProperties.AutomationID.

$
0
0

Dear Team,

   The matter is that, we've developed an WPF application on MVVM design pattern using prism.  Our entire application has been developed .We needed to create the Test Automation framework for which we need to set a unique, permanent and stable property value  as identifier for all the objects (overall static and dynamic objects) so that the Automation framework doesn't brake over time in long run.

 Now, we don't want to use the default "Name" dependency property as object's unique identifier. So, we looked up to initialize cum bind the required "AutmationProperties.AutomationID" from XAML which is general in such automation scenarios. But, turns out that SmartBear's "Test Complete", test automation tool allowed to be used, is not able to locate any property with this name at all which we can configure as unique id.

   Finally, I found a dependency property "Uid" in place of "AutmationProperties.AutomationID" to serve the purpose which the tool is able to locate. 

Would you be kind enough to advise if we are in right direction!What options do we have to effectively populate this property for each and every object in all the Views that we have other than from XAML as we have near around  50-60 Screens.

If it proves any help, I am using VS 2013 Ultimate Edition.  



What is the inteded logic of TreeWalker with condition?

$
0
0

I observe an illogical behavior of TreeWalker for filtered trees. Let us assume that we try to find all buttons in some application window using walker.  So we create a walker with the corresponding condition, something like:

VARIANT prop;
prop.vt = VT_I4;
prop.lVal = UIA_ButtonControlTypeId;
CComPtr<IUIAutomationCondition> type_condition_ptr;
automation_ptr->CreatePropertyCondition(UIA_ControlTypePropertyId, prop, &type_condition_ptr);

CComPtr<IUIAutomationTreeWalker> walker_ptr;
automation_ptr->CreateTreeWalker(type_condition_ptr, &walker_ptr);

And then walk the sub-tree for app's window (wnd_ptr):

IUIAutomationElement* child_ptr;
walker_ptr->GetFirstChildElement(wnd_ptr, &child_ptr);
while (child_ptr != NULL) {    walker_ptr->GetNextSiblingElement(child_ptr, &child_ptr);
}

On practice GetNextSiblingElement() returns not only buttons of wnd_ptr's subtree, but buttons from some other (not all) apps sub-trees.

It seems that the hierarchical structure of UI tree is not counted. Is that intended logic or bug? If it is the intended logicthen how to use the walker with the condition filter for sub-trees?


Is it OK to use multiple threads to work with UI Automation Client API?

$
0
0

UI Automation documentation recommends to "make all UI Automation calls from a separate thread" (seehttp://msdn.microsoft.com/en-us/library/ee671692%28v=VS.85%29.aspx)

However it says nothing about whether it should be the only thread or multi-threaded access is also possible and safe.

So, I have 3 questions:

1. Is it OK to access UI Automation API from multiple threads? Can I for example get a IUIAutomationElement in one thread and pass it to another thread for further usage?

2. Is it OK to access UI Automation from STA threads as longs as they do not attempt to add/remove event handlers? MSDN says "Using the Single-threaded Apartment (STA) model can cause problems such as preventing clients from removing event handlers from the thread.". Does this mean other uses of STA threads are OK?

3. If the above usage is safe which cases result in performance penalty?

Thanks.

Get image of ListItem with UI Automation

$
0
0

Hi!

I have a list of WinListItem. Each item has a text and an image. The image represents a green check or a red cross. I need to access to this image to know if the UI is displayed in concordance with business logic.

I have tried to get it via ControlViewWalker because from what I understand from the documentation, it should be available then as a child of the item.

public void A()
  {
     var listItem = UIMapOptionsActivationWnd.UIFirstListItem.NativeElement as AutomationElement;
     WalkControlElements(listItem);
     // result?
  }

  private List<AutomationElement> result = new List<AutomationElement>();

  private void WalkControlElements(AutomationElement rootElement)
  {
     AutomationElement elementNode = TreeWalker.ControlViewWalker.GetFirstChild(rootElement);
     while (elementNode != null)
     {
        result.Add(elementNode);
        WalkControlElements(elementNode);
        elementNode = TreeWalker.ControlViewWalker.GetNextSibling(elementNode);
     }
  }

But I am stuck here. Result has no element. I have tried the code using the WinList as the rootElement and it works to get the ListItems.

I also tried with a RawViewWalker, without more success. I will take any other solutions too!

Thanks!


Windows 10 - Set tablet buttons to perform certain tasks.

$
0
0

Hi Sir,

In Control Panel > Hardware and Sound > Tablet PC Settings > Set tablet buttons to perform certain tasks.

There is error popup message but we really install button drivers on the system. There are 3 buttons on the tablet. (Power button, volume up and volume down). "Set tablet buttons to perform certain tasks" looks to launch Apps by buttons but how to do that? Is there any documents or reference link describes how to do that?

Thanks.


Terence Liu

Why code generation was failed when save the designer level changes?

$
0
0

I had two collection one is column and another one is BaseStyleCollection and I had two forms. One form inherited another form.

public partial class Form2 : Form1
{

   public Form2()
   {
       InitializeComponent();
   }
}

public partial class Form1
{

   public Form1()
   {
       InitializeComponent();
   }
}

I have added my custom control in Form1 and add the (BaseStyles and columns) for my control in designer and BaseStyles and ColumnCollection attribute was DesignerSerializationVisibility.Contentand both are derived fromIList.

. Now i try to edit the childform in designer level and save the changes, i got the following error message



Stack trace for Columns collection:


Stack trace for BaseStyle:

This kind of changes occurring when make the changes for my control and save the changes in Form2 .

please suggest me. Why this kind of changes occurs? Is this reason for the exception? 

Thanks in advance,

Mohanraj G



Viewing all 585 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>