Nov 22, 2013 at 10:53 AM
Edited Nov 22, 2013 at 11:03 AM
The Get-UIAControlClick cmdlet needs a handle.
How to get a handle of a thing that has no handle?
There are two ways:
1) if your label is recognizable as AutomationElement, you could simply run the following:
Get-UIAWindow ..... | Get-UIA[your static label] | Invoke-UIAControlClick -DoubleClick;
Even if your control does not have handle, the Invoke-UIAControlClick cmdlet gets its parent, or its 'grandparent', etc, until it gets a control with handle. After that, the cmdlet calculates X and Y and hits to the place your handless control is.
2) If your label is not recognizable as AutomationElement, you need to get an upper element (on what your label is painted), move the cursor and use the same cmdlet:
Get-UIAWindow ..... | Get-UIA[the parent of your static label] | Move-UIACursor -X ... -Y ... | Invoke-UIAControlClick -DoubleClick;
Here could be a problem: if you selected its further ancestor, on which its parent is placed, and both parent and further ancestor have handles, the cmdlet hits ancestor, not the parent. This could be heard as a glass sound (as when you click onto that is not
considered to be clickable like a window under a modal window).
Shortly, you need to choose exactly the control with handle on that your label is painted, and hit there.
Sometimes, an app has its own opinion about what the double click is. Double click is usually two clicks with WM_MOUSEMOVE in between (as spy++ says). However, automated double click on calc.exe is not the same as you perform it manually (your hand is simply
too slow for calc :)).
Start-Process calc -PassThru | Get-UiaWindow | Get-UiaButton 5 | Invoke-UiaControlClick -DoubleClick;
If you perform a double click on a button, you've got two digits in the text box.