Simulate User Input in 3rd Party Application

2019-09-19 13:38发布

Not sure where to start with this one ...

I'm thinking about creating a small little application to automate some repetitive text entry. I would like to be able to define snippets of text, and inject them into other applications when I want. What would be the best way to approach this problem? I have stumbled across UI Automation, as well as SendKeys. Any suggestions?

I don't mind if I have to "point out" the input controls for the application (like how Mac's native screenshot tool asks you to click on the window you want to capture). For instance, I could select the snippet of text in this application, then click on my other application's text input box, and that would somehow let the first application get a handle for the input's control to then simulate input.

Also, would there be any way to programmatically "submit" that form of controls once filled in? I come from a web design background, so a lot of this native application development is new to me.

Sorry if this is a vague question, I'm just not sure where to even start with this ...

2条回答
何必那么认真
2楼-- · 2019-09-19 14:29

I've successfully used the CBT "Computer Based Training" API functions in C++ for this to create self-running demos that inject windows messages, including mouse clicks, text, etc.

Here's a link that describes a macro record/playback that should get you started.

http://www.codeproject.com/KB/applications/winmacro.aspx

I think the old VB SendKeys function uses these CBT Journal Playback functions.

查看更多
一纸荒年 Trace。
3楼-- · 2019-09-19 14:31

You could try AutoIt.

查看更多
登录 后发表回答