Support Portal

for ProcessRobot and WinAutomation

Start a new topic

Obtaining Window's Toggle Value

Dear All,

I am trying to automate the Windows Privacy Settings. The windows is composed of  several options with a toggle 0n/0ff button


Using WinAutomation UISpy I am able to get to the control type button and it's class and ID, however WinAutomation is unable to obtain the Toggle Value which is stored according to inspector as: Toggle.ToggleState: On (1) or Toggle.ToggleState: Off (0)

 WinAutomation UISpy gets me this far:


> window[class="Windows.UI.Core.CoreWindow"][name="Settings"] > group[class="LandmarkTarget"]:eq(0) > pane[class="ScrollViewer"][id="ItemsControlScrollViewer"] > group[class="GroupItem"][name="Change privacy options"] > button[class="ToggleSwitch"][id="SystemSettings_Privacy_AdvertisingIdEnabled_ToggleSwitch"][name="Let apps use advertising ID to make ads more interesting to you based on your app activity (Turning this off will reset your ID.)"]


Whereas in Inspector I get the following data:

Name:	"Let apps use advertising ID to make ads more interesting to you based on your app activity (Turning this off will reset your ID.)"
ControlType:	UIA_ButtonControlTypeId (0xC350)
LocalizedControlType:	"toggle switch"
BoundingRectangle:	{l:942 t:526 r:1337 b:600}
IsEnabled:	true
IsOffscreen:	false
IsKeyboardFocusable:	true
HasKeyboardFocus:	false
ProcessId:	8936
RuntimeId:	[2A.B80A8A.4.31]
AutomationId:	"SystemSettings_Privacy_AdvertisingIdEnabled_ToggleSwitch"
FrameworkId:	"XAML"
ClassName:	"ToggleSwitch"
IsControlElement:	true
IsContentElement:	true
ProviderDescription:	"[pid:8936,providerId:0x0 Main(parent link):Unidentified Provider (unmanaged:Windows.UI.Xaml.dll)]"
IsPeripheral:	false
LiveSettingProperty:	Off (0)
IsPassword:	false
IsRequiredForForm:	false
IsDataValidForForm:	true
ClickablePoint:	{x:980 y:584}
Culture:	1033
Orientation:	0
PositionInSet:	4294967295
SizeOfSet:	4294967295
Level:	4294967295
LandmarkType:	none (0x0)
IsDialog:	false
HeadingLevel:	HeadingLevel_None (0x138B2)
LegacyIAccessible.ChildId:	0
LegacyIAccessible.DefaultAction:	"Press"
LegacyIAccessible.Description:	""
LegacyIAccessible.Help:	""
LegacyIAccessible.KeyboardShortcut:	""
LegacyIAccessible.Name:	"Let apps use advertising ID to make ads more interesting to you based on your app activity (Turning this off will reset your ID.)"
LegacyIAccessible.Role:	push button (0x2B)
LegacyIAccessible.State:	checked,focusable (0x100010)
LegacyIAccessible.Value:	""
Toggle.ToggleState:	On (1)



How can I obtain/format the values in inspector settings  of a certain controller in order to incorporate them manually in the selector?

I would for example like to obtain the following value: 

  1. Toggle.ToggleState: On (1) (which I would like to use for an IF condition and subsequent mouse click)
  2. BoundingRectangle: {l:942 t:526 r:1337 b:600} (cooridnates which I would like to use for the mouse click coordinates)


I would really appreciate any input that would enable me to get the specific selector's value using Get Details of Element in Window action.

I couldn't find any specific instructions on how to do this and the article "Using Inspect.exe to access UI elements that WinAutomation is not able to "see" couldn't provide the necessary information regarding this particular scenario.

Thank you in advance.

1 Comment

There is a pseudo-solution...

You can use the Inspect tool during runtime, which means the following steps should work:

1. Have the Watch Cursor mode active.

2. Click Element on the button, with offset x: 20, y: -20 from bottom left corner.

3. Get Details of Element on the inspection pane

4. Parse out the Toggle.ToggleState value.

5. If the value is not as it should be, repeat Step 2 once.

Let me know if it is helpful :]

Login or Signup to post a comment