3

I'm trying to write a script that will do one of the following based on hotkey commands using one autohotkey script: a) open a specific (1 out of 10) vnc connection accross a network, b) open 5 (5 out of 10) separate vnc connections accross a network, and c) open all 10 vnc connections accross a network. Each iteration of the script opens a separate connection to the host machine in question. I can get item "c" to work on command, however items (a) and (b) will open more connections than I need, and Im trying to end each hotkey with something like end or exit at the end of its respective script. I have listed the code for items (a) and (b) below as those are the ones that this applies to:

Item (a) and part of Item (b) [for Item (b) this is repeated x times]

^!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
    }

For Item (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
     }

How can i force the hotkey to end when it finishes a given task, but keeps going given what I have provided?

2
  • 1
    Your question is a bit unclear. When do you want it to stop? Do you only want it to stop if a certain condition is met? Commented Jun 11, 2013 at 13:07
  • I would like for the script to end after (a) finishes and after (b) finishes. The script contians 13 separate hotkeys which do the same thing, however 3 of them perform the same task x times with the 13th one opening 10 vnc connections with a two second delay in between each run script as denoted by the {} in the second code block indicated above, which also applies to item (b) which has an associated hotkey to initiate the second group of five connections Commented Jun 11, 2013 at 21:51

1 Answer 1

5

You're looking for the Return command to stop the execution of your hotkeys. See the piece of code below. I've created a function which you can use to call a specific machine without so much code repetition. This way you will get the specific machines you desire.

#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
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.