.. _15-Subroutines: 15. Subroutines ============================================================================== User-defined commands can be used as subroutines by including them inside other commands or hotkey definitions. Here's an example. Suppose you have a hotkey that sends a keystroke to a window, waits 500 milliseconds, and sends the keystroke again. It would look like this:: That definition is pretty short, so it works fine. But suppose you want the hotkey to perform the same action in five different windows? The definition would be very long. A subroutine can help by making it shorter. To do this, create a user-defined command:: And define the hotkey like this:: Subroutines on remote PCs In the previous example, all the windows are on the local PC where you press the hotkey. But what if some of the windows are on remote PCs? In that case, performance is improved if you load the subroutine on the remote PCs and call it from the local PC. To do this, remove SendPC from the command (it will be included in the hotkey instead) and then load the command definition in hotkey files on every PC:: // NEW VERSION // LOAD THIS ON ALL PCs Now we define the hotkey like this:: Technical note You can use a hotkey as a subroutine too. Call it with DoHotkey. This can be useful because some keywords can be included in hotkeys but not in commands. Related topics Command CommandLine ThirdPartyCommandLine