Reading A Custom Item's Value

Oct 24, 2013 at 12:57 AM
Hi again!

I was wondering if there's any way to read a Custom object's value. I get search for the object (and find it) based on the value through Get-UIACustom -Value <value>, and then get its name through Read-UIAControlName. There doesn't seem to be Read-UIAControlValue cmdlet though... do you have any suggestions as to how to access that value?

Thanks so much!

Oct 24, 2013 at 1:02 AM
Seems I always discover the solution shortly after posting a question here! I got the values by the following:

$dataTable | Get-UIAPatternGet

Thanks anyway (:

Oct 24, 2013 at 7:11 AM
Hi Jonathan,
UI Automation (both '1.0' and '2.0') is a complicated framework in terms of naming. Especially patterns that are classes, their lever could be a method, a property, both method and property, or even a set of methods and properties.
At the same time, Microsoft insists on naming cmdlet as Verb-Noun, its Cmdlet Design Guidelines requires the schema Verb-[YourCompany/Project]Noun.
Whereas many teams in Microsoft outside the PowerShell division don't follow these guidelines (especially, names of parameters deviate), and the PowerShell division published the first cmdlets (PS 1.0) before these guidelines were out, we amateurs struggle to follow these guidelines. :)

Here are rules we followed in naming:
  • Read- cmdlets return the properties of AutomationElement (i.e., the properties you could get via $element.Current, for example, AutomaitonId, ProcessId, AccessKey)
  • patterns are Invoke- cmdlets (Invoke-UIA[PatternName]Pattern, Invoke-UIA[PatternName]PatternSet, Invoke-UIA[PatternName]PatternGet)
  • for readability and searchability, there are cmdlets (just classes derived from Pattern- cmdlets) like Get-UIA[...]Value, Get-UIA[...]SelectionItem, etc
Regarding the topic you raised, this is definitely a bug.
Initially, the matrix which control should have such a pattern was pulled from MSDN. However, some controls in real life supported patterns that they weren't supposed to support (and a lot controls didn't support patterns they were supposed to suppport). After all, there were 'invented' 'Custom' cmdlets: they are not ties to the type (Custom), it's just for readability.

There is the Get-UIAValuePatternGet (I just renamed it to Invoke-UIAValuePatternGet), but further is a mess-up.
Some cmdlets are 'Value', same are 'Text'.
Get-UIACustomValue is now Get-UIACustomText

I'll change some names of cmdlet today and publish one more beta. All old names will be marked obsolete, not removed.
For example, the following are new names of previously Get- (now obsolete) cmdlets:

Some other cmdlets (unpopular, as I think. I, for instance, never used in practice some patterns) are separated by the action they perform:
Invoke-UIADockPattern -> Invoke-UIADockPatternSet
Get-UIADockPattern -> Invoke-UIADockPatternGet

Thank you for pointing to the naming problem!

Oct 24, 2013 at 7:25 AM
As I remember, Value cmdlets were called Text intentionally (in fact, Value is single-line text).
I'll be thinking how to make names clear.