Here is my code:
Where I need to implement Print screen to validate the operation.
/*
Code is to test one module of S/w application. Here if char '1' is received from Serial1 of Leonardo,
then by using Keyboard library it will press Alt+f and then 'o' button to open the window.
As window is open. Test need to validate the open window by taking screen shot of window.
To take screen shot of window, print screen button need to press and release.
*/
void setup() { // initialize
Serial1.begin(9600);
Serial.begin(9600);
while (! Serial1);
while (! Serial);
Mouse.begin();
Keyboard.begin();
}
void loop() {
if (Serial1.available() > 0) {
char inChar = Serial1.read();
switch (inChar) {
case '1':
delay(1000);
Keyboard.press(KEY_LEFT_ALT);
delay(100);
Keyboard.press('f');
delay(100);
Keyboard.releaseAll();
delay(100);
Keyboard.press('o');
delay(100);
Keyboard.releaseAll();
delay(500);
//Here I want to do validation for open window. I need to take screen shot of open window by KeyBoard library.
//If print screen would be implemented then code would be as below:
// Keyboard.press(KEY_PRNT_SCRN); //Yet Did not find modifier key for Print screen.
// delay(100);
// Keyboard.releaseAll();
// //open microsoft paint to store screen shot
// Keyboard.press(KEY_LEFT_GUI) //window key
// Keyboard.press('r')
// delay(100);
// Keyboard.releaseAll();
//
// Keyboard.print("mspaint");
// delay(100);
// Keyboard.press(KEY_RETURN)
// delay(100);
// Keyboard.releaseAll();
// //Then Paste the screen shot by Cntrl+V and save the image.
break;
default:
Serial.print("Default Case");
} //switch end
} //if end
}//void loop End