I don't want to close the toolbar; I want to close other windows such as Outlook, Excel, Word, Listers or any other open window. This would be the same as clicking on the small red x in the upper left corner of any open window.
There are several reasons why I want to do this with the big red X that I have installed on the floating toolbar.
The problem is that once you click a button on an Opus toolbar (I seem to recall you crafting a floating Opus toolbar as a Start Menu replacement or something) you're making that toolbar 'active' and giving it input focus. So guess what will happen if you run <Alt+F4> against a floating toolbar...?
That said, it's trivial to compile an autohotkey script to run something like:
; Alt+F4
Send !{Tab}
Sleep, 25
Send !{F4}
...which you can then call from an Opus button. It's doing an <Alt+Tab> first to switch back to the previously active window, waiting for a small bit of time for the window change to complete, then sending <Alt+F4>.
But I'm wary of suggesting you really rely on this. Depending on system load, it could still end up closing the current window, or doing nothing at all if the window switch takes some fractional bit of time that causes the Alt+F4 keystroke to go to the desktop or something. It could also have other unexpected results - like closing some ~other window you didn't intend to close (like it did to me when it closed Opera midway through drafting my original version of this reply even though it was several windows 'behind' the last active window that Alt+Tab should have switched to).
Ahhh... I'm beginning to see the heart of the problem; as soon as I click on the big red X on my toolbar IT than has focus and Alt+F4 will close down the toolbar... not what I want.
It is not exactly the same as manually pressing the Alt+F4 keys on the keyboard with Outlook selected as focus.
It may be that the standard Close Lister command is all that I can have.
But, I'm also thinking that the big red X toolbar button can still work IF...
1: I can somehow make the command first select the previously active window (such as the Outlook example) before doing Alt+F4.
2: Adding some code that would ignore the toolbar as a top focused window (when the big red X is clicked) then run Alt+F4.
3: De-focus the toolbar then run Alt-F4.
I've used that before and it does work very well. Problem is, even with 13 fully programmable mouse keys, I'm out of keys.
Same for the keyboard... out of keys.
Clicking on the little x in the top right corner of each window is what I want to get away from. I often have many windows of different sizes open and sometimes want to quickly close a few of the top-most ones & have always found Alt-F4 to work well EXCEPT when the windows are of different sizes then it is a pain as I have to move the mouse all over the place to click on the x's in different locations. It's actually quicker to manually press the Alt+F4 keys to close different size windows. Just thought having a single BIG red X in one consistent location would be much nicer.
Oh, well; maybe something will come up. I'll sleep on it.
Think I have come up with an answer. I was looking at my Universal Key Commands Excel database I put together a year or so ago which has every key for many common programs including Windows. I recalled seeing several ways to back track or recall previous focused windows.
The answer is the Win+Tab key. No matter what window was last opened before selecting an Opus toolbar, Win+Tab ALWAYS returns to the last focused window. It seems that it also completely ignores the Opus toolbar as not even being there.
Sooo... all we need is something like....
1: Win+Tab.
2: Alt+F4.
And we're done.
Is there a way to enter simple commands like that directly into an opus toolbar button or do we need to run something like AutoHotKey?
I don't think there's a DOpus-Command to send keystrokes. You can use nircmd.exe to do this but it will probably also close the floating toolbar at some point when executed from the toolbar.
What you can do to get around this is to pin a shortcut which executes your command to the taskbar. To do that write the following command to a textfile and rename it to e.g. "test.ncl":
sendkey alt down
sendkey tab down
wait 25
sendkey tab up
sendkey alt up
sendkeypress alt+F4
Now create a shortcut to nircmd.exe, pin it to your taskbar and edit it to do [path]\nircmd.exe script [path]\test.ncl
The following nircmd script is fully working (with a little flicker) from a button in a floating toolbar. If your toolbar is not docked to the left side of your screen you'll have to change the values for the "movecursor"-commands accordingly.
It moves the cursor out of the toolbar (adjust the value in the first line to fit the width of your toolbar to make it work even if you click the button near the edge of the screen), applies the hotkeys and moves the cursor to the edge of the screen first and some pixels to the right afterwards to bring the toolbar up again with cursor placed above the button.
movecursor 100 0
sendkey alt down
sendkey tab down
wait 25
sendkey alt up
sendkey tab up
sendkeypress alt+F4
movecursor -500 0
wait 25
movecursor 30 0
It has a reasonably capable scripting language that can work with Windows titles, processes and the like.
I don't know if it could do what you want, and I haven't tried to make it play ball with DOpus, but I use it to take some of the cues for actions that you describe.