HOME
TOPICS
ABOUT ME
MAIL

 
A macro program records your keystrokes and presses them for you when you type a trigger key.
  technofile
Al Fasoldt's reviews and commentaries, continuously available online since 1983

Make your own editing functions using a macro program


June 4, 2000

By Al Fasoldt
Copyright ©2000, Al Fasoldt
Copyright ©2000, The Syracuse Newspapers

   A few months ago I realized I needed a "portable" HTML editor -- a Web-page editor that would follow me around, so to speak, as I worked in different programs on my computer. It would be instantly available whether I was doing e-mail or jotting down notes or working in my heavy-duty word processor.
   No such thing existed, so I had to create it myself.
   It didn't take long. I'll tell you how you can do it, too.
   Here's what I wanted. Let's say I'm typing along in my word processor and I wanted to make some HTML (hypertext markup language) code out of a Web address. I wanted to be able to turn that address into HTML code right then and there. Kaboom! It's done.
   And I wanted to be able to do that even if I wasn't using my favorite word processor. How about when I was just using my little text editor? My e-mail program?
   You get the point.
   Luckily, HTML code is mostly a bunch of brackets with strange little words stuck here and there. That means you can turn normal text into HTML relatively easily. You just put brackets and strange little words in front of stuff and so on.
   If you think I'm trying to dumb down HTML code, I'm not. Most of it is just the way I'm telling it to you. It's just a bunch of angle brackets and little commands that look like words or plain old letters.
   So if I want to turn "Hello!" into HTML code, I have to put a command in front of the word and after the word. I can do that manually, of course, but I needed to do it more quickly. I needed an automatic method. I needed something that would change normal text into HTML code with the press of a key.
   Or maybe the press of a couple of keys all at once. If I wanted to turn something bold, I could press Alt and B together. Or if I wanted to turn a Web address into a hyperlink, I could press Alt and Shift and H.
   I did everything I wanted using a macro program.
   A macro program records your keystrokes and presses them for you when you type a trigger key or hotkey. I've used macro programs for years and wouldn't want to do any computing without them. I type Alt-Shift-A and my macro program spits out my full name, for example.
   For this little project, any decent macro program would have worked, but I chose one called "khotkeys" that runs under Linux. (It's part of the K Desktop Environment, or KDE, a Linux graphical user environment.) If I'd wanted to do this under other operating systems, I could have used a macro program designed for Windows or the Mac.
   But I didn't just want a program to type characters for me. Getting "Al Fasoldt" to appear when I type Alt-Shift-A is a no-brainer. How about turning my name into a hypertext mail link? Or turning the name of a Web site into a real Web address?
   That takes a little knowledge of the way your operating system works. In particular, you need to know how your computer's operating system does cutting and pasting.
   Cutting and pasting? Am I nuts? Weren't we talking about a macro thingamabob that does stuff for you?
   Yes, cutting and pasting. It's elegantly simple. My macro program doesn't just type characters. It types commands. And those commands can easily include the ones for copying and pasting.
   Under Windows and under KDE in Linux, cutting and pasting work the same way from the keyboard. Ctrl-X cuts (deletes and places in the clipboard) something that is selected and Ctrl-V pastes it. (The Mac does this, too, using the Apple key instead of the Ctrl key.)
   Forget about the macro editor for a minute. Let's say you want to put a word in parenthesis. Here's the easiest way, using cutting and pasting. You select the word. Then you cut it so that the word is in the clipboard but not in your text. Then type an opening parenthesis. Then paste the word back in. Then type a closing parenthesis.
   Notice how all of those operations were just keystrokes? That means your everyday macro program can do them, too.
   How about the idea of cutting and pasting? See how it lets you automate things so they can be done by a macro program?
   Here's an example. You have a Web address. It's twcny.rr.com/technofile (my Web site). That is NOT a valid HTML hyperlink. In order for it to be valid as HTML code, it needs bracketed code in front of it and behind it -- just like we did with that simple example using parentheses.
   So you select the non-HTML version of the Web address manually. (Always make this part of the procedure non-automated, so you don't mess everything up with one bad keystroke.) Then you program your macro editor to do the following: Cut the selected text to the clipboard, type the beginning of the HTML code to create an "HREF" hyperlink, paste the address back into your text and then type the end of the code.
   Your macro program can do this for you automatically. Think of simple operations, too, such as turning normal words into italicized ones (with slanted letters) or boldface ones (with dark letters). Select the text, then let the macro program cut it to the clipboard, type the beginning code, paste the text back in and type the ending code.
   Voila! Or "viola," as a musician might say. We have an HTML editor. It's a simple one, and won't win prizes. But it gets things done.