使用 autohotkey 脚本将 cmd.exe IDE 的内容提取到文本文件
我正在尝试使用 autohotkey 脚本(即一个 test.ahk)将 cmd.exe IDE 的内容提取到文本文件,其编写如下所示:
WinGetText, text, "C:\WINDOWS\system32\cmd.exe"
FileAppend, %text%, C:\ThreePartition\ACTUAL.txt
我无法提取内容。 谁能建议正确的提取方法?
I am trying to extract the contents of cmd.exe IDE to a text file using autohotkey scripts ie one test.ahk and its written as shown below:
WinGetText, text, "C:\WINDOWS\system32\cmd.exe"
FileAppend, %text%, C:\ThreePartition\ACTUAL.txt
I am not able to extract the contents. Can anyone please suggest the correct way to do the extraction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Window Spy 不显示 CMD 窗口的文本元素 - 您所看到的不一定是您能得到的:)
您可以做的是模拟“全选”和“粘贴”命令,然后使用剪贴板内容。
The Window Spy shows no text elements for CMD windows - what you see is not necessarily what you can get :)
What you can do is to simulate the Select All and Paste commands, and then use the clipboard contents.
我不相信您可以在不使用 DllCall 直接读取进程内存的情况下提取 cmd 窗口的内容。
如果您只需要 CLI 命令(例如 Grep 或 AWK)的输出,则通过 run 命令使用 stdout 应该可以。 但老实说,我不再依赖 AHK,因为这种东西太笨重了。
http://www.autohotkey.com/docs/commands/Run.htm。
编辑评论:
您想要的是可行的,但解决方案完全取决于您的 IDE 的工作方式。 它有哪些构建项目所特有的行为? 如果它生成临时文件,您可以使用 AHK 子例程重载“构建”按钮,该子例程监视这些文件是否存在,然后检查输出可执行文件的修改日期以查看构建是否成功。 如果 IDE 在构建时更改其窗口标题,则同样的解决方案也适用。 聪明一点。 :)
如果做不到这一点,您可能必须安装消息挂钩。
I don't believe you can extract the contents of a cmd window without somehow using DllCall to read the process memory directly.
If you just want the output of a CLI command such as Grep or AWK, using stdout via the run command should work. Honestly though, I stopped relying on AHK because this sort of thing is just too clunky.
http://www.autohotkey.com/docs/commands/Run.htm.
Edit for comments:
What you want is doable, but the solution depends entirely on how your IDE works. What behavior does it have that's unique to building a project? If it makes temp files, you can overload your "build" button with an AHK subroutine that watches for the existence of those files, and then checks the modified date of the output executable to see if the build succeeded. The same kind of solution works if the IDE changes its window title when building. Be clever. :)
Failing that, you might have to install a message hook.