AutoHotKey script to toggle between Minimize, Restore, and Focus Dopus window

This script which I did not write but got help with on the r/autohotkey subreddit was inspired by this functionality in TotalFinder that I use when I'm on OSX.

Of course, it's not quite the same with the animations and sliding back down when losing focus but it's essentially a quick way to open or close or bring into focus a single Directory Opus window all with the same key command. I used autohotkey for this but getting some built-in functionality in dopus (kind of like the visor function in Total Finder) would be ideal IMO.

Anyway, here is the autohotkey script. I used ALT-D for my shortcut. If there is no open window it will open Directory Opus using the "Win-E" launch settings. I set mine to use a default lister and then set the default lister to update with every close so that I can pick up where I left off using this shortcut. If I want a specific layout I use a different shortcut or change it in the app. If the window is open but not focused it will focus it and if the window is open and focused it will minimize it. If minimized, it will restore it. dopus.txt (491 Bytes)

You could do all of that with just Opus on its own if you want.

Go NEW LASTACTIVELISTER on a system-wide hotkey (which you can create from Opus) would cover a lot of it on its own, bringing the last active window to front or opening a new one if there isn't one.

To make the same key minimise the lister if it's already active should also be possible with a bit of scripting.

Oh cool, yeah that would be a better solution overall to integrate the shortcut into Opus, I agree. I wasn't aware of that "new lastactivelister" option but also the scripting to get the minimize feature would also be beyond my capabilities. The ahk script is working for now but if someone ends up posting the script to do it within Opus I would definitely switch over to that one.

This is KEY to my workflow: being able to toggle DOPUS' visibility (I only ever use one lister).

I'm not able to script this myself, either. So if someone would be willing to put the minimize script up here, that would be so nice ...

Here you go:

function OnClick(clickData)
{
	var lister = DOpus.Listers.lastactive;
	var cmd = DOpus.Create.Command();
	if (lister == 0)
		cmd.RunCommand("go new");
	else {
		cmd.SetSourceTab(lister.activetab);
		if (cmd.IsSet("LISTERCMD=minimize"))
			cmd.RunCommand("Set LISTERCMD=restore");
		else if (lister.foreground)
			cmd.RunCommand("Set LISTERCMD=minimize");
		else
			cmd.RunCommand("go lastactivelister");
	}
}

2 Likes

I just tried this script and got it to work with the button, but my command editor doesn't look the same so I don't know how to make this a system-wide hotkey. How do I do that?

System-wide hotkeys are created either via the Keys tab on the Customize dialog, or by placing the button in a floating toolbar and assigning a hotkey to it.

Thanks for the prompt response. When I put the button in a floating toolbar, it already had a hotkey assigned, and when I assigned a new hotkey, it did not seem to make the hotkey system-wide. Is there a box to check or is this supposed to happen automatically when assigning a hotkey to a button on a floating toolbar?

As far as creating a system-wide hotkey on the Keys tab, is there any way to change an existing hotkey into a system-wide hotkey, or do I have to create a new hotkey? Can you explain why I don't see a "system-wide" checkbox on my interface the way you have on yours?

The command editor for hotkeys looks like this:

What you posted above is a normal button editor, not a hotkey editor.

The hotkeys for buttons in floating toolbars automatically become system-wide out of Customize mode, as long as the Enable hotkeys option is turned on for them (right-click on the toolbar outside of Customize mode to get to this option).

image

Thanks. Both windows have the same title - "Command Editor". I suggest a future version could have the more specific titles "Button Editor" and "Hotkey Editor" to help make this distinction more clear.

In your screenshot, the Script Type drop-down is set to VBScript but the script code is written in JScript.

Thanks, I noticed that after I started writing my post and I corrected it in DO but I didn’t bother taking another screenshot.

For Create a systemwide hotkey go to the Keys tab on the Customize dialog box as screenshot below.
2019-10-23_10-39-29

I have a confusion! Is That system-wide hotkey can Open Opus when opus is not running in the system tray, I mean After I Exit Opus If I Press the system-wide hotkey, Is that key Open again Opus? Because In My PC It's worked fine when Opus is running or in system tray. But After I Exit Opus, I Press the system-wide hotkey for Run Opus again But It's Not Work. Nothing happens. Even I Press win + shift + E It's another system-wide hotkey. Nothing happens. What's wrong in my pc?

Hotkeys only work when Opus is running.

Is That applicable for All System-wide hot key? I mean Is That applicable for This button also?

Did you try it? What happened? :smiley:

Yes I tried But nothing happened dear aussieboykie Is there any other settings for stop this button for working?

Then I think you answered your own question...

But I don't know where is the settings which is the cause for stop works for the button! can you help me to find the settings?