我正在尝试编写一个脚本,该脚本将使用一个autohotkey脚本基于热键命令执行以下操作之一:a)在网络中打开特定的(1/10)vnc连接,b)打开5(5) 10)网络中单独的vnc连接,以及c)打开网络中的所有10个vnc连接。脚本的每次迭代都会打开与相关主机的单独连接。我可以使用项目“c”来处理命令,但是项目(a)和(b)将打开比我需要的更多的连接,并且我试图结束每个热键的结尾或者在各自的脚本末尾退出。我列出了下面(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
}
如何在完成给定任务时强制热键结束,但是根据我提供的内容继续保持热销?
答案 0 :(得分:3)
您正在寻找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
}
}