如何使用鼠标指针和键盘快捷键捕获文本?
我想使用 C# 或 java 使用鼠标指针和键盘快捷键从打开的窗口捕获文本 (如 babylon ),所以 我需要知道什么以及如何实施?
我需要使用哪些库?或者我可以使用 winapi 吗?
i want to capture text from opened windows using mouse pointer and keyboard shortcut using C# or java
( like babylon ) , so
what i need to know and how to implement it ?
what are the libraries i need to use ? or can i use winapi ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用脚本语言创建您想要执行的操作的草稿。
您可以使用AutoHotKey或AutoIt等程序。请注意,您包含自动录音机,它可以为您提供基本草稿。您可以将这些脚本编译为可执行文件,并使用 Shell Execute 从 C# 或 Java 调用它们 ( c#; java< /a> (exec) ) 或作为新进程运行 ( c#; java(流程构建器))。后者是优选的。
下面是一个示例,说明如何将“暂停”键映射到从屏幕上选择文本的功能,然后使用 AutoHotKey 将其复制并粘贴到另一个位置。
Shift + left click
用于背景选择所有文本。请注意,这是最简单的示例,不会通过其指针调用窗口并使用固定位置(并且仅适用于一种分辨率)。使用Java。
Java 包含
Robot
类来执行此操作。您可以自行定制如何使用 Robot,但一般方式:
java2s 上的更多 Robot 示例:( 链接 )
使用 C#。
有无数解决方案。只需google“测试自动化 c#" 或 "间谍 c#"。
MSDN:SendKeys
MSDN:如何:在代码中模拟鼠标和键盘事件
您可以使用windows API,但是需要一些繁琐的工作。你不想这样做,你真的不想这样做,但如果你这样做,那么一定要检查一下:
我建议您使用
Use a scripting language to create a draft of what you want to do.
You can use programs like AutoHotKey or AutoIt. Note, that thy include auto recorder, that gives you a basic draft. You can compile those scripts to executables, and call them from C# or Java using Shell Execute ( c#; java (exec) ) or run as new Process ( c#; java (process builder) ). Latter is preferred.
Here is an example of how to map a key 'pause', to a function that selects a text from screen, copy's it and pastes it in another place using AutoHotKey.
Shift + left click
is used on background to select all the text. Note, that this is simplest example and does not invoke window by its pointer and uses fixed locations (and work only for one resolution).Using Java.
Java contains
Robot
class, to do this.You can tailor how you use Robot yourself, but general way:
More Robot examples at java2s: ( link )
Using C#.
There are myriad of solutions. Just google "Test Automation c#" or "spy c#".
MSDN: SendKeys
MSDN: How to: Simulate Mouse and Keyboard Events in Code
You can use windows API, but it requires some tedious work. You don't want to do that, you really don't, but if you do, then definitely check out:
I recommend you use inputsimulator. Example: