Dear visitor, welcome to Jabaco - Community.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
import java.awt.Robot;
import java.awt.event.KeyEvent;
/**
* @author imran
* Description : Used to toggle the multimonitor display in Win XP.
*/
public class MultiMon {
public static void main(String[] args) {
try {
//Invoke the desktop setting applet, the 3rd tab should be selected
Runtime.getRuntime().exec("control.exe desk.cpl,@0,3");
//Pause for a second....
try {
Thread.sleep(1000);
}catch (InterruptedException ex){
}
//Create a new robot that can do the system interaction for us...
Robot robot = new Robot();
//Activate the "Display" field...
robot.keyPress(KeyEvent.VK_D + KeyEvent.ALT_MASK);
//Choose the second monitor
robot.keyPress(KeyEvent.VK_2);
//goto the "Extend my windows desktop" checkbox...
robot.keyPress(KeyEvent.VK_TAB);robot.keyPress(KeyEvent.VK_TAB);
robot.keyPress(KeyEvent.VK_TAB);robot.keyPress(KeyEvent.VK_TAB);
robot.keyPress(KeyEvent.ALT_MASK);
robot.keyPress(KeyEvent.VK_E );
//toggle the check box...
robot.keyPress(KeyEvent.VK_ENTER);
//clear references...
robot = null;
//exit the application
System.exit(0);
} catch (Exception e) {
// Things did'nt work out....
e.printStackTrace();
}
}
}
java.awt.Robot SendKeysRob;
public void SendKeys(String skey) {
SendKeys(skey, 0);
}
public void SendKeys(String skey, int wait) {
If (SendKeysRob = null) SendKeysRob = new Robot;
int a = Asc(skey);
SendKeysRob.keyPress(a);
If (wait > 0) SendKeysRob.delay(wait);
}
Jabaco Source
1
2
3
4
5
6
7
Dim SendKeysRob As java#awt#Robot
PublicSub SendKeys(skey AsString, Optional wait)
If SendKeysRob IsNothingThen SendKeysRob = New Robot
Dim a AsInteger = Asc(skey)
SendKeysRob.keyPress(a)
If wait > 0Then SendKeysRob.delay(wait)
EndSub