Keystroke inputs in a macro?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Keystroke inputs in a macro?

Bill Mohler
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
Reply | Threaded
Open this post in threaded view
|

Re: Keystroke inputs in a macro?

Michael Schmid
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