SendKeys

G

Guest

I read that SendKeys should not be used because if the user changes focus at
the time the sendkeys sends the key(s), they could be redirected to another
application or window. This is the same or keybd_Event and it was suggested
to use the API SendInput. I use SendKeys.SendWait(). Should I change to use
the SendInput API which is going to requre a lot more programming?
 
H

Herfried K. Wagner [MVP]

Dennis said:
I read that SendKeys should not be used because if the user changes focus
at
the time the sendkeys sends the key(s), they could be redirected to
another
application or window. This is the same or keybd_Event and it was
suggested
to use the API SendInput. I use SendKeys.SendWait(). Should I change to
use
the SendInput API which is going to requre a lot more programming?

I think the answer to your question is strongly related to where and why you
are sending input to a window. Could you describe the scenario in more
detail?
 
G

Guest

I have a rich text box that I have the user type into with buttons that he
can select which add text at the caret point. For example, he can type "abc"
then click a button and it will add some text, i.e., "abc{TITLE}".
 
H

Herfried K. Wagner [MVP]

Dennis said:
I have a rich text box that I have the user type into with buttons that he
can select which add text at the caret point. For example, he can type
"abc"
then click a button and it will add some text, i.e., "abc{TITLE}".

To do that, I would set the 'SelectionText' property of the control to
"{TITLE}".
 
G

Guest

Thanks (it's SelectedText though, not SelectionText). Works great. Just for
future reference, what do you think about using SendKeys.SendWait for sending
keys? Would using the SendInput API function be better in some or all
situations?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top