Sometimes It’s Just Easier To Set Up a Temporary Hotkey for Inserting Text in Documents, Web Pages, or Forms, Plus a Quick Reminder of a Couple of Cool Clipboard-like AutoHotkey Apps (ClipJump and PhraseOMatic)
I’ve spent the past couple of weeks dealing with the new ComputorEdge AutoHotkey Download portal (which is the old “Free AutoHotkey Scripts and Apps for Learning Script Writing and Generating Ideas” page). I’ve added links for direct download of all the scripts, plus AHK-file-only links which, since AHK files contain pure text, avoid Windows download security issues.
Regardless of the format, adding numerous links to any Web page often becomes tedious. To lighten the load I used AutoHotkey in two different ways—both of which I pass on as a tip (one in this blog and the other, more complex, solution next time). Both techniques address the same link creation problem. The first is an easy solution which reduces the drudgery by half. The second more advanced tip (next time) offers more power, but requires a little higher level of AutoHotkey expertise.
New to AutoHotkey? See “Introduction to AutoHotkey: A Review and Guide for Beginners.”
The software I use for editing and updating Web pages includes a standard pop-up window for creating links. I highlight the link text, then click the link icon in the toolbar. A window opens where I enter the URL of the download file. The problem is that while the page URL is constant (http://www.computoredge.com/AutoHotkey/Downloads/), the filename changes for each link.
I could use the Windows Clipboard, but, since it only copies one item at a time, I would be forced to first copy the page URL, paste it into the field, then copy the file name and paste it onto the end of the page URL. While this is much better than typing the entire link each time (and more accurate than keyboarding), AutoHotkey offers better methods for getting the job done.
First, I present a couple of more permanent solutions developed by other AutoHotkey code writers. Then, I offer my simple, short script for instantly creating a Hotkey for any phrase or text.
Clipboard-like (Only Better) AutoHotkey Apps—First ClipJump
ClipJump, written and maintained by Avi Aryan, represents a major upgrade over Windows Clipboard. This super Clipboard adds multiple clips and many other cool features for anyone needing more options in their copy-and-paste operations.
My original article about ClipJump can be found in the ComputorEdge Archive (the theme article in this PDF of ComputorEdge), but I stumbled upon archive.is where someone had the foresight to make a copy of the original.
After first reviewing ClipJump, I continued using it for quite a while, but eventually found that I didn’t need quite that much power. However, if your job often demands the copying and moving or the reinserting of numerous Clipboard items, then I recommend you take a close look at ClipJump.
I later discovered another powerful AutoHotkey app written by Douglas Abernathy called PhraseOMatic which works well for formatting text, adding repetitive links, and inserting standard boilerplate. (Download the original PhraseOMatic article “A Cool Little App for Inputting Common Phrases” in PDF format.)
When I ran ComputorEdge as an online magazine, I used PhraseOMatic for inserting standard formatting and my most used links. I even added it to the second special mousebutton (XButton2) for quick access.
PhraseOMatic does not attempt to emulate the Windows Clipboard in the same manner as ClipJump, but works with a data file you set up yourself. If you’re looking for powerful copy-and-paste operations, then choose ClipJump. For those standard insertions you need all the time, PhraseOMatic does the job. Of course, there is no reason why you can’t use both.
While I find both of these AutoHotkey apps tremendously useful, I opted for a simpler solution for my problem. I eliminated the need for one of the cut-and-paste operations by using my simple InstantHotkey script to setup a temporary Hotkey which inserts the download page URL into any field or document.
InstantHotkey AutoHotkey Script
Sometimes it’s just easier to take temporary measures. Admittedly, I should probably add the download site URL to the PhaseOMatic data file. Afterall, I’m likely to need it over and over again. But, for now, I merely popped open InstantHotkey and entered a new Hotkey combination and the download site’s URL. My main AutoHotkey script sets up a Hotkey for running the compiled version of the script (InstantHotkey.exe) at boot up:
With this approach, the combination CTRL+ALT+H launches a new InstantHotkey with each Hotkey activation. (The #SingleInstance off directive allows the running of multiple instances of the same app.)
Wow! This is a tip within a tip! This line of code demonstrates another way around the problem of merging different AHK scripts. If you want to add another AutoHotkey script to your primary script, rather than perilously breaking apart the auto-execute section and the other critical pieces of the script, then placing them at the appropriate spot in the main script, merely compile the add-on script into an executable file (EXE) and create a Hotkey in the main script for launching it with the Run command.
As seen in the image above, I assigned CTRL+O as the Hotkey combination. Use any combination you like, but try not to interfere with other Hotkeys or Windows shortcuts that you might need. (The Windows Key , #, won’t work as part of a Hotkey combination since the Gui, Add, Hotkey command does not accept it.) Enter your insertion text into the next field and click “Set Key Combo.”
When I created the new links, I only needed to use the Windows Clipboard once for unique filename for each link . I copied the name of the AHK file to the Windows Clipboard (CTRL+C), opened the “Add Link” window , inserted the download page URL (CTRL+O), then pasted the name of the file (CTRL+V). This technique cut the editing time in half. Rather than two, I only used one Windows Clipboard copy-and-paste for each link.
Even running the two previous, more powerful, AutoHotkey apps (ClipJump and PhraseOMatic) requires at least one copy-and-paste operation for each unique filename. My simple InstantHotkey approach saved just as much time.
A More Permanent Solution
If this were something I needed to do everyday, then I would write a short automated script for the entire task.
- The AutoHotkey routine copies the selected text to the Windows Clipboard.
- The AutoHotkey Send command issues the shortcut key combination to open the Link window.
- Send the download page URL to the appropriate field.
- Send the Clipboard contents to the same field.
- Close (“OK”) the Link window.
With this script I would only need to select the filename in the program and hit the assigned Hotkey combination. The AutoHotkey routine turns the selected text into a hot link to the download page.
(I don’t plan to bog myself down with this type of link creation, so I didn’t write the script. But, the script is not unlike the ChangeCase.ahk routines, except the script requires the adding of the window opening shortcut and cursor navigation to the correct fields.)
InstantHotkey is a temporary solution anyone can use. But it’s still a little tiresome. What’s needed is a quick-and-dirty solution which creates all the links simultaneously. Let’s get rid of all Windows Clipboard copy-and-paste operations! That calls for a Regular Expression (RegEx)—the best timesaver yet.
Although not for the faint of heart, the tip in the next blog demonstrates how to use Ryan’s RegEx Tester as a quick-and-dirty solution for creating multiple unique links in one pass.