2

I am trying to get the value in the spinner out of it to check that it was entered correctly through an AutomationElement in C#. What I am currently doing is attempting get it out through the TryGetCurrentPattern as shown below, however it only returns 0.0 for the value despite having a different value (such as 1) displayed in the spinner.

if (spinnerAutoEle.TryGetCurrentPattern(RangeValuePattern.Pattern, out pattern)) 
{
    var valueRangePattern = (RangeValuePattern)pattern;
    return valueRangePattern.Current.Value;
}

Also, I noticed when looking at the valueRangePattern.Current the field for maximum and minimum values are always 0.0 as well despite the spinner being limited. I have also tried getting a ValuePattern out of the spinner but it will not go into the if statement if (spinnerAutoEle.TryGetCurrentPattern(ValuePattern.Pattern, out pattern)). Is it possible to get the numerical value out of the Spinner in this way?

KRJuggling
  • 75
  • 8

3 Answers3

1

Windows Forms does not support Automation for spinner controls (NumericUpDown). Actually, it supports but it gives you wrong values. Use a library like FlaUI to get the value of the spinner. It is done with Win32 messages (SendMessage WM_GETTEXT to the edit window inside the spinner). Best regards.

0

I would suggest inspecting the structure of the UI Automation tree for the spinner using the Inspect tool shipped with the Windows SDK. I have found that in certain instances (for example some Winforms implementations of spinner controls), and depending on whether you are using the managed or native version of UI Automation, the spinner control might be constructed from an edit box and two buttons in the automation tree where the actual value is accessed through the edit box and the Value pattern. I realize this is a very late answer but perhaps it can help someone.

o_weisman
  • 804
  • 7
  • 19
  • after handler get the spinner main windows title as you get the main windows title using process id samilarly soinner have id so convert handle to element or use that id to get mein win text that will give you spinner text , the process for main win title is based on id actually spinner have id too and commonsense is itys text is title – nouman arshad Jun 28 '16 at 10:29
0

spinner id to handler after handler get the spinner main windows title as you get the main windows title using process id samilarly soinner have id so convert handle to element or use that id to get mein win text that will give you spinner text , the process for main win title is based on id actually spinner have id too and commonsense is itys text is title

nouman arshad
  • 453
  • 5
  • 15