AutoHotKey实现接收到其他脚本或程序的自定义消息和最多两个数字
; 示例: 此脚本能接收到其他脚本或程序的自定义消息和最多两个数字 ; (要发送字符串而不是数字, 请参阅下一个示例). OnMessage(0x5555, "MsgMonitor") OnMessage(0x5556, "MsgMonitor") MsgMonitor(wParam, lParam, msg) { ; 由于尽快返回常常很重要, 所以最好使用 ToolTip 而不是 ; 类似 MsgBox 的进行显示, 以避免阻止函数结束: ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam% } ; 下面的代码可用于其他脚本内来激发运行上面脚本中的函数: SetTitleMatchMode 2 DetectHiddenWindows On if WinExist("Name of Receiving Script.ahk ahk_class AutoHotkey") PostMessage, 0x5555, 11, 22 ; 因为上面的有 WinExist(), 所以消息被发送到 "上次找到的窗口". DetectHiddenWindows Off ; 在 PostMessage 时不能是关闭的.