yah I tried it out. Works great. Better than the original. No point to upload mine but I will say at the very least people if they dont want to use yours for some reason they should at least change the original workflow and the IF THEN structure it uses-fixing that up takes likes a couple seconds makes the action work much better. Only thing I didnt totally like was your script automatically minimizes ALL windows upon first/1 tap. Sometimes i want that other times not so much. Mine only minimizes frontmost window on 1at tap and 1 window min everytime but if you want to toggle minimize all i have a separate trigger 1 finger tap but FN being held along with the tap to min all windows.
So instead of sharing another version of same thing basically I upload a action I use together with the action above but it hide/unhides the the app instead of toggling minimize. Way i have it setup is 1 Finger Tap on Dock Icon to toggle minimize application and 1 Finger Click on Dock icon to toogle hide action on application. Also the script does have a fallback function for apps unable hide and thus triggers them to minimize instead.
I included the preset to download aswell as an applescript you can use
-- Enhanced Dock Click Handler for BetterTouchTool (Improved)
-- Smart toggle for single-window apps, default-like behavior for multi-window apps
on run
try
set appName to "{appName}"
if appName is missing value or appName is "" or appName is "{appName}" then return
tell application "System Events"
if not (exists process appName) then
-- Not running: let normal Dock launch behavior happen (or do nothing in BTT context)
return
end if
tell process appName
set appIsHidden to (visible is false)
set appIsFrontmost to frontmost
-- Standard windows only
set standardWindows to {}
try
set standardWindows to (windows where subrole is "AXStandardWindow")
end try
set windowCount to (count of standardWindows)
if windowCount is 1 then
set theWindow to item 1 of standardWindows
my handleSingleWindow(appName, theWindow, appIsFrontmost, appIsHidden)
else if windowCount is 0 then
-- No standard windows: activate app (reopen behavior depends on app)
my activateApp(appName)
else
-- Multi-window app: keep behavior simple/predictable
if appIsHidden then set visible to true
my activateApp(appName)
end if
end tell
end tell
on error errMsg number errNum
-- Optional debug:
-- log "Dock Handler Error: " & errMsg & " (" & errNum & ")"
try
if appName is not missing value and appName is not "" then my activateApp(appName)
end try
end try
end run
on handleSingleWindow(appName, theWindow, appIsFrontmost, appIsHidden)
tell application "System Events"
set isMinimized to false
try
set isMinimized to (value of attribute "AXMinimized" of theWindow)
end try
set isFullScreen to false
try
set isFullScreen to (value of attribute "AXFullScreen" of theWindow)
end try
if isMinimized then
my setMinimized(theWindow, false)
my raiseAndFocus(appName, theWindow)
else if appIsHidden then
set visible of process appName to true
my raiseAndFocus(appName, theWindow)
else if isFullScreen then
if appIsFrontmost then
-- Optional behavior: if already frontmost fullscreen, minimize
-- Some apps dislike toggling fullscreen via AX; fallback safely
try
set value of attribute "AXFullScreen" of theWindow to false
delay 0.35
end try
my setMinimized(theWindow, true)
else
my raiseAndFocus(appName, theWindow)
end if
else if appIsFrontmost then
my setMinimized(theWindow, true)
else
my raiseAndFocus(appName, theWindow)
end if
end tell
end handleSingleWindow
on raiseAndFocus(appName, theWindow)
try
tell application "System Events"
set frontmost of process appName to true
try
perform action "AXRaise" of theWindow
end try
end tell
on error
my activateApp(appName)
end try
end raiseAndFocus
on setMinimized(theWindow, shouldMinimize)
try
tell application "System Events"
set value of attribute "AXMinimized" of theWindow to shouldMinimize
end tell
on error
-- Fallback: raise if unminimizing failed
if shouldMinimize is false then
try
tell application "System Events" to perform action "AXRaise" of theWindow
end try
end if
end try
end setMinimized
on activateApp(appName)
try
tell application id (my bundleIDForApp(appName)) to activate
on error
try
tell application appName to activate
end try
end try
end activateApp
on bundleIDForApp(appName)
try
tell application "System Events" to return bundle identifier of application process appName
on error
return missing value
end try
end bundleIDForApp
Because your dockminimize script functions well-there is no reason for me to post mine so instead I will post another script I use in congunction with the minimizeapp script: click dock app to hide appliation. I use 1 finger tap on a dock icon to minimize the app and use 1 finger click on the dock icon to hide/unhide the application (if hiding is not possible with app it has a fallback function that will auto minimize it because some apps are unable to hide)
Enjoy to use just copy the json code and then paste in BTT when in the touchpad section
-- Enhanced Dock Click Handler for BetterTouchTool (Improved)
-- Smart toggle for single-window apps, default-like behavior for multi-window apps
on run
try
set appName to "{appName}"
if appName is missing value or appName is "" or appName is "{appName}" then return
tell application "System Events"
if not (exists process appName) then
-- Not running: let normal Dock launch behavior happen (or do nothing in BTT context)
return
end if
tell process appName
set appIsHidden to (visible is false)
set appIsFrontmost to frontmost
-- Standard windows only
set standardWindows to {}
try
set standardWindows to (windows where subrole is "AXStandardWindow")
end try
set windowCount to (count of standardWindows)
if windowCount is 1 then
set theWindow to item 1 of standardWindows
my handleSingleWindow(appName, theWindow, appIsFrontmost, appIsHidden)
else if windowCount is 0 then
-- No standard windows: activate app (reopen behavior depends on app)
my activateApp(appName)
else
-- Multi-window app: keep behavior simple/predictable
if appIsHidden then set visible to true
my activateApp(appName)
end if
end tell
end tell
on error errMsg number errNum
-- Optional debug:
-- log "Dock Handler Error: " & errMsg & " (" & errNum & ")"
try
if appName is not missing value and appName is not "" then my activateApp(appName)
end try
end try
end run
on handleSingleWindow(appName, theWindow, appIsFrontmost, appIsHidden)
tell application "System Events"
set isMinimized to false
try
set isMinimized to (value of attribute "AXMinimized" of theWindow)
end try
set isFullScreen to false
try
set isFullScreen to (value of attribute "AXFullScreen" of theWindow)
end try
if isMinimized then
my setMinimized(theWindow, false)
my raiseAndFocus(appName, theWindow)
else if appIsHidden then
set visible of process appName to true
my raiseAndFocus(appName, theWindow)
else if isFullScreen then
if appIsFrontmost then
-- Optional behavior: if already frontmost fullscreen, minimize
-- Some apps dislike toggling fullscreen via AX; fallback safely
try
set value of attribute "AXFullScreen" of theWindow to false
delay 0.35
end try
my setMinimized(theWindow, true)
else
my raiseAndFocus(appName, theWindow)
end if
else if appIsFrontmost then
my setMinimized(theWindow, true)
else
my raiseAndFocus(appName, theWindow)
end if
end tell
end handleSingleWindow
on raiseAndFocus(appName, theWindow)
try
tell application "System Events"
set frontmost of process appName to true
try
perform action "AXRaise" of theWindow
end try
end tell
on error
my activateApp(appName)
end try
end raiseAndFocus
on setMinimized(theWindow, shouldMinimize)
try
tell application "System Events"
set value of attribute "AXMinimized" of theWindow to shouldMinimize
end tell
on error
-- Fallback: raise if unminimizing failed
if shouldMinimize is false then
try
tell application "System Events" to perform action "AXRaise" of theWindow
end try
end if
end try
end setMinimized
on activateApp(appName)
try
tell application id (my bundleIDForApp(appName)) to activate
on error
try
tell application appName to activate
end try
end try
end activateApp
on bundleIDForApp(appName)
try
tell application "System Events" to return bundle identifier of application process appName
on error
return missing value
end try
end bundleIDForApp