抱歉,对 Applescript 进行编码是新手,因此不胜感激。
我正在尝试创建一个脚本,将剪贴板中的文本粘贴到 telnet 命令的中间。输出需要在同一个窗口中,看起来像这样:
I8,A,001
Q102,024
q448
rN
S4
D15
ZT
JF
O
R71,0
f100
N
B264,65,2,UA0,2,4,56,B,"100000000045"
A203,82,2,1,2,2,N,"xxxxx"
P1
第 13 行引用的 12 位数字是我需要插入的。
这是我到目前为止编写的代码,但它不起作用:
tell application "Terminal"
do script "telnet xxx.xxx.xx.xx xxxx"
delay 1
do script "I8,A,001" in window 1
do script "Q102,024" in window 1
do script "q448" in window 1
do script "rN" in window 1
do script "S4" in window 1
do script "D15" in window 1
do script "ZT" in window 1
do script "JF" in window 1
do script "O" in window 1
do script "R71,0" in window 1
do script "f100" in window 1
do script "N" in window 1
do script "B264,65,2,UA0,2,4,56,B,\""
tell application "System Events"
tell application process "Terminal" in window 1
keystroke "v" using {command down}
end tell
keystroke "\""
keystroke return
do script "\"A203,82,2,1,2,2,N,\"xxxxx\""
do script "P1"
keystroke return
end tell
end tell
一旦我尝试使用命令 V 粘贴,它就会退出终端窗口并将剪贴板上的内容粘贴到脚本上,它不会让我告诉它留在终端窗口 1 中。