I am developing an application to automates other applications. I want to be able to determine whether the textbox element on the "other" application is readonly or not. In case of one-line textboxes MS UI Automation framework provides ValuePattern and I can get readonly attribute from that pattern, but when we have multiline textbox, there is no ValuePattern available and I only can access TextPattern and ScrollPattern. How can I get the readonly attribute from multiline textbox using MS UI Automation?
P.S. I've tried to find something about this on the internet but it seems that there are no so much information about MS UI Automation in general.
The TextPattern
pattern provides a way to check ranges for read-only status. Checking the full DocumentRange
tells you if the entire textbox is read-only:
TextPattern textPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
object roAttribute = textPattern.DocumentRange.GetAttributeValue(TextPattern.IsReadOnlyAttribute);
if (roAttribute != TextPattern.MixedAttributeValue)
{
bool isReadOnly = (bool)roAttribute;
}
else
{
// Different subranges have different read only statuses
}