Friday, April 27, 2007

Lesson 3: The Extra Mile

Ok, so now you've got your toolbar going. How can you really make this dog hunt? Let's get into the config and see.

If you go to your QM Editor and hit Ctl-F1, you'll open the help for QM. This is actually an extremely well documented program and the help is always my first stop. The first thing to do is click on the 'Index' tab and start entering 'Toolbar properties'; you'll notice that it jumps down the list as you type. Now, take a look at the entry for 'Toolbar properties'. We'll be doing some work in here in a bit but first open the properties of the toolbar (Ctl-p) and let's set it to open only when we have a certain window open.

Here's the properties window; now choose 'window' under the 'triggers' tab and then choose 'created and active'.

On the right you'll see a little icon that looks like a aiming reticle; click and drag that onto the window, who when starting up, will trigger the toolbar to open. You'll see it fill-in a bunch of info in the 'window name' field and probably the class as well. Edit the 'window name' field as needed as the toolbar will not open if the window tittle bar doesn't contain exactly what is in the field. For instance, if I want the toolbar to open when FireFox is started, it won't if I leave the value 'The Macro Hook - Mozilla Firefox' in the window field. To fix that, I'll just remove the first part and leave '
Mozilla Firefox' in there. I can also use the '*' wildcard by clicking the checkbox 'Use *' and put it in the field like this '*Mozilla Firefox'. And if you really want to let your Geek-Flag-Fly, start putting in Regular Expressions by hand or via the 'RX' button.

Now, let's say you want to make this toolbar (which should have a few buttons on it) sit on top of the window's title bar. Here's what we do. Run the tool bar and right click on it. Click on 'coordinates' and then 'top-right'. Also, make sure that 'Auto-Select' is unchecked. Now adjust the size by dragging the edges around. Once you have the size set to the way you want it, uncheck 'Sizing Border'. Now move it into place by dragging it into place with the right mouse button. Once it is set in place, it should move with the size of the window to always be next to the 'minimize' button.

Here's what I'm seeing.

Nice and very usable but let's see what else we can do. Open up the properties again and click on the 'Toolbar Properties' tab. Here you can see all kinds of hacking potential (i.e. 'Shrinked width', 'Text Colour', and 'Bitmap') but let's take a look at just one for now, 'Opacity'. I love this one! Windows opacity can be set from 0-255 (255 being standard Widows opaque and 0 being completely invisible). Now, set the Opacity for 150 and tab over to 'Transparent Colour' and click the button that says 'Back. Colour'. Hit 'Ok' and close your toolbar and open it again for the changes to take effect. Nice huh? Now, go back to the properties and take out the value for 'Opacity' and just leave the 'b' in the 'Transparent Colour'. Hit 'Ok' and restart your toolbar.....Even better huh? Notice the differences in the two? No lines just like the programmer put them there.

So now you know how to: build a toolbar; make it look like you want; and assign it's existence to only a particular window. There's plenty more you can do like: use a bitmap for the background (gradients are nice for this); have them shrink out of the way till you mouse-over them; and set different icons on them. Digg into them and you'll see all kinds of uses for them.

So have at it and I'll see you next time cause the hook always brings you back.

Thursday, April 26, 2007

The Extra Mile....

The Extra Mile will be a few more days this week due to illness.



Lesson 3: The Toolbar

Ok, so we've gone over two different ways to access your macros or code quickly and easily: the Text-Sensitive Menu (TSM (which is the quickest and invisible)) and the Pop-up Menu (PuM (which is visible but only till you choose an option or cancel it). But, there is a third that is more permanent than the PuM; it is called the Toolbar (Tb). Of course you've seen this ever since you've opened QM as there is one connected to the QM Editor. So, let's get into it so you can start doing more with less.

Toolbars, Pop-up Menus, and the Text-Sensitive Menus are all about giving you ways to execute code quickly by trading off speed with volume. If you have more than a score of text-replacements or other macros that you try to put into a TSM, you can start to loose track of them and start to reenter them having forgot you put them in there two or three months ago when you last used that particular process. So, moving them to the PuM can help remind you of what you already have, but if you've had to categorize it with sub-folders and sub-sub-folders and thus it has become tiresome to keep pulling up the PuM and then navigate to what you want, then you're in the market for a toolbar. So let's get that started.

Create a new Tb by clicking File>New>New Toolbar

No screenshot for YOU; come back one lesson!

Now, let's start dropping in some entries: a few programs you're always using; a few websites; and a macro or two. And here's the code for my quick one so you can see what they look like.

IEXPLORE :run "$program files$\Internet Explorer\IEXPLORE.EXE"
WINWORD :run "$program files$\Microsoft Office\OFFICE11\WINWORD.EXE"
EXCEL :run "$program files$\Microsoft Office\OFFICE11\EXCEL.EXE"
The Macro Hook :web "";;come on if John C. Dvorak can do it...!
Quick Macros Forum :web ""
One Line
Unformat Clipboard

The first three entries I created from last week's lesson on the PuM by just dragging over some exe's from my file manager. The second group will take me to a couple of websites (again these were created by merely dragging over the icon that's in the address bar to the QM Editor). The last two are a couple of custom macros that I built to help me out so they won't look right (or work) in your Editor but feel free to add your own there.

When you first start it, you probably won't like how it looks. Here's what I got (whoops those macro icons didn't show up...I'll fix that in the next slide; look for green triangles).

Not very pretty, huh? But let's pull it cherry hot from the furnace that is our desire and put it on the anvil of our will and shape it to be the beast of burden we need....(ok, so I listen to a lot of George R. Martin.....and Roy Dotrice better be reading the next book...I'm talking to you Random House!). Let's transmogrify to the below description....(ok, so I like Calvin and Hobbes too....) it to fit this description:

  • vertical
  • with text
If you right-click on the toolbar, you'll see this menu. Click "Vertical" and "Show Text"

Right-click on it again and click "Miscellaneous" and take a look at the options there. Click "Equal Buttons" and see how it affects your Tb.

Now, just grab the lower right-hand corner of the Tb and adjust the size as you needed. For bonus points, try out the "Auto-Shrink" option as well....(I'm not going to tell you what it does but it won't affect you in any way that you'll need to start paying attention to your spam folder to fix).

So there it is, 3 lessons, three execution platforms: No-look, Quick-look, and Always-look. Play around and keep expanding because these machines are here for us not the other way around.

So have at it and I'll see you next time cause the hook always brings you back.

Tuesday, April 24, 2007

Automation and the Crippled Masses

GAAAAAHHHH!!!! this didn't post!....such an E-List blogger mistake!

There are times when, the planets are aligned,the solstice is here, and that monkey just popped off for a very thorough shower....and this, my friend is a story about such a time. The yin and yang of automation is summed up in one article; it reminds us that automation cuts both ways but the cutting isn't always bad....Enter Ferdy.

Meaninglessness - Worse Than Failure

Tuesday, April 17, 2007

Lesson 2: The Pop-up Menu

Well, here here we are at lesson two and you've already reduced your annoyance and saved yourself a tonne of time with the Text Sensitive Menu (TSM). And if you're like me you may have a hard time keeping track of all the items it the T.S. Menu. Have I got just the thing for you: the Pop-up Menu (PuM). The PuM can hold command strings or execute macros, just like the TSM, but you can pick these items from a visual menu rather than trying to remember them. So now that the hook has been baited, let's put it in the water and see what hits it.

Create a new PuM by clicking File>New>New Menu

The syntax for the PuM is pretty straight forward. The label (the name you want to show on the menu), then a 'space' character, then a 'colon' character, then the magic. Let's start with all those 'text-replacements' you setup in the TSM but can't remember to use. Since it's pretty straight forward I'll just show you what it looks like.

And here's the code (note: there are only three lines of code even though your browser may have wrapped them:

No Thanks :outp "Thank you for your concern but I don't need any non-perscription v!agr4."
Good Luck :outp "That is unfortunate about your current financial circumstances; I would help you, however I am already helping a wrongly deposed prince in Sierra Leone."
PPpbbbbtttt :outp "Your offer is very tempting as your rates seem to be very low, however I won't do my banking with someone who can't spell 'r3f1nanc3' correctly."

Since you have other things to do besides reply to spam all day (which I don't recommend by the way), here's another function of the PuM that will save you a tonne of time. Launch your favorite applications from the PuM.

It is insanely simple to to code the PuM to launch programs; just drag the icon into the Editor, and then....ummmm....ok, well there isn't another step.

Here is the code that is put into the Editor when I drop the program's icon into the Editor.
halo :run "$program files$\Microsoft Games\Halo\halo.exe"
And here is what the PuM looks like when I hit the trigger for it.

But after a program or two plus the text-replacements, things can get cluttered but here's how we can deal with that. You can create Sub-Menus to organize all the entries that are related.

To do this use the '>' (greater than) character to let QM know that the following is the name of the Sub-Menu. When you hit enter, the Editor automatically 'tab-indents' the lines that follow. Now you can move the line down into the Sub-Menu like this and drop in a couple of tabs to line everything up and then end the block with a '<' (less than) character so that your code looks like this.

Now you've got a place for that Text-Sensitive Menu 'run-off' that you can't seem to keep in your head. Plus, a quick menu for your most used programs.

So have at it and I'll see you next time cause the hook always brings you back.

Lesson 2: The Extra Mile

Lesson 2:The Extra Mile

Well, now that you've got your menu up and going, it has probably gone all Audrey II on you and has like a 100 lines in it by now. Like the Sub-menu, there is another way that you can further categorize the Pop-up Menu (PuM) by making several and have them tied to the specific program that you are currently using. But the problem with a bunch of PuMs is that, you have to remember all those triggers. So here's a plan to avoid that. I call it "Macro Stacking".

First split up your PuM items into program categories ( e.g. browsing, email, Excel actions, etc.) and create a new PuM for each category. Now, make a new macro with the trigger you want (mouse or keyboard or second keyboard). What you're going to do is use the "getwintext" string function to get the active window's Tittle Bar text and then use the "sel" function to determine which PuM is brought up.

Here is how it is coded:

sel _s 2
case "*- Mozilla Firefox"
mac "Menu3"
case "Quick Macros - *"
mac "Menu2"
case "QM Help"
mac "Menu"

This is pretty straight forward but I will make a few notes. First the '_s' is a predefined local variable for a string. There are also numerous other predefined variables but I mostly use _s and _i (integer). It saves a line of code by not having to declare it. The '2' after 'sel _s' is a flag that tells QM that the values in the select case will/may contain wildcards. You can also tell QM that the case statements need to be case insensitive with the flag 1. Or, you can tell QM that the case statements are case insensitive AND may contain wildcards by adding the flags together and putting a 3 there.

So there you have it; one macro to rule them all using 'Macro Stacking'. Now you can make all kinds of PuMs without having to sift though all the macros/code or Sub-menus that don't apply to the situation at hand.

So have at it and I'll see you next time cause the hook always brings you back.

Lesson 2:The Pop-up Menu

Friday, April 13, 2007

Soft Coding - Worse Than Failure

Soft Coding - Worse Than Failure

I wanted to include this article from Worse Than Failure even though it doesn't seem to apply to automation per se. It does however discuss hard-coding versus soft coding. And in the end drags the big-wet-greasy finger of automation across the line between hard and soft coding. Especially when you have automated your compilers and program distribution. In the end, what's the difference between an end user going in and removing or adding a record to a database that a program uses to create output and a programmer going in and doing the same thing in the source code along with an automated compiling script and executable distribution....I'd say, "Dang little, and a sight more reliable."

Anyway, it's a good read.

Tuesday, April 10, 2007

The Format

Well, I've just posted my first lesson here on The Macro Hook. I've laid it out differently than most. The lessons come in two parts. The first part is an introduction to the topic and the second takes it a bit further (thus it is called "The Extra Mile").

Comments are open and I do take suggestions but I have had to limit it to registered users only...cuz MAN, there are a lot of spammers and griefers out there!!!

So, enjoy and jump in on the discussions. Future posts will certainly be affected by your input.


Lesson 1: The Text Sensitive Menu

In the 1st article here at The Macro Hook, I'm going to show you how to make the T.S. Menu (TSM) your friend.

T.S. stands for "Text Sensitive" and is used for "text replacement" but that's kind of misleading to the new user. Think of the TSM as a way to write tonnes of text with just a few keystrokes. Let's dive in and I'll show you.

Ok, so here's the scenario involving email but this can work for text documents or spreadsheets, or anytime you need to type the same thing over and over. So, you have numerous people writing you; you basically want to say the same thing to each of them but don't want to write it every time. Here's how we do it.

Create a new TSM by going to "File">"New">"New T.S. Menu"

You will notice that it automatically calls the menu "T.S. Menu" by default but the name is selected and ready for you to type in your name or you can just hit enter and accept the default name (subsequent TSM will be called " T.S. Menu2", "T.S. Menu3" etc). The big blank box is called the "Editor"; it's where the magic happens.

Just a quick aside: the first line of your new T.S. Menu put in this code. I'm not going to go into what this does at this time because we have enough to cover but you can look at the help file to find out more about it.


So, lets say you want to always say, "Thanks for your input." in responding to these emails your always getting. Here's how we do that. In the Editor, type the "trigger text". For example, if you want QM to type out the above response when you type "nr" (nice response), your code would look like this.

nr :outp "Thanks for your input."

Now, we need to set your "trigger" for the TSM itself. While in the editor, press Ctl-P to get the properties dialog (you can also get to that by right clicking the macro name in the "List"). You'll see this dialog.

Now, click the "Keyboard" item in the list of triggers. If you hit the tab key after selecting the trigger method, it will take you to the "Hot-Key" field. Now hit just the letter of the keyboard shortcut you want to use. For instance, if you want your TSM trigger to be Control-Shift-t, just hit the "t" key when in the Hot-Key field and then click check boxes for Ctrl and Shift. Now, every time you hit Ctrl-Shift-t, you have engaged the TSM and it will wait for you to hit the trigger 'nr'. It will wait for 5 seconds for you to give it a correct trigger, at that time it will end the process. If you hit keys that are: not a trigger, click the mouse, or type a non-printable key such as....ummm....well, I would print them out here but they are non-printable (kind of like Schrödinger's cat so don't try to print them; you don't want to kill kittens do you?...EGAD MAN, JUST DON'T DO IT!....)....Sorry about that. It's just that I feel very strongly about quantum keystrokes.

So, now we're in business. Open a document in something (I like ConText) and hit your TSM trigger and then your text trigger; I'll wait for you........................Ok, good. Nice huh? Now lets make another that has a little more to it. Try this.

nr :outp "Thanks for your input.[]The ''Hofstadter-Moebius loop'' is actually very common in that type of computer.[][]R. Chandra"

Note: paste this in as one line of QM code.

Now, go try your triggers again.....AAAhhhhh....why did it to a new line character after "input."? Yes, you're right. The "[]" told QM to do a new line there. It's a very handy thing to have; it's kind of like a special escape character. Now, did you notice the odd appearance of the double-quotes? Well, that's a special consideration in QM (and maybe in other 3G or 4G languages too). When you're telling QM to "output all info between the next two quotation marks", you can't have it output the quotation mark because it thinks you're trying to tell it to stop outputting the text, so, instead you use two apostrophes instead. So, two of these ' equal one of these "

So there you have it; a quick and easy way to output a tonne of text with only a few keystrokes. Only you can limit the use of this technique; you can use it in text documents, web page forms, or even to beat down Digg spammers. 80)

So have at it and I'll see you next time cause the hook always brings you back.

Lesson 1: The Extra Mile

Lesson 1: The Extra Mile

Now that you've seen how to get the T.S. Menu (TSM) up and going, let's get into it a bit more.

Your T.S. Menu looks like this (note there are only two lines; your browser may wrap long lines):

nr :outp "Thanks for your input.[]The ''Hofstadter-Moebius loop'' is actually very common in that type of computer.[][]R. Chandra"

But you might also want to run your macros from the TSM as well; not a problem. Let's say, you want to trigger your macro "Date-Time" with the trigger dt; here's how you would do that.

dt :mac "Date-Time"

Now, when you invoke the TSM and hit 'dt', your macro runs instead of outputting text. But here's a nice little trick that you can do in QM. If you don't want to create a new macro, just code it in the TSM.

In QM you can run all the lines together by separating them with a semi-colon ';' instead of carriage-returns. Take your Date-Time macro for example. Here's your code:

str a
outp a

Nice and compact; easy to maintain; and efficient. Good job; you're really getting the hang of this. Anyway, so you want to have this code in the TSM rather than making a whole new macro; no problem. Here's how you're going to do that. Replace the 'carriage-returns' with a 'semi-colon' like this:

str a;a.time("%c");outp a

Now put that into your trigger line in your TSM like this:

dt :str a;a.time("%c");outp a

And there you have it. It makes complicated macros and functions a real bear-cat to debug or even to know what it's for, but it can be done and it can be better sometimes than making all kinds of new macros clogging up your List in the main window.

So have at it and I'll see you next time cause the hook always brings you back.

Lesson 1: The Text Sensitive Menu

Saturday, April 7, 2007


I was talking to a guy at work the other day and we were discussing automation. He was curious as to why I was so gun-ho about automation; I told him that my driving force behind it was "INDIGNATION"!! If we can send men to the moon with a slide-ruler, then surely there's a way that I can keep from typing the same lines over and over and over (no, I still do not administrate that system contact ITS).

Yes, it is obvious why you would want to automate processes but as this is the beginning of this blog I'll go ahead and outline them so we can all start on the same page. Besides, I'm betting I have one benefit that you haven't thought of yet. 80)

The first reason is to free me up to do tasks that the computer isn't good at, like: what do I want to have for second breakfast or does this keyboard make me look fat? You know, the important stuff. The second reason is, things are done more accurately when you let the computer do it. Of course, you have to have accurate code in there to begin with but that's what this blog is about. The third reason is so that the tasks get done even if I'm not there. No training, no frantic calls from the nearly dead cellphone trying to explain how to get a report published. And the fourth reason is that you only have to be polite once. It doesn't matter if this is the 17th time you've answered the question since you got into work (and you haven't even had elevenses yet!). You can be as mad as you want and cuss the users till you pass out and hit your head on your faux targh-leather messenger bag but your email response is just as sweet as honey-laced ambrosia served by a Jewish grand-mother who hasn't seen you in too long.

So, as we approach these up coming code examples remember to gird your loins with your best winter kilt of Indignation and drink deep the cup of Vexation and remember "If you do something more than once, you're a sucker."

Friday, April 6, 2007

AAAaaannnnd We're Off!!

So here it is. My first post on a blog that I hope makes me a million bucks (USD). In the end isn't that what all us bloggers are out for (yeah, I'm talkin' to you Johnny C. D.!)? That way we'll have more time to sit in a St. Louis Bread Co. and eat chocolate-chip muffins and surf...I mean, work.

So, here's a little synopsis of what I'm trying to do (besides make that million); I've been working in a scripting and execution environment called Quick Macros for several years now. I'm doing all kinds of really handy things in it and I want to help make your life easier (and make a million bucks). Each post will be about a concept or procedure to help you understand QM better and help you free yourself up more.