Send keys to browser dialog windows

I would like to print pages after each click in Chrome. So script should perform a click and after that send “CTRL+P” to open printing dialog and “ENTER” to save page as PDF file.

plaidshirtakos said:

I would like to print pages after each click in Chrome. So script should perform a click and after that send “CTRL+P” to open printing dialog and “ENTER” to save page as PDF file.



Rustam Ismayilov said:

plaidshirtakos said:

I would like to print pages after each click in Chrome. So script should perform a click and after that send “CTRL+P” to open printing dialog and “ENTER” to save page as PDF file.



  

Sorry, but your reply is missing, comment is empty.

plaidshirtakos said:

I would like to print pages after each click in Chrome. So script should perform a click and after that send “CTRL+P” to open printing dialog and “ENTER” to save page as PDF file.

Try Java Robot class:

Robot robot = new Robot();

robot.keyPress(KeyEvent.VK_CONTROL)
robot.keyPress(KeyEvent.VK_P)
// CTRL+P is now pressed

robot.keyRelease(KeyEvent.VK_P)
robot.keyRelease(KeyEvent.VK_CONTROL)
// CTRL+P is now released
Import this:

import java.awt.Robot;
import java.awt.event.KeyEvent;

4 Likes