Waitforuser press a key

Tags: #<Tag:0x00007fb87e48b5a0>


Hi Everyone,

We know about the waitforuser function, where we have to click the “OK” button to continue. Is it possible to continue by pressing a spacebar or some other key (or there is a function available which can do this)?

I am aware that using Java it is possible (like in Java "press space bar to continue"), but I am seeking something that can be implemented using IJ macro programming.

Thanks in advance.



Sorry for the delay in response - so I’m not sure this will answer your question… but I was perusing the Built-In Macro Functions page and found this guy:

Returns true if the specified key is pressed, where key must be “shift”, “alt” or “space”. See also: setKeyDown.

Perhaps you can use this function with an if statement or so within your code? Hope this helps a little in any case…



Dear @Jpp,

Something like the following should work (at least is has worked in my short tests):

// Do something
// Wait for input:
while (!isKeyDown("shift")) {
// Do something after Shift was pressed

And thanks @etarena for bringing isKeyDown() back to my attention. Had already forgotten about that :wink: