Opt-in for Apps!
Only works for Apps you choose and add to the Conditional List. See How-to for more information.
. What the preset is for:
If there is only one window left, the App will quit, when the red button of the window is clicked.
. How it works:
If you want to add an Application, which should quit with the last open window, you have to do the following steps.
Click on the Named Trigger 'Close that App'.
Click in the right panel on the button 'Advanced Conditions...'
This is the list of all apps that will quit with the last open window being closed.
You can delete an item by clicking on the minus-button of the line.
To add an app, click on the plus-button of the last item.
Copy the text from the Item before and change the name in-between the "..." to the name of the application you want to add. The exact name can be seen, when you hover with the mouse over the icon of the app in the Dock. It has to the correct spelling and capitals.
What is happening in the Preset?
The variable 'closeThatThing' is set to false | The clicked App will get activated | Named Trigger 'Close That App' is triggered | Delay 0.2 sec | Named Trigger 'Close That Window is triggered
If the clicked App is part of the Conditional list of 'Close That App', the Variable 'closeThatThing' will be set to true, what will result in, that 'Close That Window' will do nothing and only 'Close That App' will be executed. Otherwise, the clicked Window will just close.
If 'Close That App' will be activated because the clicked App is part of the conditional list, then an Apple Script will check, if it is the last open window of the application. If true, then the app quits. If false, only the window will be closed with the keystroke command + w.
Try one after the other after restarting BTT. Please tell me which one was the problem
You need to have both presets installed
In the Settings ‘Advanced Settings > Scripting BTT’ turn on ‘Allow external BetterTouchTool Scritping’
(after trying CMD+w, you should see the variable ‘closeThatThing: false’ in this list)
Try to reconnect the named triggers:
Klick on the second action (in your picture) in the middle coloum with the ABC icon. Then choose from the dropdown menue on the right ‘Named Trigger > Named Trigger: Close That App’
Do this for the fourth action also with ‘Named Trigger: Close That Window’
Great tool. thank you!
the CMD+W preset worked for me. I guess @hu_hao maybe you've duplicated trigger for CMD+W. first delete all. related presets and disable others then test it.
Although I should say this CMD+W is not perfect yet. cause it would CMD+Q in some apps like Safari which it should close just the current tab.
Another bug of this is the trigger condition depends on the location of mouse pointer (hover) so because of the keyboard shortcut it may close inactive app! (because the mouse pointing at that app's windows)
For the CMD+W version I suggest to check and trigger just on the CURRENT app. like mac OS used to be.
And there is a bug in the main "Red Button" preset as well: If you have some unsaved work on TextEdit it won't alert you before it quit it completely (although it restore from where you were after opening again)
hi @omn_ia that variable is defined as false every time you click on the red button. If the app is listed in the conditions of 'CloseThatApp', then it will be set to 'true'. Which cancels out the next 'CloseThatWindow'. If it stays false, 'CloseThat'Window' will be executed. This is also explained at the end of my initial posting
Look in the conditions of 'CloseThatWindow'. There you'll see the condition that the variable has to be 'false'.
And this is the reason, why I call CTApp before CTWindow. The other way around would make no sense.
Thanks for your feedback on CMD+W. I do not use this. Because of the mentioned problems. The command has the purpose of closing windows, not apps.
F.e. nn the case of Safari, you won't be able to close the open tabs of the last window with this setup.
There are workarounds, but they are complicated. And it is way easier to just press Q instead of W.
And if you are already pressing a combination, I see no purpose in this to be honest.
@hu_hao I guess you should delete all that is related to this setup and reinstall the presets. It should work, like for @omn_ia
If you press CMD+Q yes it will close open windows immediately even if there is an ongoing progress but if you press CMD+W (or tap on the Red button of windows) it will prompt to save the ongoing document.
With your preset when I tap on the Red button of an in-progress window it quit immediately and doesn't prompt for saving the unsaved document as it should.
It I didn't clarify this behavior right tell me to send the screenshots.
Actually it has a benefit because if you have no open windows of an app it make no sense to keep app open. I don't like CMD+Q cause its like a hammer! It will close all open windows immediately even though maybe there is some window I didn't aware of. So I prefer to close each open window (open document in TextEdit) to close one by one and in just in that situation quit the app entirely. some apps has this behavior out of the box like iTerm. If you close all of its tabs and windows it will quit as well (and didn't stay open in the background with little dot beneath of its icon)