Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 897

AutoHotkey v2的標準輸出如何執行?

$
0
0

AutoHotkey v2腳本如何把輸出寫到標準輸出(stdout)呢?寫資料到stdout只要把輸出檔名寫成字串星號就可以,例如:

FileAppend "Hello", "*"

但執行時會產生下列錯誤:
gh|700

查看了說明文件後,有兩個作法暫時解決,方法二比較簡單,只要將內容再傳給另一個程式(用Pipe)就可以了。

透過副檔名關聯的方法執行仍然有相同錯誤,但以AutoHotkey64.exe執行檔直接執行再 Pipe 給 more 就成功了。

gh|700

AutoHotkey.chm 說明文件裡的標準輸出說明:

Standard Output (stdout): Specifying an asterisk (*) for Filename causes Text to be sent to standard output (stdout). Such text can be redirected to a file, piped to another EXE, or captured by fancy text editors. For example, the following would be valid if typed at a command prompt:
"%ProgramFiles%\AutoHotkey\AutoHotkey.exe" "My Script.ahk" >"Error Log.txt"

However, text sent to stdout will not appear at the command prompt it was launched from. This can be worked around by 1) compiling the script with the Ahk2Exe ConsoleApp directive, or 2) piping a script's output to another command or program. For example:
"%ProgramFiles%\AutoHotkey\AutoHotkey.exe" "My Script.ahk" |more
For /F "tokens=*" %L in ('""%ProgramFiles%\AutoHotkey\AutoHotkey.exe" "My Script .ahk""') do @Echo %L
Specifying two asterisks (**) for Filename causes Text to be sent to the standard error stream (stderr).

##

您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 897

Trending Articles