Added Percent and Carrot special keys sendKeys, take screen shot command, select list index command
This commit is contained in:
@@ -8,8 +8,13 @@
|
||||
package org.synthuse.commands;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.IOException;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.synthuse.*;
|
||||
|
||||
@@ -196,5 +201,32 @@ public class MainCommands extends BaseCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean cmdDisableStatus(String[] args) {
|
||||
if (!checkArgumentLength(args, 1))
|
||||
return false;
|
||||
boolean val = args[0].toUpperCase().equals("TRUE");
|
||||
parentProcessor.setQuiet(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cmdTakeScreenCapture(String[] args) {
|
||||
if (!checkArgumentLength(args, 1))
|
||||
return false;
|
||||
try {
|
||||
String saveName = args[0];
|
||||
if (!saveName.toLowerCase().endsWith(".png"))
|
||||
saveName += ".png";
|
||||
//LOG.debug("take Screen Capture " + new File(saveName).getAbsolutePath());
|
||||
Robot robot = new Robot();
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
BufferedImage image = robot.createScreenCapture(new Rectangle(screenSize));
|
||||
ImageIO.write(image, "png", new File(saveName));
|
||||
}
|
||||
catch(Exception e) {
|
||||
//e.printStackTrace();
|
||||
appendError(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,5 +194,23 @@ public class WindowsCommands extends BaseCommand {
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean cmdSelectListIndex(String[] args) {
|
||||
if (!checkArgumentLength(args, 2))
|
||||
return false;
|
||||
WinPtr handle = findHandleWithXpath(args[0]); //xpath to HWND is first argument
|
||||
if (handle.isEmpty())
|
||||
return false;
|
||||
handle.convertToNativeHwnd();
|
||||
int index = Integer.parseInt(args[1]);
|
||||
Api.SelectListItemByIndex(handle.hWnd, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean cmdSelectListString(String[] args) {
|
||||
//CB_SELECTSTRING
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user