isKeyDown and esc

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

isKeyDown and esc

Stackman317
Hi all,

So I've been trying to make a simple addition to some looping code so that I have the option to abort the macro at the end of each run, but I've been running into some problems interfacing with running macros. First of all, hitting esc has no effect on a running macro (even a very simple test macro). In addition, ImageJ seems to be having trouble detecting keystrokes in general. For instance, if I write code such as

for (i=1; i<=10; i++) {
        wait(1000);
        test = isKeyDown("space");
        print (test);
        if (test>0) {
                setKeyDown=("esc");
        }
}

it prints a string of 10 0s whether I hold down space or not.

I'm running ImageJ 4.0 64bit on my MacBook Pro running OS 10.5.4

Anyone have experience with problems like this with ImageJ?

Thanks for your help!!
Reply | Threaded
Open this post in threaded view
|

Re: isKeyDown and esc

Wayne Rasband
> So I've been trying to make a simple addition to some looping code  
> so that I
> have the option to abort the macro at the end of each run, but I've  
> been
> running into some problems interfacing with running macros. First  
> of all,
> hitting esc has no effect on a running macro (even a very simple test
> macro). In addition, ImageJ seems to be having trouble detecting  
> keystrokes
> in general. For instance, if I write code such as
>
> for (i=1; i<=10; i++) {
> wait(1000);
> test = isKeyDown("space");
> print (test);
> if (test>0) {
> setKeyDown=("esc");
> }
> }
>
> it prints a string of 10 0s whether I hold down space or not.
>
> I'm running ImageJ 4.0 64bit on my MacBook Pro running OS 10.5.4
>
> Anyone have experience with problems like this with ImageJ?

ImageJ cannot detect key presses unless the "ImageJ" window or an  
image window has focus. It will abort the currently running macro if  
it detects that the esc key was pressed.

-wayne