Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SelectReplaceHighlightFormat crlf question
#1
Hi -

I wanted to replace some text in a different application with new text - everything works except for inserting a newline. What would be the way of inserting a newline (or linebreak or ...)?

str newText = F"{oldText}[13][10]More text..."
SelectReplaceHighlightFormat(windowHandle oldText newText 4 0 0 0)

Thanks

Sean
#2
Not my function, but I guess the reason can be SendMessage hwnd WM_CHAR...
Look in the topic, there is a link to updated EditControlSelectReplace version that uses EM_REPLACESEL.
#3
Yes - it's a problem with WM_CHAR and apparently this doesn't work for CRLF because it's two characters, not one.

I had some trouble with EM_REPLACESEL - I'll try it again.

I did find something that worked but I'm a bit uneasy about it. When it's iterating over the character array and using WM_CHAR to send the characters to the other app it now tests for characters 13 and 10. For 10 - it is a no-op. For 13 - it issues this command:
SendMessage hwndre WM_KEYDOWN VK_RETURN 0

This seems to be very reliable. I'm not sure I like it though.
#4
WM_CHAR 13 also works, but probably not in all windows. Works with Edit and Rich Edit controls. WM_KEYDOWN should be more universal, but then also need WM_KEYUP.


Forum Jump:


Users browsing this thread: 1 Guest(s)