AutoHotKey Scripting Basics: The Run Command
I have already used the Run command in two of my previous posts: Launching Google and Launching Calculator using AutoHotKeys.
The Run command is used to launch a program, document, URL, and even shortcuts.
Most of you must already be familiar with the Windows version of the Run Command. If you are not, try this:
Click on Start –> Run
A Run command window will now open; just type in the name of the program or complete URL of the Web site you want to open. For documents, however, you need to specify the complete path.
For e.g. C:\My Documents\Meghna.doc
Note: The Windows Operating System treats Notepad as a Program and Microsoft Word as a document. Thus, typing Microsft Word in the Run command box will give you an error and instead you need to specify the complete path for it.
AutoHotKeys allows you to have lot more fun with the Run command. You can launch multiple programs or Web sites at once, choose how they open, specify working directories, pass parameters etc.
Let me just start off with showing you one of its simplest uses: Launching multiple programs at once.
#m::
Run Notepad
Run www.yahoo.com
Run Calculator
Run www.google.com
return
The above script will open the notepad, calculator and the home pages of both yahoo and google as soon as you press the Windows+m keys on your keyboard. Since AutoHotKeys executes scripts top-down, the programs will open in that order, so you can of course write them in order of your own preference.
The above script is an example of a multi-command line script and that is why we have put the commands beneath the hotkey definition. This improves readability and makes it easier to modify the scripts later, especially for larger scripts.
The Return command will exit the script (you will understand its real importance later). In single-line scripts, using the return command was unnecessary as exit was implied.
Let’s see another variation of the above script:
#m::
Run Notepad, , max
Run www.yahoo.com
Run Calculator
Run www.google.com, , min
return
Now when you use this script, the Notepad will open maximized on your screen, while the google browser window will be minimized.
Meghna
Related posts:
AutoHotKey Scripting Basics - The RunWait Command
The RunWait command is an extension of the Run command. However, as the name suggest,...
AutoHotKey script; Launching Calculator
In my opinion, one of the most useful applications included with Windows is their calculator....
AutoHotkey – Display an on-screen message
When I use AutoHotkey to run background tasks, download files and prepare backups, I want...
AutoHotkey – One-Click Auto Shutdown
Have you ever had to wait in front of your computer before it shuts down?...
Tags: AutoHotKey Scripts
June 13th, 2009 at 10:32 pm
[...] - AutoHotKey Scripting Basics: The Run Command saved by seung122009-06-05 - 拟于本周末建立AutoHotkey专版 saved by Rrezz2009-06-02 - [...]