AHK通讯 CMD Lua IPC
- 命令行/命令提示符/command-line/CMD/Console中:
- ErrorLevel是变量名,存储被调用命令的返回值。
- 可以%变量名%(%ErrorLevel%)获取变量值。
- Autohotkey/AHK中,使用变量名ExitCode向调用者传递数值。
ExitCode:An integer (i.e. negative, positive, or zero) that is returned to its caller when the script exits. This code is accessible to any program that spawned the script, such as another script (via RunWait) or a batch (.bat) file.
- 参见:Return variable to command-line?,How do I return a value from an AutoHotkey script?
- CMD中命令/程序/批处理的输出,默认,输出至CMD的显示。
- ..输出可>(重定向)至文件,可|(管道)至下一级命令/程序/批处理的输入。
- 或构造WScript.Shell对象,通过对象的属性/方法获取..输出。
- 参见:Capture CMD output with AutoHotkey
- AHK中 Append,% text,* , FileOpen("*", "w `n") 可将变量text的值发送至标准输出/stdout,但不会显示在CMD中。
text sent to stdout will not appear at the command prompt it was launched from. This can be worked around by piping a script's output to another command or program.
-
- 在SciTE4AutoHotkey中执行脚本可以输出至Output窗口。
- 在CMD中执行脚本无输出(ErrorLevel非0或抛出异常)。
- 在CMD中执行脚本,在 Append 前,使用 DllCall("AttachConsole", "int", -1) 。
- 但“输出”的内容不同于显示(如echo):
- 在输入符号>之后;
- 不可方向键导航,编辑删除;
- 不影响其后用户输入的命令行。
- 以上,在命令行中使用 my.ahk | more 可“正常”输出。
- 但“输出”的内容不同于显示(如echo):
- 参见:Return text to command prompt - Ask for Help - AutoHotkey Community,Run AHK script from cmd and return output - Ask for Help - AutoHotkey Community
- Print(), PrintDebug(), Stdout() & Stdin() - AutoHotkey Community
- 使用 FreeConsole , AllocConsole , AttachConsole , CONOUT$
- Print(), PrintDebug(), Stdout() & Stdin() - AutoHotkey Community
;CONOUT$ is a special file windows uses to expose attached console output
- 貌似[批处理]命令才能与CMD交互,显示信息;程序只能返回 ExitCode。
- 参见:Run external program, feed it input, take its output - Ask for Help - AutoHotkey Community
NamedPipe, Standard Input, Standard Output(FileAppend)
- 参见:[module, ahk & dotNet] IPC 2.6 - Scripts and Functions - AutoHotkey Community(自AutoHotkey Archives)
WM_COPYDATA应用
- 参见:Client & Server Script for TCP/IP Network Communication - Scripts and Functions - AutoHotkey Community
- 参见:ObjRegisterActive - AutoHotkey Community
- IPC, COM objec, ProgID, CLSID
- Alien:
Alien is a Foreign Function Interface (FFI) for Lua
-
Pipes, redirection, and standard out and in
-
echo 的标准输出是命令行,但可以通过管道(改变以)连接到其他命令( tr , unzip , curl ,wget , mail )
-
- add to an existing file (using >>) or create a new file (using >)
- The introduction of standardized streams represented a major breakthrough in the computer field
- c# - Create 2 FileStream on the same file in the same process - Stack Overflow
- system.io.fileshare , system.io.memorymappedfiles
- 问题:
- live output
- 返回数据至CMD,如同chcp
- 进程的输入、输出?
- 以上,或 AllocConsole 或 AttachConsole 设置了脚本的stdout。可否手动设置以连接不同的程序。
- 进程间通信/IPC。
- WM_COPYDATA,Sockets。
- 参见Lua/AHK socket tcp telnet - 萝卜L - 博客园
- 搜索:ahk command line return value,ahk live output,ahk stream communicate using stdout live,ahk communicate lua - Google 搜索,ahk lua popen - Google 搜索,IPC stdout ahk - Google 搜索,lua IPC ahk strokesplus - Google 搜索,lua "autohotkey" "strokesplus","lua" WM_COPYDATA - Google 搜索,lua 5.3 alien - Google 搜索,pipe stdin stdout - Google 搜索,Console Handles - Windows Console | Microsoft Docs(参见另一篇随笔stream file 文件 数据流),file stream open share - Google 搜索
use Spy++ to examine the message being sent, and use Windows Debugger Tools, throwing a message box before sending the message
acSendString(lpData, dwData, handle, x, y)
IPC module / USB connection dll used for IR remote / logitech Keyboard
- 搜索"lua" (get OR receive OR monitor) "windows" message WM_ - Google 搜索无果。
即,Lua无法获取消息(如WM_COPYDATA之消息)。 - 在找lua&ahk的wrap或者binding。
参见比较久远的尝试,I wrote a LuaJIT FFI binding for AutoHotkey_H - AutoHotkey Community、AHK + LUA Interop (stdlib), proof of concept - Scripts and Functions - AutoHotkey Community
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?