【问题标题】:autohotkey Restricting a script to only run a designated programautohotkey 限制脚本只运行指定的程序
【发布时间】:2015-08-14 10:52:28
【问题描述】:

我将 Teraterm 用于我的终端程序。我的问题是我不能只在我在 teraterm 程序中运行我的脚本。如果我在不同的应用程序中,有没有办法让它进入 teraterm?

脚本效果很好,请将它分享给任何使用 teraterm 的人。

我们总是使用显示在窗口标题中的相同服务器 ip,它包含 10.155.3.8。该文本始终在标题中。

如何让它只在 teraterm 中执行。我知道这是一个非常简单的问题,但我花了几天时间环顾四周,任何帮助将不胜感激。

如果您有任何基本教程网站,我将不胜感激。 我是一个编程新手。

::ttwa:: ; change teraterm window name to current device or state.
SetTitleMatchMode, 2     ;// allow partial window title matches
#IfWinActive, 156.99.121.173,  156.99.121.173

send !e
sleep 10
send s
send {enter 100}
sleep 100
Send {click 3}
send !s
sleep 10
Send w
sleep 10
send %clipboard%
sleep 100
;send {backspace}
sleep 10
send {enter}
send !e s {enter}
send {enter 10}
Clipboard :=
return

【问题讨论】:

  • 有没有办法自动热键识别 teraterm 或 putty。

标签: autohotkey


【解决方案1】:

有几种方法:

  1. 分配一个热键来启动脚本:

    ^+F1::
    .... send stuff
    ....
    return
    
  2. 等待 teraterm 窗口出现 (WinWait) 或激活 (WinWaitActive):

    winwait, teraterm ; change to the actual window qualifications
    .... send stuff
    ....
    return
    
  3. 从您的脚本运行 teraterm,因此您将运行脚本图标而不是直接运行 teraterm:

    run teraterm ; change to the actual path
    winwait, teraterm ; change to the actual window qualifications
    .... send stuff
    ....
    return
    

【讨论】:

  • SetTitleMatchMode, 2 #IfWinActive, Tera Term ::srtg:: ;show run tunnel-group shpix send sh run tunnel-group {space 3} #IfWinActive return
  • 有没有办法去 gosub a ttrw: SetTitleMatchMode, 2 ; ttrw lable 仅在 tera term #IfWinActive Tera Term 中运行
  • 请澄清您的问题。
【解决方案2】:

嗯。在我看来,您的脚本中似乎已经有了答案。

来自此处的文档:#IfWinActive

创建上下文相关的热键和热字串。这样的热键执行 根据窗口的类型不同的操作(或根本没有) 是活动的或存在的。

您只需让您的脚本执行该要求,而不是按需要执行的顺序。

SetTitleMatchMode, 2
#ifWinActive, 156.99.121.173,  156.99.121.173 ;Assuming this is correct
::ttwa:: ; change teraterm window name to current device or state.
send !e
sleep 10
send s
send {enter 100}
sleep 100
Send {click 3}
send !s
sleep 10
Send w
sleep 10
send %clipboard%
sleep 100
;send {backspace}
sleep 10
send {enter}
send !e s {enter}
send {enter 10}
Clipboard :=
return

关于进一步了解AutoHotkey的建议,我强烈建议从官方Tutorial开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多