Cannot get Get-UIASpinnerValue

Jun 25, 2012 at 6:14 PM

I try to get  UIASpinnerValue:

 

 

$UserLimit = Get-UIAWindow  -Name $WindowName | `
                                Get-UIASpinner -Name 'User limit' | `
                                    Get-UIASpinnerValue                    
$UserLimit                                                               

 

but always have "".

Here the whole script (it takes user limit from properties of ordinary share, so it requires at least one ordinary share with non maximum allowed users in properties).

 

Set-StrictMode -Version Latest;

ipmo d:\DDN_docs\scripts\powershell\auto\UIAutomation.0.7.11.NET35\UIAutomation.dll 
ipmo d:\DDN_docs\scripts\powershell\auto\UIAutomation.0.7.11.NET35\TMX.dll 

#[UIAutomation.Mode]::Profile = [UIAutomation.Modes]::Presentation;
[UIAutomation.Mode]::Profile = [UIAutomation.Modes]::Normal;
[UIAutomation.Preferences]::Timeout = 1000;

#Open Remote computer management
$MainWindow = Start-Process "compmgmt.msc" -PassThru | Get-UIAWindow; 

#Expand Shared Folders
$Null = Get-UIATreeItem -Name 'Shared Folders' | `
            Invoke-UIAMenuItemExpand 

#Expand Shares
$Null = Get-UIATreeItem -Name 'Shares' | `
            Invoke-UIAMenuItemExpand 

#Get Shares
$SharedItems = Get-UIADataGrid -Class 'SysListView32' | `
                    Get-UIAControlDescendants -ControlType DataItem;

foreach ($Item in $SharedItems) {
    #Write ShareItem Name    
    #Select ShareItem      
    $Null = Get-UIAWindow -ProcessId $MainWindow.Current.ProcessId | `
                Get-UIADataGrid -Class 'SysListView32' | `
                    Get-UIAControlDescendants -ControlType DataItem | `
                        Get-UIADataItem -Name "$($Item.Current.Name)" | `
                            Invoke-UIADataItemSelectItem -ItemName "$($Item.Current.Name)"  
    #Open Properies Window        
    $Null = Get-UIAWindow -ProcessId $MainWindow.Current.ProcessId | `
                Get-UIAToolBar -ControlType MenuBar | `
                    Get-UIAMenuItem -Name 'Action' | `
                        Invoke-UIAMenuItemClick | `
                            Get-UIAMenuItem -Name 'Properties' | `
                                Invoke-UIAMenuItemClick                                    
         
    #Check if Share is Special Share
    $WindowName = "$($Item.Current.Name) Properties"
    $IsSpecialShare = $False
    try {         
        #If it is a special share, close notify and properties window
        $Null = Get-UIAWindow -Name 'Shared Folders' | `
            Get-UIAButton -Class 'Button' -Name 'OK' | `
                Invoke-UIAButtonClick                               
        $IsSpecialShare = $True                
    }
    catch {
    }
    #If it is not a special share, write out its properties    
    if (!$IsSpecialShare) {                      
        $UserLimitB = Get-UIAWindow -Name $WindowName | `
                Get-UIARadioButton -Class 'Button' -Name 'Maximum allowed' | `
                    Get-UIARadioButtonSelectionItemState      
        $UserLimitB
        if ($UserLimitB -eq $True) {
            $UserLimit = 0                    
        }
        else {
            [int]$UserLimit = Get-UIAWindow  -Name $WindowName | `
                                Get-UIASpinner -Name 'User limit' | `
                                    Get-UIASpinnerValue                    
            $UserLimit                                                               
        }        
    }
    $Null = Get-UIAWindow -Name $WindowName | `
                Get-UIAButton -Name 'Close' | `
                    Invoke-UIAButtonClick                
}

 

 

 

Jun 25, 2012 at 6:59 PM

I have not tried the script yet, I've only observed what the spinner is.

I'm sitting now on Windows 8 RP and UIAutomationSpy says that this spinner supports only RangeValuePatten (not every control and in not every time a control supports all the patterns it theoretically can).

This works:

Get-UIAWindow -Name *user*prop* | Get-UIASpinner -Name *user*lim* | Get-UIASpinnerRangeValue

Jun 26, 2012 at 7:10 AM

Thanks! It works!