AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
captureScreen () yoix.image
captureScreen (Component comp)  
captureScreen (Rectangle rect[, int raw])  
 
Returns an Image that represents a captured portion of the main display screen. With no arguments, the entire screen is captured. With a component argument, for example a JFrame or a JButton, then just the specified component is captured. When a Rectangle is provided, it specifies a portion of the screen to be captured. By default, the rectangle is assumed to be in Yoix coordinates, namely 72 units per inch. When a non-zero int argument is also supplied, then the coordinates are taken to be raw screen pixel coordinates.
 
 Return:   Image
 
 Example:   The program,
import yoix.*.*;

Image img = captureScreen(); 

JFrame f = {
  Dimension size = { int width = 72 * 6; int height = 72 * 5; };
  BorderLayout layoutmanager;
  int visible = TRUE;

  Array layout = {
    new JScrollPane {
      String tag = "$_pane";
      int    scroll = AS_NEEDED;

      Array layout = {
        new JPanel {
          String tag = "$_image";
          Image  backgroundimage = img;
          int backgroundhints = SCALE_NONE;
          Dimension preferredsize = img.size;
        },
      };
    },
    CENTER,
    new JPanel {
      FlowLayout layoutmanager;

      Array layout = {
        new JButton {
          String text = "Capture Screen";
          int    mnemonic = KeyCode.VK_S;
        
          actionPerformed(e) {
            img = captureScreen();
            root.components.$_image.size = img.size;
            root.components.$_image.backgroundimage = img;
          }
        },
        new JButton {
          String text = "Capture Frame";
          int    mnemonic = KeyCode.VK_F;
        
          actionPerformed(e) {
            img = captureScreen(root);
            root.components.$_image.size = img.size;
            root.components.$_image.backgroundimage = img;
          }
        },
        new JButton {
          String text = "Capture Rectangle";
          int    mnemonic = KeyCode.VK_R;
        
          actionPerformed(e) {
            img = captureScreen(new Rectangle{
              int x = random() * (VM.screen.width - 288);
              int y = random() * (VM.screen.height - 288);
              int width = 288;
              int height = 288;
            });
            root.components.$_image.size = img.size;
            root.components.$_image.backgroundimage = img;
          }
        },
        new JButton {
          String text = "Capture This!";
          int    mnemonic = KeyCode.VK_C;
        
          actionPerformed(e) {
            img = captureScreen(this);
            root.components.$_image.size = img.size;
            root.components.$_image.backgroundimage = img;
          }
        },
        new JButton {
          String text = "Quit";
          int    mnemonic = KeyCode.VK_Q;
        
          actionPerformed(e) {
            exit(0);
          }
        },
      };
    },
    SOUTH,
  };
};
creates a frame that initially displays a full screen capture in its scroll pane area. It also has buttons for updating the screen capture, for capturing just the frame itself, for capturing a random 4 inch square potion of the screen, for capturing an image of the button being pressed and for exiting.

 

Yoix is a registered trademark of AT&T Inc.