Difference between revisions of "Keyboard shortcuts"

(Option 2: Associate shortcut to a plugin menu entry: Use code block for file path)
m (Assign a shortcut to a macro: Add option via macro toolsets)
Line 22: Line 22:
  
 
== Assign a shortcut to a macro ==
 
== Assign a shortcut to a macro ==
There are 2 options to assign a keyboard shortcut to a macro.<br>
+
There are 3 options to assign a keyboard shortcut to a macro.<br>
  
=== Option 1: StartupMacros ===
+
=== Option 1: Edit the StartupMacros file ===
Either put the code of the macro in the file macro>StartupMacros.ijm (or StartupMacros.fiji.ijm in Fiji) to have it installed automatically.<br>
+
Either put the code of the macro in the file macro>StartupMacros.ijm (or StartupMacros.fiji.ijm in Fiji) to have it installed automatically at startup.<br>
The code of the macro must declared a keyboard shortcut in square bracket as such
+
The code of the macro must declare a keyboard shortcut in square bracket as such
 
<source>
 
<source>
 
macro "Macro 1 [1]" {
 
macro "Macro 1 [1]" {
Line 33: Line 33:
 
</source>
 
</source>
  
=== Option 2: Associate shortcut to a plugin menu entry ===
+
=== Option 2: Save the macro(s) as a toolset ===
 +
The shortcut should be defined in square bracket like for option 1, but instead of editing the existing StartupMacros file, the macros(s) can be saved as a separate MyShortcut.ijm or .txt file in the ImageJ/Fiji subfolder <code>macros/toolsets</code>.<br>
 +
Then restart ImageJ/Fiji and click the {{bc|>>}} at the rightmost side of the fiji toolbar and click the entry MyShortcut. This will install your macros and thus activate the associated shortcuts.<br>
 +
This option is more convenient to distribute macros with keyboard shortcuts to colleagues or via an update site.
 +
 
 +
=== Option 3: Associate shortcut to a plugin menu entry ===
 
The second possibility consist in saving the macro code as a small script file into the <code>./Fiji.app/scripts/Plugins/</code> folder, so that it appears in the menu upon restart.<br>  
 
The second possibility consist in saving the macro code as a small script file into the <code>./Fiji.app/scripts/Plugins/</code> folder, so that it appears in the menu upon restart.<br>  
 
Then you can register a shortcut using {{bc|Plugins|Shortcuts|Add Shortcut…}}
 
Then you can register a shortcut using {{bc|Plugins|Shortcuts|Add Shortcut…}}
  
 
[[Category:User interface]]
 
[[Category:User interface]]

Revision as of 05:46, 13 January 2020

ImageJ has a lot of keyboard shortcuts.

Listing all keyboard shortcuts

For a verbose list of keyboard shortcuts, call Plugins  › Shortcuts  › List Shortcuts.

The Command Launcher

Use ^ Ctrl+L (on Mac, Command+L) to open the Command Launcher, to call menu entries by name.

Recent Commands

To open a list of some recent commands, and a list of the most frequently called commands, hit ^ Ctrl+9 (on Mac, Command+9).

Open

To open new images, type ^ Ctrl+O (on Mac, Command+O).

Creating your own keyboard shortcuts

You can also assign your own keyboard shortcuts!

Assign a shortcut to a macro

There are 3 options to assign a keyboard shortcut to a macro.

Option 1: Edit the StartupMacros file

Either put the code of the macro in the file macro>StartupMacros.ijm (or StartupMacros.fiji.ijm in Fiji) to have it installed automatically at startup.
The code of the macro must declare a keyboard shortcut in square bracket as such

macro "Macro 1 [1]" {
    print("The user pressed '1'");
    } 

Option 2: Save the macro(s) as a toolset

The shortcut should be defined in square bracket like for option 1, but instead of editing the existing StartupMacros file, the macros(s) can be saved as a separate MyShortcut.ijm or .txt file in the ImageJ/Fiji subfolder macros/toolsets.
Then restart ImageJ/Fiji and click the >> at the rightmost side of the fiji toolbar and click the entry MyShortcut. This will install your macros and thus activate the associated shortcuts.
This option is more convenient to distribute macros with keyboard shortcuts to colleagues or via an update site.

Option 3: Associate shortcut to a plugin menu entry

The second possibility consist in saving the macro code as a small script file into the ./Fiji.app/scripts/Plugins/ folder, so that it appears in the menu upon restart.
Then you can register a shortcut using Plugins › Shortcuts › Add Shortcut…