Workaround to lost module settings

Steve H's Avatar

Steve H

15 Sep, 2020 10:41 PM

I continue to run into the bug where the sidebar and other modules lose their settings, so I wrote the attached AppleScript the other day. Lo and behold, I needed to make use of it this morning, and it worked like a charm; although, PF had also lost all of the modules on the right shelf, not just their settings, so I had to recreate my layout first. I'm posting this here in case it might also help somebody else out. This does take the willingness to tinker with AppleScript and the user interface. I found it to be a fun afternoon of learning, hopefully this post will help make that much less time for you (I'm thinking maybe a half hour if you already know your way around AppleScript, but don't know the GUI Scripting part, but YMMV).

The script uses GUI Scripting to essentially choose and click through the interface to reapply the settings in each module. I had previously attempted to record the actions required to apply the settings using keyboard presses and/or mouse clicks, but the results were very inconsistent. For example, there is no way to select the settings menu for the module via keystroke, and mouse clicks are not reliable because the size of the window can change. This was difficult for me to figure out until I found [UI Browser][https://pfiddlesoft.com/uibrowser/]. The benefit of this method is that it uses code to directly manipulate the controls and menus rather than using mouse and keyboard to select; but to get that benefit, the script is extremely personalized. It is absolutely reliant on having my specific shelf layout. You will need to customize this section of the code for your layout. UI Browser is your friend for that; it will give you the code to use for each selection (I find UI Browser to be very crashy, but very beneficial). My shelf layout is:

  • Left (t->b): Drop Stack, Sidebar
  • Bottom: nothing
  • Right (t->b): Info, Attributes, Tags and Ratings, Open With

For all of the modules except Drop Stack, I have customized my layout, color, and font settings. I've saved the settings for each module. These settings names need to be edited in the AppleScript. Currently, they are all listed as "SAVED_SETTINGS", but you can change that to match your saved settings.

-- uses model script from UI Browser
set theVersion to system attribute "sysv"  
if theVersion is greater than or equal to 4144 then -- 4144 is Mac OS X 10.3 (Panther)  
  activate application "Path Finder"
  tell application "System Events"
    set asGUIScriptingEnabled to UI elements enabled
    if asGUIScriptingEnabled then
      tell application process "Path Finder"
        -- ************************************
        -- insert GUI Scripting statements here
        -- ************************************

        -- Since we rely on the name of the window, start from a consistent location
        click menu item "Computer" of menu 1 of menu item "Computer" of menu 1 of menu bar item "Go" of menu bar 1

        -- SideBar
        click button 1 of scroll area 3 of splitter group 1 of splitter group 1 of window "Computer"
        click pop up button 1 of pop over 1 of button 1 of scroll area 3 of splitter group 1 of splitter group 1 of window "Computer"
        click menu item "SAVED_SETTINGS" of menu 1 of pop up button 1 of pop over 1 of button 1 of scroll area 3 of splitter group 1 of splitter group 1 of window "Computer"

        -- Info Module
        click button 1 of scroll area 1 of splitter group 3 of splitter group 1 of window "Computer"
        click pop up button 1 of pop over 1 of button 1 of scroll area 1 of splitter group 3 of splitter group 1 of window "Computer"
        click menu item "SAVED_SETTINGS" of menu 1 of pop up button 1 of pop over 1 of button 1 of scroll area 1 of splitter group 3 of splitter group 1 of window "Computer"

        -- Attributes Module
        click button 1 of scroll area 2 of splitter group 3 of splitter group 1 of window "Computer"
        click pop up button 1 of pop over 1 of button 1 of scroll area 2 of splitter group 3 of splitter group 1 of window "Computer"
        click menu item "SAVED_SETTINGS" of menu 1 of pop up button 1 of pop over 1 of button 1 of scroll area 2 of splitter group 3 of splitter group 1 of window "Computer"

        -- Tags and Ratings Module
        click button 1 of scroll area 3 of splitter group 3 of splitter group 1 of window "Computer"
        click pop up button 1 of pop over 1 of button 1 of scroll area 3 of splitter group 3 of splitter group 1 of window "Computer"
        click menu item "SAVED_SETTINGS" of menu 1 of pop up button 1 of pop over 1 of button 1 of scroll area 3 of splitter group 3 of splitter group 1 of window "Computer"

        -- Open With Module
        click button 1 of scroll area 5 of splitter group 3 of splitter group 1 of window "Computer"
        click pop up button 1 of pop over 1 of button 1 of scroll area 5 of splitter group 3 of splitter group 1 of window "Computer"
        click menu item "SAVED_SETTINGS" of menu 1 of pop up button 1 of pop over 1 of button 1 of scroll area 5 of splitter group 3 of splitter group 1 of window "Computer"

        -- send the escape key to back out of the last pop over
        tell application "System Events" to key code 53

        -- ************************************
        -- end of GUI Scripting statements ****
        -- ************************************
      end tell
    end if
  end tell
  if not asGUIScriptingEnabled then
    beep
    if theVersion is less than 4240 then -- 4240 is OS X Mavericks 10.9
      activate
      display dialog "GUI Scripting is not enabled" & return & return & "Select the \"Enable access for assistive devices\" setting in Accessibility (or Universal Access) preferences and run this script again." buttons {"Open System Preferences", "Cancel"} default button "Cancel"
      if button returned of result is "Open System Preferences" then
        tell application "System Preferences"
          set current pane to pane "com.apple.preference.universalaccess"
          activate
        end tell
      end if
    else
      set asScriptRunner to name of current application
      activate
      display alert "GUI Scripting is not enabled for " & asScriptRunner & "." message "Open System Preferences, unlock Security & Privacy preferences, select " & asScriptRunner & " in the Privacy pane's Accessibility list, and run this script again." buttons {"Open System Preferences", "Cancel"} default button "Cancel"
      if button returned of result is "Open System Preferences" then
        tell application "System Preferences"
          tell pane id "com.apple.preference.security" to reveal anchor "Privacy_Accessibility"
          activate
        end tell
      end if
    end if
  end if
else  
  beep
  display dialog "This computer cannot run this script" & return & return & "The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 (Panther) or later." with icon caution buttons {"Quit"} default button "Quit"
end if  
<pre><code></code>
</pre>
  1. Path Finder Support Team closed this discussion on 17 Sep, 2020 09:01 AM.

  2. Path Finder Support Team re-opened this discussion on 17 Sep, 2020 09:02 AM

  3. Support Staff 1 Posted by Path Finder Sup... on 17 Sep, 2020 09:03 AM

    Path Finder Support Team's Avatar

    Hi Steven,

    Mary from Path Finder support here!

    Thanks for providing your findings and workaround around this issue. I'll loop in our developer and maybe he'll find information provided by you essential in fixing this issue or at least providing full temporary workaround.

    Have a great day and stay safe!

    Best Regards,
    Mary 
    Path Finder Support Team

  4. Path Finder Support Team closed this discussion on 17 Sep, 2020 09:03 AM.

  5. Path Finder Support Team re-opened this discussion on 17 Sep, 2020 09:03 AM

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac