Tuesday, April 17, 2007

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:

_s.getwintext(win())
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

No comments: