//  This macro demonstrates how to use the getCursorLoc() function.
//  To use it, run the macro, open an image and move the cursor over it. 
//  Also try pressing the left mouse button and/or the shift, control or 
//  alt keys. Pressing the right mouse button, or click-control on a Mac,
//  displays a pop-up menu. There needs to be a way to disable 
//  this feature. Pressing the alt key may not work on windows.
//  The macro quits 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

      leftButton=16;
      rightButton=4;
      shift=1;
      ctrl=2; 
      alt=8;
      x2=-1; y2=-1; z2=-1; flags2=-1;
      logOpened = false;
      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 + "<left>";
              if (flags&rightButton!=0) s = s + "<right>";
              if (flags&shift!=0) s = s + "<shift>";
              if (flags&ctrl!=0) s = s + "<ctrl> ";
              if (flags&alt!=0) s = s + "<alt>";
              // if (isKeyDown("alt")) s = s + "<alt>";
              // if (isKeyDown("shift")) s = s + "<shift>";
              // if (isKeyDown("space")) s = s + "<space>";
              print(x+" "+y+" "+z+" "+flags + "" + s);
              logOpened = true;
              startTime = getTime();
          }
          x2=x; y2=y; z2=z; flags2=flags;
          wait(10);
      }



