• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Restore FastScripts Keyboard Shortcuts from Backup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Restore FastScripts Keyboard Shortcuts from Backup


  • Subject: Re: Restore FastScripts Keyboard Shortcuts from Backup
  • From: Christopher Stone <email@hidden>
  • Date: Sat, 23 Apr 2016 01:27:21 -0500

On Apr 21, 2016, at 22:03, Tim Nelson <email@hidden> wrote:
He said it wouldn't be very difficult to write a script that would restore the shortcuts. However, I'm stumped as to how this would be done.
______________________________________________________________________

Hey Tim,

I was mistaken about this.

When I was looking at the dictionary in Script Debugger it said get/set for the Keyboard Shortcut class.

It didn't occur to me the shortcut string inside it might be read-only, so I conjectured without testing and got caught.  :)

The only way to back up and restore FastScripts' keyboard shortcuts is to backup and restore its preferences files.

I talked to developer Daniel Jalkut about this, and it's unlikely to change.

-------------------------------------------------------------------------------------------
From Daniel on backing up FastScripts' Prefs:
-------------------------------------------------------------------------------------------
Oh, I should have mentioned a caveat that applies, as far as I know, to restoring ANY preferences files for Mac apps these days. Since a few OS releases ago, the way the preferences system works you need to either kill the Preferences daemon, or else restart the Mac, or else cached preferences may take priority. So, a SAFE restore to original keyboard shortcuts should be:

1. Quit FastScripts
2. Replace the com.red-sweater.fastscripts.plist file
3. Restart Mac
4. Reopen FastScripts
-------------------------------------------------------------------------------------------

Here is a script that will create a text table of script name, keyboard shortcut, script file path in a file on the desktop.  (Just in case you ever have to manually recreate your keyboard shortcuts.)

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2015/08/31 09:44
# dMod: 2016/04/22 13:04
# Appl: FastScripts
# Task: List all keyboard shortcuts in a text file on the Desktop.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @FastScripts, @Backup, @Keyboard_Shortcut
-------------------------------------------------------------------------------------------

set _pad to "                                                                                "
set AppleScript's text item delimiters to linefeed

tell application "FastScripts"
  tell (script items where its has keyboard shortcut is true)
    set scriptItemNameList to its name
    set scriptFileList to paragraphs of (script file as Unicode text)
    set shortcutStringList to shortcut string of keyboard shortcut
  end tell
end tell

set AppleScript's text item delimiters to tab

set maxNameLength to 0
set maxkeyboardShortcutLength to 0

set _cntr to 0
repeat with i in shortcutStringList
  set _cntr to _cntr + 1
  set (contents of i) to item _cntr of scriptItemNameList & tab & contents of i & tab & item _cntr of scriptFileList

  

  set nameLength to length of (text item 1 of i)
  if maxNameLength < nameLength then
    set maxNameLength to nameLength
  end if

  

  set keyboardShortcutLength to length of (text item 2 of i)
  if maxkeyboardShortcutLength < keyboardShortcutLength then
    set maxkeyboardShortcutLength to keyboardShortcutLength
  end if

  

end repeat

repeat with i in shortcutStringList
  set scriptName to text item 1 of i
  set keyboardShortcut to text item 2 of i
  set scriptPath to text item 3 of i

  

  set padLen to maxNameLength - (length of scriptName) + 5
  set scriptName to scriptName & text 1 thru padLen of _pad

  

  set padLen to maxkeyboardShortcutLength - (length of keyboardShortcut) + 5
  set keyboardShortcut to keyboardShortcut & text 1 thru padLen of _pad

  

  set contents of i to scriptName & keyboardShortcut & scriptPath

  

end repeat

set AppleScript's text item delimiters to linefeed
set shortcutStringList to shortcutStringList as text

set backupFile to (path to desktop folder as text) & "FastScripts Keyboard Shortcut List.txt"
writeFile(shortcutStringList, backupFile, 0, «class utf8»)

-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------
on writeFile(srcData, targetFile, startPosition, dataType)
  try
    set fileRef to open for access targetFile with write permission
    if startPosition = 0 then
      set eof of fileRef to 0
    end if
    write srcData to fileRef as dataType starting at startPosition
    close access fileRef
  on error errMsg number errNum
    try
      close access fileRef
    end try
    error "Error in handler: writeFile of library: gen.lib" & return & return & errMsg
  end try
end writeFile
-------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Restore FastScripts Keyboard Shortcuts from Backup (From: Tim Nelson <email@hidden>)

  • Prev by Date: Re: Acquiring the Dropbox Folder Path -- was: Re: Error -10000 for one user
  • Next by Date: Re: Acquiring the Dropbox Folder Path -- was: Re: Error -10000 for one user
  • Previous by thread: Restore FastScripts Keyboard Shortcuts from Backup
  • Next by thread: Re: Restore FastScripts Keyboard Shortcuts from Backup
  • Index(es):
    • Date
    • Thread