3

我正在尝试编写一个脚本,该脚本将使用一个自动热键脚本根据热键命令执行以下操作之一:a)在网络上打开一个特定的(10 个中的 1 个)vnc 连接,b)打开 5(10 个中的 5 个) ) 跨网络分离 vnc 连接,以及 c) 打开跨网络的所有 10 个 vnc 连接。脚本的每次迭代都会打开一个与相关主机的单独连接。我可以让项目“c”在命令上工作,但是项目 (a) 和 (b) 将打开比我需要的更多的连接,并且我试图在其各自脚本的末尾用 end 或 exit 之类的东西结束每个热键。我在下面列出了项目 (a) 和 (b) 的代码,因为这些代码适用于:

(a) 项和 (b) 项的一部分 [对于 (b) 项,重复 x 次]

^!c::
   {
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
     WinWaitActive, VNC Viewer
      {
       Send Frankenstien-SubSystem-1
       Send {enter}
      }
     WinWaitActive, Authentication Credentials
      {
       Send {Shift Down}
       Send {Tab}
       Send {Shift Up}
       Send <username>
       Send {Tab}
       Send <password>
       Send {enter}
      }
     Sleep 2000 [Only used for items (b) and (c) ;<== End here for Item (a) only
    }

(b) 项

#a::
   {
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
     WinWaitActive, VNC Viewer
      {
       Send Frankenstien-SubSystem-1
       Send {enter}
      }
     WinWaitActive, Authentication Credentials
      {
       Send {Shift Down}
       Send {Tab}
       Send {Shift Up}
       Send <username>
       Send {Tab}
       Send <password>
       Send {enter}
      }
     Sleep 2000 [Only used for items (b) and (c)
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
     WinWaitActive, VNC Viewer
      {
       Send Frankenstien-SubSystem-2
       Send {enter}
      }
     WinWaitActive, Authentication Credentials
      {
       Send {Shift Down}
       Send {Tab}
       Send {Shift Up}
       Send <username>
       Send {Tab}
       Send <password>
       Send {enter}
      }
     Sleep 2000 [Only used for items (b) and (c)
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
     WinWaitActive, VNC Viewer
      {
       Send Frankenstien-SubSystem-3
       Send {enter}
      }
     WinWaitActive, Authentication Credentials
      {
       Send {Shift Down}
       Send {Tab}
       Send {Shift Up}
       Send <username>
       Send {Tab}
       Send <password>
       Send {enter}
      }
     Sleep 2000 [Only used for items (b) and (c)
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
     WinWaitActive, VNC Viewer
      {
       Send Frankenstien-SubSystem-4
       Send {enter}
      }
     WinWaitActive, Authentication Credentials
      {
       Send {Shift Down}
       Send {Tab}
       Send {Shift Up}
       Send <username>
       Send {Tab}
       Send <password>
       Send {enter}
      }
     Sleep 2000 [Only used for items (b) and (c)
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
     WinWaitActive, VNC Viewer
      {
       Send Frankenstien-SubSystem-5
       Send {enter}
      }
     WinWaitActive, Authentication Credentials
      {
       Send {Shift Down}
       Send {Tab}
       Send {Shift Up}
       Send <username>
       Send {Tab}
       Send <password>
       Send {enter}
      }
      ;END Here; <== Item (b) twice
     }

如何在完成给定任务时强制热键结束,但根据我提供的内容继续运行?

4

1 回答 1

5

您正在寻找Return停止执行热键的命令。请参阅下面的代码。我创建了一个函数,您可以使用它来调用特定机器,而无需太多代码重复。这样,您将获得您想要的特定机器。

#a::VNC("Frankenstien-SubSystem-1", "myuser", "mypass")

#b::
    VNC("Frankenstien-SubSystem-1", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-2", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-3", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-4", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-5", "myuser", "mypass")
    Return

#c::
    VNC("Frankenstien-SubSystem-1", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-2", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-3", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-4", "myuser", "mypass")
    VNC("Frankenstien-SubSystem-5", "myuser", "mypass")
    ; ... and so on
    Return


VNC(machine, user, pw)
{
    Run, vnc-E4_6_3-x86_win32_viewer.exe, C:\Program Files (x86)\RealVNC\VNC4 Viewer
    WinWaitActive, VNC Viewer
    {
        Send % machine
        Send {enter}
    }
    WinWaitActive, Authentication Credentials
    {
        Send {Shift Down}
        Send {Tab}
        Send {Shift Up}
        Send % user
        Send {Tab}
        Send % pw
        Send {enter}
    }
    Sleep 2000
    }
}
于 2013-06-12T18:20:16.017 回答