<< How to record and play macros | Table of Contents | How to search and replace text in any application >>

How to create macro sequence (chain)

Hot Keyboard 2.1 presents a very useful feature: the ability to execute all macros in any menu in sequence. Thus Hot Keyboard can be used to solve much more complicated tasks (when one single macro it not enough), making Hot Keyboard a great Windows automation tool.

Getting started with macro chaining

In this section we are going to describe how to create and use a simple macro chain. The 5 minutes you spend on this topic will bring you hours of free time.

We assume that you use WinAmp to listen to the music. WinAmp does not provide us with a command to restart the current song, and there is no such Hot Keyboard macro. But we can do this via the macro chaining functionality: in order to restart a track we need to click 'stop' and then 'play'.

So we are going to put the sequence of 'stop' and 'play' commands into a single hotkey:

  1. Open the main Hot Keyboard window and click the "New Macro" button.
  2. Change the "Action type" to "Menu".
  3. Select the "Execute macros in the menu in sequence" item. Make sure that repeat count is one and the "Repeat forever" box is not checked.
  4. Assign a hotkey to the macro, give it a name (optionally), e.g. "WinAmp song restart" and click the "OK" button.

  5. In this new menu add a "Control WinAmp" macro and select the "Stop" WinAmp command. Do not name the macro and do not select a hotkey for it.
  6. Create another "Control WinAmp" macro (in the same menu) and select the "Play" WinAmp command.
  7. Delete the dummy "Menu item" item from the menu (it was created along with the menu at the fourth step). You should see the following:

Now you can restart any currently playing song with just one keystroke (Ctrl+Play/Pause)! This happens because the first macro in the menu stops WinAmp and then the second one makes it play back.

Advanced macro chaining

Here we will discuss the creation of a macro sequence in details.

For example, if you want to put a list of files from Windows Explorer into MS Word document or MS Excel spreadsheet, unfortunately there is no way to copy more than one file name simultaneously. If you select files and click "Copy", you get files in the clipboard but not file names.

This image displays what you cannot do quickly and easily unless you use Hot Keyboard:

You should probably know that when you click to rename a file in Windows Explorer, you can just copy its old name without actually renaming it. We are going to use this trick and here is the point where Hot Keyboard macro chaining helps a lot because you can copy any number of file names without any routine work!

So, to copy file names to the MS Excel spreadsheet we need to do the following steps:

  1. Select the first file
  2. Invoke the Windows Explorer "Rename" command
  3. Copy the file name to the clipboard
  4. Cancel the "Rename" command (we do not want to rename a file!)
  5. Switch to Excel
  6. Paste file name
  7. Switch back to Explorer
  8. Proceed to the next file
  9. Go to step 2 until we are done

Now we are ready to create a macro sequence that performs these actions while you can get another cup of coffee.

  1. Open the main Hot Keyboard window (e.g. click on the Hot Keyboard icon in the system tray):

  2. Click the "New macro" button. Select the "Menu" action type in the "Edit macro" dialog, assign a hotkey to the macro (e.g. "Ctrl-Alt-C"), give it a name (e.g. "Copy file names"), select the "Execute macros in the menu in sequence" option and specify the repeat count. The repeat count depends on how much files you have. In our example we have 19 files, so the repeat count is 19. Please make sure that the "Repeat forever" check box is not checked:

  3. Click the "OK" button and look what you get:

    Just ignore "Menu item" - this is a fake macro (each Hot Keyboard menu must contain at least one macro).
  4. To invoke "Rename" in Windows Explorer we should press the F2 key:
    4.1 Click the "New macro" button; name the new macro somewhat as "F2"
    4.2 Select the "Paste text" action type
    4.3 Check the "Play keys instead of using clipboard" box
    4.4 Click the ">" button located to the right of the edit field. The next menu pops up:

    4.5 Select the "Custom key" item. This brings out the following dialog:

    4.6 Press the "F2" key and click the "OK" button
    4.7 Now click the "OK" button to save the macro. So, you have two macros:

  5. Create one more "Paste text" macro the same way but name it "Ctrl-Ins" and select the corresponding (Ctrl-Insert) key combination. It will copy the file name to the clipboard.
  6. Now, create a macro for the "Escape" key to cancel the rename operation. Please note: you should select the "Escape" key from the menu:

  7. Create one more macro to simulate the "Down" key. This is necessary to proceed to the next file.
  8. Now we need to switch to Excel to paste the file name. The most convenient way to do it is to simulate the "Alt-Tab" key combination. So, create another "Paste text" macro and set it up to simulate these keys. But, there is no way to select the "Alt-Tab" as a special key! Yes, Hot Keyboard is missing this key combination from the menu and you cannot enter it as a special key. The workaround to the problem is to use its code: "${{ PKKey (04,09)}}". Enter it to the "Text to paste" field:

  9. Then we must wait until the Excel window becomes active. There is the special "Delay" macro type for this purpose. Create a new macro and select the "Delay" action type. Then, click on the "Wait for the window with title:" option and enter "Excel" in the field below:

  10. Create three more macros that will simulate the "Shift-Insert", "Enter" and "Alt-Tab" key combinations. Then create one more "Delay" macro to wait until the Explorer window becomes active (enter the folder name into the window title to wait for). At last you will get the following:

  11. Now select the first "Menu item" macro and delete it since you do not need it any longer.
  12. Close Hot Keyboard Window, open Excel, select the cell which should be the first cell for file names, open the folder where you would like to copy file names from, select the first file and press the "Ctrl-Alt-C" keys. The result of macro's work is here and we get it in less than 5 seconds!

    One more thing that should be remembered: since we use the "Alt-Tab" combination to switch between Excel and Explorer, they must be opened one after another. You should try to press "Alt-Tab" before starting the macro to make sure that windows are opened in the correct order.