I want to make a program which takes screenshot whenever it runs. For that, I thought of using virtual keys but i am not able to press two keys simultaneously. I am trying to do this in Microsoft windows 8.1 and trying to press + Print Scrn simultaneously.
Asked
Active
Viewed 567 times
0

NathanOliver
- 171,901
- 28
- 288
- 402

nitish-d
- 241
- 2
- 11
-
possible duplicate of [how to make screen screenshot with win32 in c++?](http://stackoverflow.com/questions/3291167/how-to-make-screen-screenshot-with-win32-in-c) – NathanOliver May 21 '15 at 12:06
-
No, this is not what I want. I want to press and hold windows logo key and then press prtscn and then release those two buttons. – nitish-d May 21 '15 at 12:09
-
Your title says: `without pressing any key`. So which is it? – NathanOliver May 21 '15 at 12:10
-
I meant without pressing it physically. – nitish-d May 21 '15 at 12:11
1 Answers
1
You can send multiple keys to the OS with keybd_event()
. The first time you call it you will send the windows key and tell it to stay down. Then you will do the same with the printscreen button. After you do that you need to call the function again to lift each key in reverse order. You should be able to use:
keybd_event(VK_LWIN, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);

NathanOliver
- 171,901
- 28
- 288
- 402