Seleção Null

[code]package robo;

import static java.awt.event.KeyEvent.VK_C;
import static java.awt.event.KeyEvent.VK_CONTROL;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.InputEvent;
import java.io.IOException;

import jxl.read.biff.BiffException;

public class Seleciona {

public static void main(String[] args)throws AWTException, IOException, BiffException, UnsupportedFlavorException, InterruptedException  {
	
	
	
	final int TIME_CONST = 10;
	
	Robot robot = new Robot(); 
	
	RobotManager manager = new RobotManager(robot);	
	
	robot.delay(4000);  
	
	robot.mouseMove(964,326);	
	
	Thread.sleep(TIME_CONST); 
	
	robot.mousePress(InputEvent.BUTTON1_MASK);
	robot.mouseRelease(InputEvent.BUTTON1_MASK);
	
	robot.mousePress(InputEvent.BUTTON1_MASK);
	robot.mouseRelease(InputEvent.BUTTON1_MASK);
	
	Thread.sleep(TIME_CONST);   

	manager.typeSequence(VK_CONTROL,VK_C); 
    Thread.sleep(TIME_CONST);
    
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();             
    Transferable contents = clipboard.getContents(clipboard);
    
    
      
    
    
    String copyResult = "";
    copyResult = (String) contents.getTransferData(DataFlavor.stringFlavor);
    
    System.out.println(copyResult.trim());
    
	
	
	
	
}

}[/code]

Em qual linha está dando seu NullPointerException? Assim só de olho só posso imaginar…

Talvez seja aqui:

 String copyResult = "";  
 copyResult = (String) contents.getTransferData(DataFlavor.stringFlavor);   // Aqui nesse trecho. 
          
 System.out.println(copyResult.trim());

Se for, basta uma verificação pra saber se esse valor é null e definir o que fazer com ele caso seja. Como você tentou fazer essa verificação? Pra efeito de exemplo segue esse trecho:

String myStr = null;

if(myStr!=null){
    myStr = myStr.trim();
} else {
    throw new Exception("Oh não... Não pode ser nulo");
}

Abs []

[code]package robo;

import static java.awt.event.KeyEvent.VK_C;
import static java.awt.event.KeyEvent.VK_CONTROL;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.InputEvent;
import java.io.IOException;

import jxl.read.biff.BiffException;

public class Seleciona {

public static void main(String[] args)throws Exception  {
	
	try{
	
	final int TIME_CONST = 10;
	
	Robot robot = new Robot(); 
	
	RobotManager manager = new RobotManager(robot);	
	
	robot.delay(4000);  
	
	robot.mouseMove(964,326);	
	
	Thread.sleep(TIME_CONST); 
	
	robot.mousePress(InputEvent.BUTTON1_MASK);
	robot.mouseRelease(InputEvent.BUTTON1_MASK);
	
	robot.mousePress(InputEvent.BUTTON1_MASK);
	robot.mouseRelease(InputEvent.BUTTON1_MASK);
	
	Thread.sleep(TIME_CONST);   

	manager.typeSequence(VK_CONTROL,VK_C); 
    Thread.sleep(TIME_CONST);
    
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();             
    Transferable contents = clipboard.getContents(clipboard);
    
    
    String copyResult = null;
    copyResult = (String) contents.getTransferData(DataFlavor.stringFlavor);
    
    if(copyResult!=null){
    	copyResult = copyResult.trim();
    	System.out.println(copyResult.trim());
    	
    } else {
        throw new Exception("Oh não... Não pode ser nulo");
    }
    
    
    
	}catch (BiffException e) {
		e.printStackTrace();
		  		
	
	 
	}
	
	
	
}

}
[/code]

Exception in thread "main" java.io.IOException: system clipboard data unavailable at sun.awt.windows.WClipboard.getClipboardData(Native Method) at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(Unknown Source) at sun.awt.datatransfer.ClipboardTransferable.<init>(Unknown Source) at sun.awt.datatransfer.SunClipboard.getContents(Unknown Source) at robo.Seleciona.main(Seleciona.java:50)

[quote]Pessoal não consegui resolver o problema ainda, sempre que o mouse seleciona uma região da tela que não possui texto o programa retorna erro! Alguém teria uma sugestão? Obrigado.

Erro:[/quote]

Exception in thread "main" java.io.IOException: system clipboard data unavailable at sun.awt.windows.WClipboard.getClipboardData(Native Method) at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(Unknown Source) at sun.awt.datatransfer.ClipboardTransferable.<init>(Unknown Source) at sun.awt.datatransfer.SunClipboard.getContents(Unknown Source) at robo.Seleciona.main(Seleciona.java:50)

Coloca um try catch para capturar essa exceção

at sun.awt.windows.WClipboard.getClipboardData(Native Method) at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(Unknown Source) at sun.awt.datatransfer.ClipboardTransferable.<init>(Unknown Source) at sun.awt.datatransfer.SunClipboard.getContents(Unknown Source) at robo.Seleciona.main(Seleciona.java:50)

[code]package robo;

import static java.awt.event.KeyEvent.VK_C;
import static java.awt.event.KeyEvent.VK_CONTROL;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.InputEvent;
import java.io.IOException;

import jxl.read.biff.BiffException;

public class Seleciona {

public static void main(String[] args)throws AWTException, IOException, BiffException, UnsupportedFlavorException, InterruptedException  {
	
	try{
	
	final Integer TIME_CONST = 10;
	
	Robot robot = new Robot(); 
	
	RobotManager manager = new RobotManager(robot);	
	
	robot.delay(4000);  
	
	robot.mouseMove(964,326);	
	
	Thread.sleep(TIME_CONST); 
	
	robot.mousePress(InputEvent.BUTTON1_MASK);
	robot.mouseRelease(InputEvent.BUTTON1_MASK);
	
	robot.mousePress(InputEvent.BUTTON1_MASK);
	robot.mouseRelease(InputEvent.BUTTON1_MASK);
	
	Thread.sleep(TIME_CONST);   

	manager.typeSequence(VK_CONTROL,VK_C); 
	Thread.sleep(TIME_CONST);
    
   Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();             
   Transferable contents = clipboard.getContents(clipboard);
      
      
    if (contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
    	
    	String copyResult = (String)contents.getTransferData(DataFlavor.stringFlavor);
    
   	    
    System.out.println(copyResult);
    
    }
    
    } catch (IOException e) {
    	
    	e.printStackTrace();
		
    }
	
}

}[/code]

Faz isso:

Transferable contents; 
try {
      contents = clipboard.getContents(clipboard); 
} catch (IOException e) {  
      contents = null;             
}