sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #51011
Re: [Question #679226]: Keyboard frozen after script run --- need to press ctrl-alt-c
Question #679226 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/679226
Chetan B gave more information on the question:
Hi ,
Sorry i sent wrong code,please find correct code below:
package Devicetesting;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.FileUtils;
import org.apache.commons.net.util.Base64;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Key;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.testng.Reporter;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class SikuliCommand extends Base1 {
public static String line = null;
public static String actualresult = "";
public static String expectedresult =
"df09020000000023edc2330870f8e7100010048e0890b3d51f300100000002007c17010902000700000500000b0200010700000500010b030040bd8052c1021076bffaad8520be7092354574d8d391";
public static int i;
public static boolean flag = false;
@Test
public static void Sikuli() throws IOException,
InterruptedException, FindFailed, AWTException {
try {
Screen screen = new Screen();
//
Runtime.getRuntime().exec("C:\\Windows\\System32\\cmd.exe");
// App app=new App("notepad.exe");
// App.open("C:\\Windows\\System32\\cmd.exe");
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.keyPress(KeyEvent.VK_R);
robot.keyRelease(KeyEvent.VK_WINDOWS);
robot.keyRelease(KeyEvent.VK_R);
Thread.sleep(2000);
screen.type("C:\\Windows\\System32\\cmd.exe");
robot.keyPress(KeyEvent.VK_ENTER);
Pattern commandprompt1 = new
Pattern("C:\\Sikulinotepad\\Commandprompt.png");
/*
Pattern commandprompt1 = new Pattern("C:\\Sikulinotepad\\Notepadedit.png");
Pattern commandprompt2 = new Pattern("C:\\Sikulinotepad\\Notepadpaste.png");
Pattern commandprompt3= new Pattern("C:\\Sikulinotepad\\Notepadfile.png");
Pattern commandprompt4 = new
Pattern("C:\\Sikulinotepad\\Notepadsaveas.png");
Pattern commandprompt5= new
Pattern("C:\\Sikulinotepad\\Notepadfilepath.png");
Pattern commandprompt6 = new
Pattern("C:\\Sikulinotepad\\Notepadfilesave.png");
Pattern commandprompt7= new Pattern("C:\\Sikulinotepad\\Notepadfile.png");
Pattern commandprompt8= new
Pattern("C:\\Sikulinotepad\\Notepadfilexit.png");
Pattern commandprompt9= new Pattern("C:\\Sikulinotepad\\Confirmsaveas.png");
// screen.click(commandC:prompt0);
C:
Thread.sleep(2000);
screen.click(commandprompt1);
screen.click(commandprompt2);
screen
*/
Thread.sleep(3000);
screen.click(commandprompt1);
screen.type("title firstcommandprompt");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("cd/");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("cd dist-db-17-08-2018");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("acb-r2.0.exe entityfile_00-0F.yaml 9089");
robot.keyPress(KeyEvent.VK_ENTER);
//====================================================================
//secondcommandprompt
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.keyPress(KeyEvent.VK_R);
robot.keyRelease(KeyEvent.VK_WINDOWS);
robot.keyRelease(KeyEvent.VK_R);
Thread.sleep(2000);
screen.type("C:\\Windows\\System32\\cmd.exe");
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(3000);
screen.click(commandprompt1);
screen.type("title Secondcommandprompt");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("cd/");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("cd dist-db-17-08-2018");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("echo %date%-%time%");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("receive.exe 21020");
robot.keyPress(KeyEvent.VK_ENTER);
//Third command prompt
robot.keyPress(KeyEvent.VK_WINDOWS);
robot.keyPress(KeyEvent.VK_R);
robot.keyRelease(KeyEvent.VK_WINDOWS);
robot.keyRelease(KeyEvent.VK_R);
Thread.sleep(2000);
screen.type("C:\\Windows\\System32\\cmd.exe");
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(3000);
screen.click(commandprompt1);
screen.type("title Thirdcommandprompt");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("cd/");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("cd dist-db-17-08-2018");
robot.keyPress(KeyEvent.VK_ENTER);
screen.type("send.exe 127.0.0.1 9089 gcs23.yaml");
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(2000);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_TAB);
Thread.sleep(2000);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_ALT);
Thread.sleep(4000);
for (int i = 0; i <= 0; i++) {
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_A);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_C);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.keyRelease(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_C);
Thread.sleep(3000);
Runtime.getRuntime().exec("C:\\Windows\\system32\\Notepad.exe");
// C:\Users\bodkec1\Pictures\img
Pattern commandprompt0 = new
Pattern("C:\\Sikulinotepad\\opennotepad.png");
Pattern commandprompt11 = new
Pattern("C:\\Sikulinotepad\\Notepadedit.png");
Pattern commandprompt2 = new
Pattern("C:\\Sikulinotepad\\Notepadpaste.png");
Pattern commandprompt3 = new
Pattern("C:\\Sikulinotepad\\Notepadfile.png");
Pattern commandprompt4 = new
Pattern("C:\\Sikulinotepad\\Notepadsaveas.png");
Pattern commandprompt5 = new
Pattern("C:\\Sikulinotepad\\Notepadfilepath.png");
Pattern commandprompt6 = new
Pattern("C:\\Sikulinotepad\\Notepadfilesave.png");
Pattern commandprompt7 = new
Pattern("C:\\Sikulinotepad\\Notepadfile.png");
Pattern commandprompt8 = new
Pattern("C:\\Sikulinotepad\\Notepadfilexit.png");
Pattern commandprompt9 = new
Pattern("C:\\Sikulinotepad\\Confirmsaveas.png");
// screen.click(commandprompt0);
Thread.sleep(2000);
screen.click(commandprompt11);
screen.click(commandprompt2);
screen.click(commandprompt3);
screen.click(commandprompt4);
// screen.click(commandprompt5);
Thread.sleep(3000);
screen.type(Key.DELETE);
screen.type("C:\\Responses\\gcs23.txt");
Thread.sleep(1000);
screen.click(commandprompt6);
screen.click(commandprompt9);
Thread.sleep(2000);
screen.click(commandprompt7);
screen.click(commandprompt8);
String fileName = "C:\\Responses\\gcs23.txt";
int counter = 0;
FileReader fileReader = null;
fileReader = new FileReader(fileName);
BufferedReader bufferedReader = new BufferedReader(fileReader);
while ((line = bufferedReader.readLine()) != null) {
counter++;
if (line.contains("FullData")) {
flag = true;
System.out.println("Base64" + line);
line = line.toString();
actualresult = line.substring(14);
System.out.println(actualresult);
break;
}
}
if (flag == true) {
break;
}
}
if (flag == false) {
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(3000);
String timeStamp = new
SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
BufferedImage image = new
Robot().createScreenCapture(new
Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "png", new
File("C:\\Screenshots\\Failed\\Gcs23.png"));
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_ENTER);
Pattern commandprompt9 = new
Pattern("C:\\dist-db-17-08-2018\\Sikuli\\Command.png");
Pattern commandprompt10 = new
Pattern("C:\\dist-db-17-08-2018\\Sikuli\\closeall.png");
screen.rightClick(commandprompt9);
screen.click(commandprompt10);
Thread.sleep(3000);
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_C);
Thread.sleep(2000);
// Runtime.getRuntime().exec("rundll32
user32.dll,LockWorkStation");
SoftAssert assert1 = new SoftAssert();
assert1.fail();
assert1.assertAll();
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_C);
}
//String guid =
"3QAAAAAAAEERAAAAAN8JAgAAAAAj5axnCHD45xAAEASOCJCz1R8wAQAAAAIAoQ0BCQEBBwkABQgACwCLAHQUrYRoxljDjduMFw==";
byte[] decoded = Base64.decodeBase64(actualresult);
String Actualresult = Hex.encodeHexString(decoded);
System.out.println("Actual Result in Hexadecimal" + Actualresult);
// Reporter.log("Actual Result:" + Actualresult);
String expectedresult1 = expectedresult.substring(0, 8);
String expectedresult2 = expectedresult.substring(24, 40);
String expectedresult3 = expectedresult.substring(42, 58);
String Actualresult1 = Actualresult.substring(0, 8);
System.out.println("expectedresult1" + expectedresult1);
System.out.println("Actualresult1" + Actualresult1);
String Actualresult2 = Actualresult.substring(24, 40);
System.out.println("expectedresult2" + expectedresult2);
System.out.println("Actualresult2" + Actualresult2);
String Actualresult3 = Actualresult.substring(42, 58);
System.out.println("expectedresult3" + expectedresult3);
System.out.println("Actualresult3" + Actualresult3);
if (Actualresult1.replaceAll("\\s+",
"").contains(expectedresult1.replaceAll("\\s+", "")) &&
(Actualresult2.replaceAll("\\s+",
"").contains(expectedresult2.replaceAll("\\s+", "")) &&
(Actualresult3.replaceAll("\\s+",
"").contains(expectedresult3.replaceAll("\\s+", ""))))) {
System.out.println("Expected Result Matches with the
actual result");
System.out.println("========================================================");
System.out.println("Actual Result1:" + Actualresult1);
System.out.println("Expected Result1:" + expectedresult1);
System.out.println("========================================================");
System.out.println("Actual Result2:" + Actualresult2);
System.out.println("Expected Result2:" + expectedresult2);
System.out.println("========================================================");
System.out.println("Actual Result3:" + Actualresult3);
System.out.println("Expected Result3:" + expectedresult3);
System.out.println("========================================================");
Reporter.log("Expected Result Matches with the actual
result");
Reporter.log("========================================================");
Reporter.log("Actual Result1:" + Actualresult1);
Reporter.log("Expected Result1:" + expectedresult1);
Reporter.log("========================================================");
Reporter.log("Actual Result2:" + Actualresult2);
Reporter.log("Expected Result2:" + expectedresult2);
Reporter.log("========================================================");
Reporter.log("Actual Result3:" + Actualresult3);
Reporter.log("Expected Result3:" + expectedresult3);
Reporter.log("========================================================");
String timeStamp = new
SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
File screenshot = ((TakesScreenshot)
screen).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new
File("C:\\Screenshots\\Passed\\Gcs23" + timeStamp + ".png"));
Reporter.log(timeStamp);
SoftAssert assert1 = new SoftAssert();
assert1.assertEquals("pass", "pass");
assert1.assertAll();
} else {
System.out.println("Actual result does not match with
expected result");
String timeStamp = new
SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
File screenshot = ((TakesScreenshot)
screen).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new
File("C:\\Screenshots\\Failed\\Gcs23" + timeStamp + ".png"));
SoftAssert assert1 = new SoftAssert();
assert1.fail();
assert1.assertAll();
}
} catch (FileNotFoundException ex) {
System.out.println(ex);
SoftAssert assert1 = new SoftAssert();
assert1.fail();
assert1.assertAll();
}
}
public static void main(String args[]) throws IOException,
InterruptedException, FindFailed, AWTException {
SikuliCommand.Sikuli();
}
}
Regards,
Chetan
Hi,
Yes I type in command
On Fri, Mar 15, 2019, 11:57 AM RaiMan <question679226@xxxxxxxxxxxxxxxxxxxxx>
wrote:
> Your question #679226 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/679226
>
> Status: Open => Needs information
>
> RaiMan requested more information:
> what version of SikuliX?
>
> How do you open the command prompt?
>
> Are you typing into the command prompt?
>
> --
> To answer this request for more information, you can either reply to
> this email or enter your reply at the following page:
> https://answers.launchpad.net/sikuli/+question/679226
>
> You received this question notification because you asked the question.
>
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.