Showing posts with label Java Selenium. Show all posts
Showing posts with label Java Selenium. Show all posts

Thursday, July 18, 2019

Create a Word Document using Sikuli using Java

To Download SIKULI JAR and IDE


  • https://launchpad.net/sikuli/+download - https://launchpad.net/sikuli/+download
  • SIKULI - GUI to identify the image and prepare script
    • Sikuli-IDE-win32-0.10.2.exe
    • In case the above file is available, you can download latest version IDE as well.

  • SIKULI JARs
    • sikuli-setup.jar (once you double click the file, you will get - sikulixapi.jar) i.e, below file.
    • sikulixapi.jar
    • Add this JAR into Eclipse in External JAR

Info: Sikuli tech used to create new WORD document and store it in specific path.
Finally closing it.

/**
 * @author Mano
 *
 */
package javaselenium;
import java.awt.AWTException;
import java.awt.Robot;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.sikuli.script.FindFailed;
import org.sikuli.script.Key;
import org.sikuli.script.Screen;

public class OpenMSOfficeUsingSikuli {

public static void main(String[] args) throws AWTException, FindFailed {
   
    Robot robot = new Robot();
    Screen sSikuli = new Screen();
       
        //Window Application using Sikuli     
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickStartButton.png");
        robot.delay(1000);
        sSikuli.type("MS Word");
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\ClickMSWord.png");
        robot.delay(1000);
       
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\ClickBlankDocument.jpg");
        robot.delay(1000);
        DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");  
        LocalDateTime now = LocalDateTime.now();
        sSikuli.type("This is Testing program, using SIKULI !! - Now the time is :"+now);
        robot.delay(1000);
       
        sSikuli.doubleClick("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickThisWord.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickBoldButton.png");
        robot.delay(1000);
       
        sSikuli.doubleClick("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickISWord.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickItalicWord.png");
        robot.delay(1000);
       
        sSikuli.doubleClick("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickTestingWord.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickUnderlineWord.png");
        robot.delay(1000);
       
        sSikuli.doubleClick("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickProgramWord.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickStrikeButton.png");
        robot.delay(1000);
       
        sSikuli.doubleClick("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickUsingWord.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickSubsetButton.png");
        robot.delay(1000);
       
        sSikuli.doubleClick("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickSIKULIWord.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickSupersetButton.png");
        robot.delay(1000);
       
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickFileMenu.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickSaveButton.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickBrowseButton.png");
    robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\selectToTypePath.png");
        robot.delay(1000);
        sSikuli.type("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp");
        robot.delay(1000);
       
        sSikuli.keyDown(Key.ENTER);
        robot.delay(1000);       
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\clickSavePopupButton.png");
        robot.delay(1000);
        sSikuli.click("E:\\Mano\\Java Selenium\\Sikuli\\WindowsApp\\closeWindowButton.png");       
    }


}

Read Excel FIle using Java Code in Selenium Automation

Below code is compile and Executed and it is working fine using below JAR files.



which are download from https://poi.apache.org/download.html
Note: Above mentioned specific version of file might not available in future.  So, NO WORRIES you can download the latest POI ZIP file using https://poi.apache.org/download.html

/**
 * @author Mano
 *
 */
package javaselenium;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class ReadExcelFile {

    public void readExcelFile(String filePath,String fileName,String sheetName) throws IOException{

    //Create an object of File class to open xlsx file
    File file =    new File(filePath+"\\"+fileName);

    //Create an object of FileInputStream class to read excel file
    FileInputStream inputStream = new FileInputStream(file);
    Workbook sampleWorkbook = null;

    //Find the file extension by splitting file name in substring  and getting only extension name
    String fileExtensionName = fileName.substring(fileName.indexOf("."));

    //Check condition if the file is xlsx file
    if(fileExtensionName.equals(".xlsx")){
    //If it is xlsx file then create object of XSSFWorkbook class
    sampleWorkbook = new XSSFWorkbook(inputStream);
    }

    //Check condition if the file is xls file
    else if(fileExtensionName.equals(".xls")){
        //If it is xls file then create object of HSSFWorkbook class
        sampleWorkbook = new HSSFWorkbook(inputStream);
    }

    //Read sheet inside the workbook by its name
    Sheet sampleSheet = sampleWorkbook.getSheet(sheetName);

    //Find number of rows in excel file
    int rowCount = sampleSheet.getLastRowNum()-sampleSheet.getFirstRowNum();

    //Create a loop over all the rows of excel file to read it
    for (int i = 0; i < rowCount+1; i++) {
        Row row = sampleSheet.getRow(i);

        //Create a loop to print cell values in a row
        for (int j = 0; j < row.getLastCellNum(); j++) {
        String cellData="";
       
            //Print Excel data in console
        cellData = (String)row.getCell(j).toString();
            System.out.print(cellData+" || ");
        }

        System.out.println();
    } 

    }  

    //Main function is calling readExcel function to read data from excel file
    public static void main(String[] args) throws IOException{

    //Create an object of ReadExcelFile class
    ReadExcelFile objExcelFile = new ReadExcelFile();

    //Prepare the path of excel file
    String filePath = "E:\\Mano\\Java Selenium\\";

    //Call read file method of the class to read data
    objExcelFile.readExcelFile(filePath,"SampleExcel.xlsx","SampleSheet");

    }

}

Sunday, July 14, 2019

Identify number of alerts raised to given username using Selenium Java

Steps used below:
1. Open IE browser
2. Login into IBM Sterling using username & password
3. Click login button
4. Open Alert Console screen
5. Input username in the Search box
6. Click the Search button
7. Fetch number of alerts

package javaselenium;
import java.awt.AWTException;
import java.awt.Robot;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class IdentifyAlertCount {

public static void main(String[] args) throws AWTException {
   
Robot robot = new Robot();

    // Creating a driver object referencing WebDriver interface
        WebDriver driver;
        
        // Setting the webdriver.ie.driver property to its executable's location
        System.setProperty("webdriver.ie.driver", "C:\\Driver\\IEDriverServer.exe");

        // Instantiating driver object
        driver = new InternetExplorerDriver();
        
        // Using get() method to open a webpage
        driver.get("http://localhost:7001/smcfs/console/login.jsp");
        
        // Maximizes the browser window
    driver.manage().window().maximize() ;
        
        // Set value to Username
        driver.findElement(By.name("UserId")).sendKeys("testuser");

        // Set value to Password
        driver.findElement(By.name("Password")).sendKeys("testuser");
        
        // Submit the Form
        driver.findElement(By.name("btnLogin")).submit(); 
        
        // Delay for 3 seconds
        robot.delay(3000);
        
        // Open Alert Console
        driver.get("http://localhost:7001/smcfs/console/exception.search");
        
        // Input - Username to whom the Alerts assigned
        driver.findElement(By.name("xml:/Inbox/User/@Loginid")).sendKeys("mano");
        driver.findElement(By.name("btnSearch")).click();

        // Delay for 1 seconds
        robot.delay(1000);

        // Obtaining value from Retrived records count
        JavascriptExecutor js = (JavascriptExecutor) driver;
        String records = (String) js.executeScript("return document.all['TotalNumRecs'].value");
        
        System.out.println("Total Records:"+records);
               
    }

}

Automate Inbound Shipment Confirmation in IBM Sterling using Selenium Java

Steps involved in Inbound Shipment Confirmation:

1. Open Internet Explorer Browser (IBM Sterling works fine in this Browser)
2. Open Login Screen
3. Input Username and Password to Login
4. Click Login form
5. Open Inbound Shipment Console (Out of the Box screen)
6. Input Seller, Buyer
7. Click "Create Shipment" button to Create the Shipment
8. Scroll down bit to Input Item Details to create Item into the Shipment
9. Input ItemID, ProductClass and Quantity
10. Save the Shipment
11. Confirm the Shipment

package javaselenium;
import java.awt.AWTException;
import java.awt.Robot;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.Select;

public class InboundShipmentConfirmation {

public static void main(String[] args) throws AWTException {
   
Robot robot = new Robot();

    // Creating a driver object referencing WebDriver interface
        WebDriver driver;
        
        // Setting the webdriver.ie.driver property to its executable's location
        System.setProperty("webdriver.ie.driver", "C:\\Driver\\IEDriverServer.exe");

        // Instantiating driver object
        driver = new InternetExplorerDriver();
        
        // Using get() method to open a webpage
        driver.get("http://localhost:7001/smcfs/console/login.jsp");
        
        // Maximizes the browser window
    driver.manage().window().maximize() ;
        
        // Set value to Username
        driver.findElement(By.name("UserId")).sendKeys("testuser");

        // Set value to Password
        driver.findElement(By.name("Password")).sendKeys("testuser");
        driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
        
        // Submit the Form
        driver.findElement(By.name("btnLogin")).submit(); 
        
        // Delay for 3 seconds
        robot.delay(3000);
        
        // Open Inbound Shipment Console
        driver.get("http://localhost:7001/smcfs/console/poshipment.detail?CurrentDetailViewID=YOMD7332");
        
        // Set Seller
        driver.findElement(By.name("xml:/Shipment/@SellerOrganizationCode")).sendKeys("KEDT");

        // Set Buyer
        driver.findElement(By.name("xml:/Shipment/@BuyerOrganizationCode")).sendKeys("EMEJE");

        // Create Shipment
        driver.findElement(By.xpath("//*[@type='button' and @class='button']")).click();     
        
        // Delay for 2 seconds
        robot.delay(2000);

        // Scroll the window 
        JavascriptExecutor js = (JavascriptExecutor) driver;  
      js.executeScript("window.scrollTo(0, 200)");

        // Add Item Details
      driver.findElement(By.name("xml:/Shipment/ShipmentLines/ShipmentLine_1/@ItemID")).sendKeys("XXJEF00003");
      Select selectProdClass = new Select(driver.findElement(By.name("xml:/Shipment/ShipmentLines/ShipmentLine_1/@ProductClass")));
      selectProdClass.selectByVisibleText("Y001");
      Select selectUOM = new Select(driver.findElement(By.name("xml:/Shipment/ShipmentLines/ShipmentLine_1/@UnitOfMeasure")));
      selectUOM.selectByVisibleText("EACH");
        driver.findElement(By.name("xml:/Shipment/ShipmentLines/ShipmentLine_1/@Quantity")).sendKeys("10");

        // Save Shipment
        driver.findElement(By.xpath("//*[@type='button' and @class='button']")).click();
        
        // Delay for 2 seconds
        robot.delay(2000);

        // Confirm Shipment
        driver.findElement(By.id("scbutton2")).click(); 
               
    }


}

Automate Login in IBM Sterling WMS using Selenium Java

In IBM Sterling WMS with version 9x.  Hope it will work for lower version too using below code.

After executing below code, it will automatically open Internet Explorer browser -> Open Sterling login screen (pls change URL for your code) -> Target Username field and set as anderson -> Target Password field and set as password and then click -> Submit button which will get logged in into the Sterling application.

1. Open Internet Explorer Browser (IBM Sterling works fine in this Browser)
2. Open Login Screen
3. Input Username and Password to Login
4. Click Login form

package javaselenium;
import java.awt.AWTException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;


public class InventoryAdjustment {

public static void main(String[] args) throws AWTException {   
 
    //Creating a driver object referencing WebDriver interface
        WebDriver driver;
        
        //Setting the webdriver.ie.driver property to its executable's location
        System.setProperty("webdriver.ie.driver", "C:\\Driver\\IEDriverServer.exe");
        //Instantiating driver object
        driver = new InternetExplorerDriver();
        
        //Using get() method to open a webpage
        driver.get("http://localhost:7001/smcfs/console/login.jsp");
        
        //Maximizes the browser window
    driver.manage().window().maximize() ;
        
        // Set value to Username
        driver.findElement(By.name("UserId")).sendKeys("anderson");

        // Set value to Password
        driver.findElement(By.name("Password")).sendKeys("password");
        driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
        
        // Submit the Form
        driver.findElement(By.name("btnLogin")).submit(); 
               
    }

 
}

Click hyperlink using Selenium Java in IBM Sterling

Step used to achieve:


1. Open Internet Explorer Browser (IBM Sterling works fine in this Browser)
2. Open Login Screen
3. Input Username and Password to Login
4. Click Login form
5. Identify the hyperlink using link text and click it


package javaselenium;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class InventoryAdjustment {

public static void main(String[] args) throws AWTException {
   
    Robot robot = new Robot();
   
    //Creating a driver object referencing WebDriver interface
        WebDriver driver;
        
        //Setting the webdriver.ie.driver property to its executable's location
        System.setProperty("webdriver.ie.driver", "C:\\Driver\\IEDriverServer.exe");

        //Instantiating driver object
        driver = new InternetExplorerDriver();
        
        //Using get() method to open a webpage
        driver.get("http://localhost:7001/smcfs/console/login.jsp");
        
        //Maximizes the browser window
    driver.manage().window().maximize() ;
        
        // Set value to Username
        driver.findElement(By.name("UserId")).sendKeys("testuser");

        // Set value to Password
        driver.findElement(By.name("Password")).sendKeys("testuser");
        driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
        
        // Submit the Form
        driver.findElement(By.name("btnLogin")).submit(); 
               
        driver.findElement(By.linkText("Search-by-XRXXFL2207")).click();
       
    }


}

Perform Adjust Location Inventory using Selenium Java

Perform Adjust Location Inventory using Selenium Java

Steps perform below to Adjust Location Inventory:
1. Login into IBM Sterling
2. Using IE Driver
3. Click Favorite link from Dashboard (Home page)
4. Favorite link internally search by ItemID (XRXXFL2207) in search panel
5. Get the auto Searched page
6. Click 4000-01 location from Search result
7. Select 1st record checkbox to Adjust inventory
8. Click AdjustLocationInventory button
9. Input ADJUSTMENT as ReasonCode
10. Select operation as Increase Inventory
11. Enter Quantity to increase as 10
12. Save the details
13. Close the poup window

----------------------------------------------------
InventoryAdjustment.java
----------------------------------------------------
package javaselenium;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import javaselenium.CustomRobot;

public class InventoryAdjustment {

public static void main(String[] args) throws AWTException {
   
    Robot robot = new Robot();
   
    //Creating a driver object referencing WebDriver interface
        WebDriver driver;
        
        //Setting the webdriver.ie.driver property to its executable's location
        System.setProperty("webdriver.ie.driver", "C:\\Driver\\IEDriverServer.exe");

        //Instantiating driver object
        driver = new InternetExplorerDriver();
        
        //Using get() method to open a webpage
        driver.get("http://localhost:7001/smcfs/console/login.jsp");
        
        //Maximizes the browser window
    driver.manage().window().maximize() ;
        
        // Set value to Username
        driver.findElement(By.name("UserId")).sendKeys("testuser");

        // Set value to Password
        driver.findElement(By.name("Password")).sendKeys("testuser");
        driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
        
        // Submit the Form
        driver.findElement(By.name("btnLogin")).submit(); 
               
        driver.findElement(By.linkText("Search-by-XRXXFL2207")).click();
       
        //Click Location 4000-01 from Search result
        driver.findElement(By.linkText("4000-01")).click();

        //Select checkbox from search result
        driver.findElement(By.xpath("//*[@name='chkEntityKey' and @type='checkbox' and @yHiddenInputName2='ItemKey_1']")).click();
       
        // Click AdjustLocationInventory button
        driver.findElement(By.id("scbutton2")).click();
       
        //Custom Robot instantiation logic     
        CustomRobot.typewrite("\t\t\tADJUSTMENT\t\t");
        CustomRobot.Press(KeyEvent.VK_DOWN, KeyEvent.VK_TAB);
        CustomRobot.typewrite("10");
        CustomRobot.typewrite("\t\t\t\t\t\t\t\n");
        robot.delay(3000);       
        CustomRobot.typewrite("\t\t\n");
    }

}

----------------------------------------------------
CustomRobot.java
----------------------------------------------------
package javaselenium;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class CustomRobot {

public static void Press(int... keycode) throws AWTException {
Press(keycode, 0, keycode.length);
}
private static void Press(int[] keyCodes, int offset, int length) throws AWTException {
Robot robot = new Robot();
if (length == 0) {
            return;
        }

        robot.keyPress(keyCodes[offset]);
        Press(keyCodes, offset + 1, length - 1);
        robot.keyRelease(keyCodes[offset]);
    }
public static void typewrite(CharSequence characters) throws AWTException {
        int length = characters.length();
        for (int i = 0; i < length; i++) {
            char character = characters.charAt(i);
            typewrite(character);
        }
    }
public static void typewrite(char character) throws AWTException {
        switch (character) {
        case 'a': Press(KeyEvent.VK_A); break;
        case 'b': Press(KeyEvent.VK_B); break;
        case 'c': Press(KeyEvent.VK_C); break;
        case 'd': Press(KeyEvent.VK_D); break;
        case 'e': Press(KeyEvent.VK_E); break;
        case 'f': Press(KeyEvent.VK_F); break;
        case 'g': Press(KeyEvent.VK_G); break;
        case 'h': Press(KeyEvent.VK_H); break;
        case 'i': Press(KeyEvent.VK_I); break;
        case 'j': Press(KeyEvent.VK_J); break;
        case 'k': Press(KeyEvent.VK_K); break;
        case 'l': Press(KeyEvent.VK_L); break;
        case 'm': Press(KeyEvent.VK_M); break;
        case 'n': Press(KeyEvent.VK_N); break;
        case 'o': Press(KeyEvent.VK_O); break;
        case 'p': Press(KeyEvent.VK_P); break;
        case 'q': Press(KeyEvent.VK_Q); break;
        case 'r': Press(KeyEvent.VK_R); break;
        case 's': Press(KeyEvent.VK_S); break;
        case 't': Press(KeyEvent.VK_T); break;
        case 'u': Press(KeyEvent.VK_U); break;
        case 'v': Press(KeyEvent.VK_V); break;
        case 'w': Press(KeyEvent.VK_W); break;
        case 'x': Press(KeyEvent.VK_X); break;
        case 'y': Press(KeyEvent.VK_Y); break;
        case 'z': Press(KeyEvent.VK_Z); break;
        case 'A': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_A); break;
        case 'B': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_B); break;
        case 'C': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_C); break;
        case 'D': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_D); break;
        case 'E': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_E); break;
        case 'F': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_F); break;
        case 'G': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_G); break;
        case 'H': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_H); break;
        case 'I': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_I); break;
        case 'J': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_J); break;
        case 'K': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_K); break;
        case 'L': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_L); break;
        case 'M': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_M); break;
        case 'N': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_N); break;
        case 'O': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_O); break;
        case 'P': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_P); break;
        case 'Q': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_Q); break;
        case 'R': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_R); break;
        case 'S': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_S); break;
        case 'T': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_T); break;
        case 'U': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_U); break;
        case 'V': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_V); break;
        case 'W': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_W); break;
        case 'X': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_X); break;
        case 'Y': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_Y); break;
        case 'Z': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_Z); break;
        case '`': Press(KeyEvent.VK_BACK_QUOTE); break;
        case '0': Press(KeyEvent.VK_0); break;
        case '1': Press(KeyEvent.VK_1); break;
        case '2': Press(KeyEvent.VK_2); break;
        case '3': Press(KeyEvent.VK_3); break;
        case '4': Press(KeyEvent.VK_4); break;
        case '5': Press(KeyEvent.VK_5); break;
        case '6': Press(KeyEvent.VK_6); break;
        case '7': Press(KeyEvent.VK_7); break;
        case '8': Press(KeyEvent.VK_8); break;
        case '9': Press(KeyEvent.VK_9); break;
        case '-': Press(KeyEvent.VK_MINUS); break;
        case '=': Press(KeyEvent.VK_EQUALS); break;
        case '~': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_QUOTE); break;
        case '!': Press(KeyEvent.VK_EXCLAMATION_MARK); break;
        case '@': Press(KeyEvent.VK_AT); break;
        case '#': Press(KeyEvent.VK_NUMBER_SIGN); break;
        case '$': Press(KeyEvent.VK_DOLLAR); break;
        case '%': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_5); break;
        case '^': Press(KeyEvent.VK_CIRCUMFLEX); break;
        case '&': Press(KeyEvent.VK_AMPERSAND); break;
        case '*': Press(KeyEvent.VK_ASTERISK); break;
        case '(': Press(KeyEvent.VK_LEFT_PARENTHESIS); break;
        case ')': Press(KeyEvent.VK_RIGHT_PARENTHESIS); break;
        case '_': Press(KeyEvent.VK_UNDERSCORE); break;
        case '+': Press(KeyEvent.VK_PLUS); break;
        case '\t': Press(KeyEvent.VK_TAB); break;
        case '\n': Press(KeyEvent.VK_ENTER); break;
        case '[': Press(KeyEvent.VK_OPEN_BRACKET); break;
        case ']': Press(KeyEvent.VK_CLOSE_BRACKET); break;
        case '\\': Press(KeyEvent.VK_BACK_SLASH); break;
        case '{': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_OPEN_BRACKET); break;
        case '}': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_CLOSE_BRACKET); break;
        case '|': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SLASH); break;
        case ';': Press(KeyEvent.VK_SEMICOLON); break;
        case ':': Press(KeyEvent.VK_COLON); break;
        case '\'': Press(KeyEvent.VK_QUOTE); break;
        case '"': Press(KeyEvent.VK_QUOTEDBL); break;
        case ',': Press(KeyEvent.VK_COMMA); break;
        case '<': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_COMMA); break;
        case '.': Press(KeyEvent.VK_PERIOD); break;
        case '>': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_PERIOD); break;
        case '/': Press(KeyEvent.VK_SLASH); break;
        case '?': Press(KeyEvent.VK_SHIFT, KeyEvent.VK_SLASH); break;
        case ' ': Press(KeyEvent.VK_SPACE); break;
        default:
            throw new IllegalArgumentException("Cannot type character " + character);
        }
    }
 
}

Popular Posts