Showing posts with label press. Show all posts
Showing posts with label press. Show all posts

How to press combination key using java Robot class ???


****************************************************************
COMPLETE SOURCE CODE FOR : PressCombinationKeyUsingRobot.java
****************************************************************


import java.awt.Robot;

import java.awt.event.KeyEvent;

public class PressCombinationKeyUsingRobot
{
public static void main(String[]args)
{
//Combination Alt+F4 is a window close order in windows operating system
//How to implement combination of Alt and F4 in using Robot class

try
{
Robot a=new Robot();
a.keyPress(KeyEvent.VK_ALT);
a.keyPress(KeyEvent.VK_F4);
a.keyRelease(KeyEvent.VK_ALT);
a.keyRelease(KeyEvent.VK_F4);
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


****************************************************************
JUST COMPILE AND EXECUTE IT
****************************************************************

How to make a program that can press keyboard for you ???


*******************************************************
COMPLETE SOURCE CODE FOR : PressKeyboard.java
*******************************************************


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

public class PressKeyboard
{
public static void main(String[]args)
{
try
{

Robot a=new Robot();

while(true)
{
//THIS PROGRAM WILL PRESS A FOR YOU
a.keyPress(KeyEvent.VK_A);

//THIS PROGRAM WILL SLEEP FOR 5 second
a.delay(5000);
}
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


*******************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************

RELAXING NATURE VIDEO