Author: Jonas Bilinkevicius
How can I manually call the "hardcopy" function (PrtScr) or how can I trick it by
sending the keycode for PrtScr?
Answer:
1 procedure SimulateKeystroke(Key: byte; extra: DWORD);
2 begin3 keybd_event(Key, extra, 0, 0);
4 keybd_event(Key, extra, KEYEVENTF_KEYUP, 0);
5 end;
6 7 procedure TForm1.Button2Click(Sender: TObject);
8 begin9 {Capture the entire screen to the clipboard by simulating pressing the 10 PrintScreen key}11 SimulateKeystroke(VK_SNAPSHOT, 0);
12 end;
13 14 procedure TForm1.Button3Click(Sender: TObject);
15 begin16 {Capture the active window to the clipboard by simulating pressing the 17 PrintScreen key}18 SimulateKeystroke(VK_SNAPSHOT, 1);
19 end;