ChatGPT, AppleScript, Keyboard Maestro, and Being an Old Mac User

I don’t remember where exactly, but if I recall correctly John Siracusa discussed setting Finder windows to look more like classic Mac OS windows. A pretty typical Finder window, invoked anew in Mac OS 9, would look like this:

OS 9 Finder Window
OS 9 Finder Window

I grew to prefer list view in OS X, which is my default these days. I also like column view, but never use icon view. List view isn’t new to the Mac; it looks like this on OS 9:

List View in Mac OS 9
List View in Mac OS 9

The macOS Finder still handles the same tasks as the original Finder, but it has changed considerably ever since the OS X Public Beta. There’s a Toolbar that expands the size of a Finder window greatly; it includes a sidebar and a customizable set of actions and options.

The Finder in macOS
The Finder in macOS

I don’t generally have any objection to the macOS Finder; early iterations were slow, and then the icons got kind of big and horsey looking, but the slow march of progress has generally improved Finder.

The podcast or wherever I heard about turning off all of the options that make a new Finder a new Finder window, in comparison with the

I’ve been playing around with Keyboard Maestro again recently, and I found an old action I’d been messing with that was intended to turn off the additional Finder settings, leaving me with a classic Mac OS-style window. You can easily turn these off via macOS’s GUI in Finder:

macOS Finder View Options
macOS Finder View Options

This would be three clicks of the mouse or three keyboard shortcuts executed each time you wanted to toggle. It’s the repetitive kind of thing that begs for an AppleScript or Keyboard Maestro utility. Or both.

Keyboard Maestro is an obvious choice; I figured I could pick one master keyboard shortcut, and have that key sequence active all three of the Finder shortcuts. But then I thought, recalling something that Jason Snell said on a recent MacBreak Weekly, ChatGPT is really good at AppleScript.

So I asked ChatGPT, “write an applescript to hide the Toolbar off in the finder if it’s visible.”

I got this:

tell application "Finder"
    activate
    try
        tell application "System Events"
            tell process "Finder"
                -- Check if the toolbar is visible
            if value of attribute "AXToolbar" of window 1 is  true then
                keystroke "t" using {command down, option down}
            end if
      end tell
   end tell
on error errMsg
    display dialog "An error occurred: " & errMsg buttons {"OK"} default button 1
end try
end tell

I went through a few iterations of this, realized that this needs to be a toggle (ie, if there’s no active Finder window open, one should be opened and set to my notional classic Finder window style; but if there is a modern macOS Finder window open already, the same keystroke should set that window to the Classic look). ChatGPT was fast and accurate all along the way. Here’s the final script:

tell application "Finder"
    activate
    if (count of Finder windows) = 0 then
        make new Finder window
    end if
end tell

tell application "System Events"
    tell process "Finder"
        try
            -- Toggle the Toolbar
            if exists menu item "Hide Toolbar" of menu "View" of menu bar 1 then
                click menu item "Hide Toolbar" of menu "View" of menu bar 1
            else if exists menu item "Show Toolbar" of menu "View" of menu bar 1 then
                click menu item "Show Toolbar" of menu "View" of menu bar 1
            end if

            -- Toggle the Status Bar
            if exists menu item "Hide Status Bar" of menu "View" of menu bar 1 then
                click menu item "Hide Status Bar" of menu "View" of menu bar 1
            else if exists menu item "Show Status Bar" of menu "View" of menu bar 1 then
                click menu item "Show Status Bar" of menu "View" of menu bar 1
            end if

            -- Toggle the Path Bar
            if exists menu item "Hide Path Bar" of menu "View" of menu bar 1 then
                click menu item "Hide Path Bar" of menu "View" of menu bar 1
            else if exists menu item "Show Path Bar" of menu "View" of menu bar 1 then
                click menu item "Show Path Bar" of menu "View" of menu bar 1
            end if

        on error errMsg
            display dialog "An error occurred: " & errMsg buttons {"OK"} default button 1
        end try
    end tell
end tell

Here’s a quick video of the script working: