在第三方应用程序中模拟用户输入
不知道从哪里开始......
我正在考虑创建一个小型应用程序来自动执行一些重复的文本输入。我希望能够定义文本片段,并在需要时将它们注入到其他应用程序中。解决这个问题的最佳方法是什么?我偶然发现了 UI 自动化以及 SendKeys。有什么建议吗?
我不介意是否必须“指出”应用程序的输入控件(就像 Mac 的本机屏幕截图工具要求您单击要捕获的窗口一样)。例如,我可以选择此应用程序中的文本片段,然后单击其他应用程序的文本输入框,这会以某种方式让第一个应用程序获得输入控件的句柄,然后模拟输入。
另外,一旦填写完毕,是否有任何方法可以以编程方式“提交”该形式的控件?我有网页设计背景,因此很多本机应用程序开发对我来说都是新的。
抱歉,如果这是一个模糊的问题,我只是不知道从哪里开始......
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 ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试 AutoIt。
You could try AutoIt.
我已经成功地使用 C++ 中的 CBT“基于计算机的训练”API 函数来创建自运行的演示,注入 Windows 消息,包括鼠标单击、文本等。
这是一个描述宏记录/回放的链接,应该获取你开始了。
http://www.codeproject.com/KB/applications/winmacro.aspx
我认为旧的 VB SendKeys 函数使用这些 CBT Journal Playback 函数。
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.