I have a simple macro that opens a folder with a keyboard shortcut. I want the macro to always be activated except when the Mac's Open/Save box is opened. Any way of achieving this?
I don't want the macro to work when the Open/Save box is open because I want Default Folder X to take over opening the same folder.
But – you can script Default Folder with AppleScript – so you can detect whether a dialog is open and have the macro tell Default Folder what to do.
Here’s an example.
Open TextEdit, and type Cmd-O to open the Open-Dialog.
Select a folder in the Finder.
Run the script and see it work.
--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/11/30 21:14
# dMod: 2018/11/30 21:14
# Appl: Default Folder X, Finder, Safari
# Task: Working Default Folder Get-File Example
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Default_Folder_X, @Finder, @Safari, @Working, @Default_Folder, @Get-File, @Example
--------------------------------------------------------
tell application "Finder" to set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in the Finder!"
set theItem to item 1 of finderSelectionList
tell application "TextEdit"
activate
end tell
delay 1
if defaultFolder_DialogIsOpen() = true then
defaultFolder_SwitchToFolder(theItem)
end if
--------------------------------------------------------
on defaultFolder_SwitchToFolder(folderAlias)
tell application "Default Folder X"
SwitchToFolder folderAlias
end tell
end defaultFolder_SwitchToFolder
--------------------------------------------------------
on defaultFolder_DialogIsOpen()
tell application "Default Folder X"
if (IsDialogOpen) = true then
return true
else
return false
end if
end tell
end defaultFolder_DialogIsOpen
--------------------------------------------------------
The two handlers give you most of what you need to complete your task, but you can holler at me if you need additional help.
This will behave as described for when there is or isn't an Open/Save dialog present. But as it's been nearly 20 years since I've used Default Folder I don't know if this will be helpful for then initiating it.