// This macro demonstrates how to use the getCursorLoc() function. // To use it, run the macro, open an image and move the cursor over it. // Try pressing the left mouse button and/or the shift, control or // alt keys. Pressing the alt key may not work on windows. // The macro stops running when the "Log" window is closed. // Information about tool macros is available at: // http://rsb.info.nih.gov/ij/developer/macro/macros.html#tools // // With ImageJ 1.42i or later, this macro displays "inside" // if the cursor is inside the current area selection. shift=1; ctrl=2; rightButton=4; alt=8; leftButton=16; insideROI = 32; // requires 1.42i or later x2=-1; y2=-1; z2=-1; flags2=-1; logOpened = false; if (getVersion>="1.37r") setOption("DisablePopupMenu", true); while (!logOpened || isOpen("Log")) { getCursorLoc(x, y, z, flags); if (x!=x2 || y!=y2 || z!=z2 || flags!=flags2) { s = " "; if (flags&leftButton!=0) s = s + ""; if (flags&rightButton!=0) s = s + ""; if (flags&shift!=0) s = s + ""; if (flags&ctrl!=0) s = s + " "; if (flags&alt!=0) s = s + ""; if (flags&insideROI!=0) s = s + ""; print(x+" "+y+" "+z+" "+flags + "" + s); logOpened = true; startTime = getTime(); } x2=x; y2=y; z2=z; flags2=flags; wait(10); } if (getVersion>="1.37r") setOption("DisablePopupMenu", false);