Reply to topic  [ 4 posts ] 
Listing of macros and their shortcut 
Author Message

Joined: 2007-04-12 14:59:36
Posts: 229
I have many macros in my macro folder and sometimes I forget the name of the shortcut. Is it possible to get a list of all macros with their key short cuts?
Also it seems to me that before the introduction of the present document manager, if one typed a short cut for calling a macro into the „Search“ window under the Help menu, the corresponding macro appeared, while now it doesn‘t.
In fact since the introduction of the present document manager the use oft this „Search“ window under Help has slowed down so much that it became far less useful than it used to be.


2010-05-26 01:29:12
Profile

Joined: 2008-05-17 04:02:32
Posts: 400
This macro will do the job. Very inelegant (surely I hate it) and I’m not sure if it works fine with localized interfaces.
Code:
Require Pro Version 1.3

$macro = ':'
$macro &= Localize 'Macro'
$macro &= ':'

$null = Text.newWithCharacter 0x0000
$tab = Text.newWithCharacter 0x0009
$LF = Text.newWithCharacter 0x000A

$specialChars = Hash.new
$specialChars{0x0009} = 0x21E5
$specialChars{0x0019} = 0x21E4
$specialChars{0x000A} = 0x21A9
$specialChars{0x000D} = 0x21A9
$specialChars{0x007F} = 0x2326

$shortcuts = Menu Shortcuts
$shortcuts = $shortcuts.join $null
$range = Range.new 0, $shortcuts.length
$shortcuts.transliterateInRange $range, $specialChars
$shortcuts = $shortcuts.split $null
$menuShortcuts = Hash.new
while $shortcuts.count
   $value = $shortcuts.dequeue
   $key = $shortcuts.dequeue
   if $key.find "^$macro", 'E-i'
      $menuShortcuts.setValueForKey $value, $key
   end
end
if ! $menuShortcuts.count
   exit 'No macro having a shortcut found, exit...'
end

$rmCopy = false
$keepLastCopy = Read User Default 'com.nisus.backup.keepLastCopy'
$lastCopySuffix = Read User Default 'com.nisus.backup.lastCopySuffix'
if $keepLastCopy != undefined
   if $lastCopySuffix != undefined
      $suffix = "\x{5C}Q$lastCopySuffix\x{5C}E\$"
      $rmCopy = true
   end
end

$folder = User Property 'macros folder path'
$names = File.namesInFolderAtPath $folder
$cmdPaths = Array.new
foreach $name in $names
   $path = $folder.filePathByAppendingComponent $name
   if File.isFolderAtPath $path
      $submenu = '_' & $macro  # folders first when sorted
      $submenu &= $name & ':'
      $cmdNames = File.namesInFolderAtPath $path
      foreach $cmdName in $cmdNames
         $cmdName = $submenu & $cmdName
         if $cmdName.findAndReplace '\.(nwm|pl)$', '', 'E-i'
            if $rmCopy == true
               $isCopy = $cmdName.find $suffix, 'E-i'
               if $isCopy == undefined
                  $cmdPaths.appendValue $cmdName
               end
            else
               $cmdPaths.appendValue $cmdName
            end
         end
      end
   else
      $cmdName = $macro & $name
      if $cmdName.findAndReplace '\.(?:nwm|pl|scpt|applescript)$', '', 'E-i'
         if $rmCopy == true
            $isCopy = $cmdName.find $suffix, 'E-i'
            if $isCopy == undefined
               $cmdPaths.appendValue $cmdName
            end
         else
            $cmdPaths.appendValue $cmdName
         end
      end
   end
end

$lang = Language.systemLanguage
$cmdPaths.sort 'li', $lang

foreach $i, $cmdPath in $cmdPaths
   $cmdPath.findAndReplace '^_', '', 'E'
   if Defined $menuShortcuts{$cmdPath}
      $cmdPath &= $tab & $menuShortcuts{$cmdPath}
   end
   $cmdPaths.setValueAtIndex $cmdPath, $i
end

$cmdPaths = $cmdPaths.join $LF
$cmdPaths = Cast to String $cmdPaths
Push Target Text $cmdPaths
   Set Font Name 'Lucida Grande'  # or another font having ⌘, ⌥, ⇧
Pop Target Text
Document.newWithText $cmdPaths

If you want a list of macros having shortcuts excluding those not, I think you can customize this one easily:
http://www2.odn.ne.jp/alt-quinon/files/NWPro/misc/ExportMenuKeys_nwm.zip


2010-05-26 09:04:48
Profile

Joined: 2007-04-12 14:59:36
Posts: 229
Marvellous!
For my personal use I added these lines, to have the Macros in a Table:
Code:
Find and Replace '\:Macro\:', '', 'Ea'
Select all
Convert to Table
Select All
Select Start

As well as a second macro (as clumsy as any, but) which rearranges the table with shortcuts first:
Code:
Select Table 1
Copy Table Text
Delete
Paste
Select End
Insert Text "\n"
Find and Replace '^(.*)\\t(.*)\\n', '\\2\\t\\1\\n', 'Ea'
Ascending (A-Z)
Convert to Table
Select All
Select Start
Reapplying it of course gets you back where you came from.


2010-05-26 13:51:46
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
js wrote:
In fact since the introduction of the present document manager the use oft this „Search“ window under Help has slowed down so much that it became far less useful than it used to be.

I see why this has happened. The Spotlight search in the Help menu builds an index of all menus in the application. The new Document Manager menu lists all files in the manager, which can take a while to populate/load (especially if you have many dynamic groups that use Spotlight to search through document content). I don't thinking searching those file name menus is particularly crucial, and I'll see if we can exclude them.


2010-06-01 14:08:42
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Bing [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software