Login  Register

Re: Keystroke inputs in a macro?

Posted by Michael Schmid on Dec 03, 2008; 10:18am
URL: http://imagej.273.s1.nabble.com/Keystroke-inputs-in-a-macro-tp3694347p3694348.html

Hi Bill,

the only other possibility that I am aware of is the isKeyDown(key)  
function, which is restricted to the "shift", "alt" and "space" keys.

You can also use getCursorLoc(x, y, z, modifiers) and wait for a  
mouse key (encoded in the modifiers)
       leftButton=16;
       rightButton=4;
if (modifiers&leftButton!=0) ...

For other keys, I think that one would have to write a plugin that  
registers as a keyListener of the main ImageJ panel. Probably it  
should also have a pop-up window to tell the user that he should  
press a key.

Michael
________________________________________________________________

On 3 Dec 2008, at 00:40, Bill Mohler wrote:

> Can a macro accept keystrokes as user input in ways other than:
>
> 1. a shortcut key that starts a macro running
> 2. entries into a dialog field
>
> I'm wondering whether a macro can await a letter or number  
> keystroke, and then execute some routine in response.  Or would  
> that have to be coded in a plugin?
>
> Thanks,
> Bill