News:

Welcome to our NEW forum! We invite you to sign up today
so it can grow to be a valuable resource to all Toolbox users!

Main Menu

Window-specific menus

Started by rjbull, October 21, 2026, 06:43:44 AM

Previous topic - Next topic

rjbull

Would it be useful to have window-specific menus?

The idea is that if I'm editing a particular file with a particular editor, say, Toolbox would pop up a menu of actions specific to that situation, e.g., boilerplate texts.  Or if I was using the database, it would pop up a menu of macros to export data in a given format.  As an alternative to popping-up willy-nilly whenever a chosen window appeared, perhaps there could be a universal hotkey to summon the correct menu for that window. That way, you wouldn't have to remember an endless series of hotkeys.

I realise that there can be difficulties distinguishing parent from child windows, but I wasn't too bothered when using similar system in the past.

oblivion

So do you mean a kind of way of enabling a bunch of text expansions or hotkeys that are only applicable when a specific application has focus?

I think, if you wanted (say) alt+F6 to behave differently depending on which application had focus, you could certainly write that into the action code, using something like

Action: Continue if "{notepad.exe}=1"
Not that it's quite the same thing, but I have a fairly complex text expansion that (without going into details) runs a process that gets the next number from the end of a bunch of saved files, increments that number and then types the filename with the incremented number suffixed to it. In principle, it'd be possible to ensure that it only did anything at all if the application that's saving the file was running; and equally, it could be coded to work differently if a different application had focus.

But I suspect if you wanted to have a set of application-specific text expansions enabled or disabled depending on whether a specific application had focus, that might be a challenge. Maybe Paul might think about making it possible for an entire action group to be associated with one or more applications and unavailable otherwise, but that feels like it might be asking quite a lot, particularly as you'd probably want the option to reuse hotkeys between different applications.

Paul (Lead Developer)

Quote from: rjbull on October 21, 2026, 06:43:44 AMAs an alternative to popping-up willy-nilly whenever a chosen window appeared, perhaps there could be a universal hotkey to summon the correct menu for that window.

If you mean for a specific exe that has the focus, then you could do it with a series of conditional exe matches, as shown in the example action below. Set a hotkey for the action and press that hotkey to do something different depending on which of three apps has the focus at the time (Notepad, Firefox and Edge). You can see in step 13 how you can invoke a totally different action on a match if need be.

If you mean to match for specific window titles, then replace the winexe$=appname.exe steps with win$=title instead (bearing in mind that window titles can change during use).

(Start)
HOW TO USE: Copy from Start to End, and then paste into an action.
REFERENCE : See an example of pasting at alomware.com/paste.png
0001 Wait: For action hotkey to be released ""
0002 Action: Allow failure messages "0"
0003 Action: Match case "0"
0004 Window: Assign active ""
0005 Action: Do this block if "winexe$=notepad.exe"
0006  Window: Maximize to fill desktop ""
0007  Keyboard: Type to active window "{f5}{enter}"
0008 Action: End of block ""
0009 Action: Do this block if "winexe$=firefox.exe"
0010  Keyboard: Type to active window "{f11}"
0011 Action: End of block ""
0012 Action: Do this block if "winexe$=msedge.exe"
0013  Action: Finish and run another "Computer\Show an info notification"
0014 Action: End of block ""
(End)

rjbull

Perhaps a bit more explanation is in order.

At work, I ran PowerPro (at a very basic level).  One of the nice things it can do is create a button and attach it (at any offset you wanted) to a particular window, either by .EXE or by a .EXE working on a particular file.  You can bind any PowerPro command or script to the hotkey.  The software for making safety data sheets offered several output formats, which could be saved to different locations.  I used a PowerPro button to trigger scripts which would press buttons, manipulate dropdowns, etc., to cut out the repetitive chores.  Later, when I needed to write a report using a particular editor on a report file, a different button would appear on the editor's title bar and would drop down a menu of specific boilerplate.

Toolbox doesn't deal in buttons, but I think what I meant was, could it be made to pop up a menu of predetermined actions in such circumstances? I.e., all the actions intended for the specific window, and no others?

<grump> don't seem to be thinking this through very clearly

Paul (Lead Developer)

Hi. I was trying to demonstrate with the demo action in my post above about how one single hotkey can do different things for different windows. In that example, pressing a hotkey while Edge was active would run the AlomWare Toolbox action called "Computer\Show an info notification". The same hotkey when used on Notepad would maximize Notepad and type the date. It tests which window has the focus and acts accordingly, including running other pre-made actions.

You can create complex menus in AlomWare Toolbox to do things. One of the default actions that demonstrates this is called "Computer\Do something from a menu" (see screenshot below). When this action is run, you get a pop-up menu of things to do, one of which is to run another action. So you could create a bunch of specific window-based actions for different windows, then use the window-matching technique in my post above to choose which to run from a single hotkey.

I will look into the button idea, though, as that should make it all a lot easier. :)