开发者

C#: An alternative to SendKeys outside of a form?

I am trying to send a string to a textbox control in an external application by using the keybd events api, however I don't particularly want to 开发者_JS百科send each character to a string using this method and would know SendKeys would be appropriate.

I have gained focus in the text box by sending a Ctrl+L command via keybd events (an application shortcut).

However, i'm executing this code from within a class and therefore the windows.forms namespace is not applicable and I cannot access SendKeys...

Are there any alternatives? (Do PostMessage and SendMessage have any application here?)

Thanks!


There isn't any reason why you couldn't use SendKeys from a class. Just be sure to put the using System.Windows.Forms directive at the top of the file. Add the reference if this class lives in its own class library project.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜