home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2001 February / Internet Magazine February 2001.iso / mac / SOFTWARE / MAC / UTILITIES / NETFINDER / NETFINDER.HQX / NetFinder v2.2b5 / Scripts / Command Key Setup Script next >
Encoding:
Text File  |  2000-09-04  |  4.2 KB  |  123 lines

  1. /* 
  2.     Sample ICI script for NetFinder.
  3.     
  4.     This script demonstrates how to customize the command key shortcuts
  5.     used to quickly access a menu command.
  6.     
  7.     Cool Idea:
  8.     Move this script into the "NetFinder Startup Items" folder and have your
  9.     command key shortcuts always loaded upon application startup.
  10.     Of course the ICILib script engine must be installed.
  11.     
  12.     NOTES:
  13.     o Full ICI programming syntax can be obtained from
  14.       <http://www.zeta.org.au/~atrn/ici/documentation.html>
  15.     
  16.     (c) Copyright 2000 Peter Li.
  17.  
  18.     ========================================================================
  19.     Like the method used to set command key shortcuts for scripts
  20.     (summarized below) we use the same format to re-define command
  21.     key shortcuts for existing menu commands.
  22.     
  23.     eg  if "My HTML Pages URL\aocsP" is the filename of a Shortcut on disk.
  24.         Then the menu item will be shown as "My HTML Pages URL" with the command
  25.         key being APPLE + OPTION + CONTROL + SHIFT and the letter "P"
  26.  
  27.     where   \ = command/modifier key sequence begin tag
  28.             a = Apple Key Modifier
  29.             o = Option Key Modifier
  30.             c = Control Key Modifier
  31.             s = Shift Key Modifier
  32.             P = command key to use, in this case the letter 'P'.
  33.     NOTE: the order of modifiers is important.
  34.  
  35.     =======================================================================
  36.     Note in this script, we use constants like kCmdNewFolder or we can use
  37.     a raw form OSType("NDir"). The advantage of the latter is that we dont
  38.     need to load the constants via the NFLoadModuleConstants() call.
  39.     This is only a concern if speed is an issue. Using the constants makes
  40.     the script a bit more readable.
  41.     
  42.     Also note, we use two \ characters instead of one, because the \ character
  43.     is a special character that is interpreted differently in a script when 
  44.     inside a quoted string.    
  45.     
  46.     For more information on all the available constants used by all the commands
  47.     in the various menus in NetFinder, please read the documentation named
  48.     "Inside NetFinder for ICI.html" found in the Modules folder.
  49.  */
  50.  
  51. /* load in some constants exported by NF, so we dont have to use numbers */
  52. NFLoadModuleConstants();
  53.  
  54. /*
  55.     Uncomment the following line (remove the "//" characters) to make
  56.     the command key shortcut for New Directory be OPTION+N as opposed
  57.     to the default APPLE+N.
  58.  */
  59.  
  60. //NFSetModifiersForCommand(OSType("NDir"), "\\oN");            /* OPTION + N */
  61.  
  62.  
  63. /*
  64.     The following lines defines entirely new command shortcuts to 
  65.     commands that previously didnt have a command key shortcut.
  66.     You are more than welcome to add or alter any command key
  67.     shortcuts you like.
  68.  */
  69.  
  70. // View Sub Menu Additions
  71. NFSetModifiersForCommand(kCmdViewInBrowser, "\\asB");        /* APPLE + SHIFT + B */
  72.  
  73. // Edit Menu Additions
  74. NFSetModifiersForCommand(kCmdSetPermissions, "\\oP");        /* OPTION + P */
  75.  
  76.  
  77. // Windows Menu Additions
  78. NFSetModifiersForCommand(kCmdShowTranscriptWin, "\\o1");    /* OPTION + 1 */
  79. NFSetModifiersForCommand(kCmdShowTransferLogWin, "\\o2");    /* OPTION + 2 */
  80. NFSetModifiersForCommand(kCmdShowPartialFileWin, "\\o3");    /* OPTION + 3 */
  81.  
  82. // Shortcuts/Favorites Menu Additions
  83. NFSetModifiersForCommand(kCmdAddToFavorites, "\\oA");        /* OPTION + A */
  84.  
  85. // ======================================================================
  86.  
  87. auto GLYPH_COMMAND = "";
  88. auto F1 = 111;
  89. auto F2 = 112;
  90. auto F3 = 113;
  91. auto F4 = 114;
  92. auto F5 = 115;
  93. auto F6 = 116;
  94. auto F7 = 117;
  95. auto F8 = 118;
  96. auto F9 = 119;
  97. auto F10 = 120;
  98. auto F11 = 121;
  99. auto F12 = 122;
  100. auto F13 = 135;
  101. auto F14 = 136;
  102. auto F15 = 137;
  103.  
  104. // Change the following from 0 to 1 to setup Windoze like keys bindings.
  105. auto SIMULATE_WINDOWS = 0;
  106.  
  107. if (SIMULATE_WINDOWS)
  108. {
  109.     // remap the label command keys, otherwise they will conflict.
  110.     NFSetModifiersForCommand(kCmdLabelNone, "\\" + GLYPH_COMMAND);
  111.     NFSetGlyphForCommand(kCmdLabelNone, F13);
  112.  
  113.     // F4 -> refresh window
  114.     // Dont know why using F5 does not work!?
  115.     NFSetModifiersForCommand(kCmdRefreshSelection, "\\" + GLYPH_COMMAND);    /* KEY */
  116.     NFSetGlyphForCommand(kCmdRefreshSelection, F4);                            /* Setup Glyph for F5 */
  117.  
  118.     // ALT + F4 -> close window
  119.     NFSetModifiersForCommand(kCmdFileClose, "\\o" + GLYPH_COMMAND);            /* OPTION + KEY */
  120.     NFSetGlyphForCommand(kCmdFileClose, F4);                                /* Setup Glyph for F4 */
  121.  
  122. }
  123.