Creating / Removing Shortcuts

Hello,

Is there a way to remove application default shortcuts in order to assign those shortcuts to custom commands? I know I can use the Plugin -> Shortcuts -> Remove Shortcuts, but this seems to only let me remove shortcuts that I assign and not any of the default shortcuts. The problem is that there are very few keys left to assign shortcuts to and I’d like to use specific keys, but they aren’t available because they are being used for something else.

-Mike

One solution is to create a macro which overrides the shortcut key you want to use. E.g.:

macro 'Say Hello [b]' {
  showMessage("Hello there!");
}

Place this snippet in your StartupMacros.txt (or StartupMacros.fiji.ijm if you are using the Fiji distribution of ImageJ).

Then when you press B, you’ll see your macro execute instead of the built-in function (in this case: the Blobs sample image).

Thanks for the response! That seems to work perfectly. I was able to map "Process -> Binary -> Make Binary " by using:

macro 'Make Binary [b]' {
  run("Make Binary");
}

One more question: would there any way to be able to make a sequential macro that was able to answer dialog box questions? For example, currently I’m doing “Image -> Color -> Colour Deconvolution” then selecting H DAB from the Vectors dropdown. once that runs, I only need the Colour_2 Image, so I close the rest. Is there any way to make a macro that would run Colour Deconvolution, select H DAB, run the deconvolution, then close the Colour_1 & Colour_3 images?

(Or at the very least run the deconvolution and select H DAB, if closing the images can’t be done?)

ok I figured it out!!

this seems to be working:

macro 'PDGFRb [c]' {
  origtitle = getTitle();
  //write("imageID = " + origtitle);
  run("Colour Deconvolution", "vectors=[H DAB] hide");
  selectWindow(origtitle + "-(Colour_1)");
  close();
  selectWindow(origtitle + "-(Colour_3)");
  close();
  selectWindow(origtitle + "-(Colour_2)");
  //do this before calling make binary
  setOption("BlackBackground", false);
  run("Make Binary");
}

thanks for setting me on the right path!

1 Like

A post was split to a new topic: Reassigning shortcuts

A post was merged into an existing topic: Reassigning shortcuts

This approach somehow doesn’t work for me (I use Fiji). I cannot override next/previous slice shortcuts to navigate next frame instead. Macro’s are loaded and if I click them inside plugins/macros/ they do what they should do. But I can’t get it done with a shortcut. I tried to use [,]/[.] or [←]/[→] or [<]/[>] as shortcuts. None of them worked.

This is what I install:

macro 'Next Frame [.]' {
Stack.getPosition(channel, slice, frame);
Stack.setPosition(channel, slice, frame + 1);
}

macro 'Previous Frame [,]' {
Stack.getPosition(channel, slice, frame);
Stack.setPosition(channel, slice, frame - 1);
}

Enable the “Reverse CZT order of ‘>’ and ‘<’” option in Edit>Options>Misc and use the “>” and “<” shortcuts.

2 Likes

Hmm… there is an option for that and all read about this is to create macros. Thanks a lot.