My app is watching a PowerShell ISE window. I'm trying to use IUIAutomationTextRanges to categorize the text on the screen. The FindText function would be incredibly helpful, but I'm having troubles trying to get it to work with control characters (\r and \n specifically).
Here's an example: The text on the screen could be something like
PS C:\> pwd
Path
----
C:\
I tell my utility to go and look at that text. Using the TextRange::GetText() function, I see that the text looks like this:
L"PS C:\> pwd\r\n\r\nPS C:\\> pwd\r\n\r\nPath\r\n----\r\nC:\\ \r\n\r\n\r\n\r\nPS C:\\> "
which makes perfect sense.
But if I then use TextRange::FindText and send in any text that has a \r\n in it (even just the "\r\n" characters), the FindText function fails to find the text.
After much looking around and searching for answers, I am suspicioning that the problem lies in the fact that PowerShell ISE uses different escape characters for the crlf characters--specifically the
`r
and
`n
characters. But if I try FindText substituting those for the \r\n characters, it still doesn't find what it's looking for.
Does anyone have any ideas as to how I can find the TextRange that encompasses those characters?