net.sourceforge.groboutils.uicapture.v1
Class VirtualWindowController

java.lang.Object
  extended bynet.sourceforge.groboutils.uicapture.v1.VirtualWindowController

public class VirtualWindowController
extends java.lang.Object

A window which covers the whole screen, and does not paint in the background. It captures keyboard and mouse events, and sends them to both all registered listeners, and to the underlying GUI as well. WARNING: if the screen size is to resize, then this will not work correctly.

Version:
Jan 4, 2002
Author:
Matt Albrecht groboclown@users.sourceforge.net

Constructor Summary
VirtualWindowController()
          Uses the Default version for the IScreenScraper and IFocusedWindowFinder.
VirtualWindowController(IScreenScraper ss, IFocusedWindowFinder fwf)
          Create using the given arguments to build the framework.
 
Method Summary
protected  void assertActive()
           
protected  void assertInactive()
           
 void begin()
          Begin the reinactment process.
 boolean compareFiles(java.io.File one, java.io.File two)
          Compares the two files for identity.
 void end()
          Complete the reinactment process.
 java.awt.Rectangle getBounds()
          Retrieves the size and position of the capture area of the screen.
 java.lang.String getImageExtension()
           
 void moveMouse(int x, int y)
          Simulate a mouse movement.
 void pressKey(int keyCode)
          Simulate a key press.
 void pressMouse(int modifiers)
          Simulate a mouse button press.
 void releaseKey(int keyCode)
          Simulate a key release.
 void releaseMouse(int modifiers)
          Simulate a mouse button release.
 void rotateMouseWheel(int rotation)
          Simulate a mouse wheel rotation.
 void saveFocusedWindow(java.lang.String filename)
          Saves a picture of the underlying UI's focused window to a file.
 void saveScreen(java.lang.String filename)
          Saves the entire screen to a file.
 void saveScreenImage(java.lang.String filename, int x, int y, int w, int h)
          Saves the selected screen part to a file.
 void saveScreenImage(java.lang.String filename, java.awt.Rectangle bounds)
          Saves the selected screen part to a file.
 void sleep(long milliseconds)
          Pause for a period of milliseconds.
 void waitForIdle()
          Waits until all events currently on the event queue have been processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualWindowController

public VirtualWindowController()
Uses the Default version for the IScreenScraper and IFocusedWindowFinder.


VirtualWindowController

public VirtualWindowController(IScreenScraper ss,
                               IFocusedWindowFinder fwf)
Create using the given arguments to build the framework.

Method Detail

begin

public void begin()
           throws java.awt.AWTException
Begin the reinactment process.

Throws:
java.awt.AWTException - thrown if a Robot is not supported in the current JDK implementation.

end

public void end()
Complete the reinactment process.


sleep

public void sleep(long milliseconds)
Pause for a period of milliseconds. Since Robot can only delay for 60 seconds at a time, this will first sleep using the Robot, then will use Thread for the remainder of the time.

Parameters:
milliseconds - Time in milliseconds to sleep.

waitForIdle

public void waitForIdle()
Waits until all events currently on the event queue have been processed.


getBounds

public java.awt.Rectangle getBounds()
Retrieves the size and position of the capture area of the screen.

Returns:
the screen size.

compareFiles

public boolean compareFiles(java.io.File one,
                            java.io.File two)
                     throws java.io.IOException
Compares the two files for identity.

Returns:
true if the files are identical, else false.
Throws:
java.io.IOException

getImageExtension

public java.lang.String getImageExtension()

saveScreen

public void saveScreen(java.lang.String filename)
                throws java.io.IOException
Saves the entire screen to a file.

Parameters:
filename - the file to save the image as.
Throws:
java.io.IOException - thrown if there was a problem writing the file.

saveFocusedWindow

public void saveFocusedWindow(java.lang.String filename)
                       throws java.io.IOException
Saves a picture of the underlying UI's focused window to a file.

Parameters:
filename - the file to save the image as.
Throws:
java.io.IOException - thrown if there was a problem writing the file.

saveScreenImage

public void saveScreenImage(java.lang.String filename,
                            int x,
                            int y,
                            int w,
                            int h)
                     throws java.io.IOException
Saves the selected screen part to a file.

Parameters:
filename - the file to save the image as.
x - the x position of the part of the screen to grab.
y - the y position of the part of the screen to grab.
w - the width of the part of the screen to grab.
h - the height of the part of the screen to grab.
Throws:
java.io.IOException - thrown if there was a problem writing the file.

saveScreenImage

public void saveScreenImage(java.lang.String filename,
                            java.awt.Rectangle bounds)
                     throws java.io.IOException
Saves the selected screen part to a file.

Parameters:
filename - the file to save the image as.
bounds - the part of the screen to grab.
Throws:
java.io.IOException - thrown if there was a problem writing the file.

moveMouse

public void moveMouse(int x,
                      int y)
Simulate a mouse movement.

Parameters:
x - the x position (aboslute) to move the mouse to.
y - the y position (aboslute) to move the mouse to.

pressMouse

public void pressMouse(int modifiers)
Simulate a mouse button press.

Parameters:
modifiers - the mouse button modifiers.

releaseMouse

public void releaseMouse(int modifiers)
Simulate a mouse button release.

Parameters:
modifiers - the mouse button modifiers.

rotateMouseWheel

public void rotateMouseWheel(int rotation)
Simulate a mouse wheel rotation.

Parameters:
rotation - the number of 'clicks' to rotate the mouse wheel.

pressKey

public void pressKey(int keyCode)
Simulate a key press.

Parameters:
keyCode - the key code of the key.

releaseKey

public void releaseKey(int keyCode)
Simulate a key release.

Parameters:
keyCode - the key code of the key.

assertActive

protected void assertActive()

assertInactive

protected void assertInactive()


Copyright © 2001-2003 by The GroboUtils Project