How to call PrintScreen
Mateescu Zeno
zmateescu at gw.cdk.bme.hu
Mon Apr 15 12:14:33 CDT 2002
Hello
I can help you with PRINTSCRN, with ALT + PRINTSCRN ... have no ideea. But
I think that it's close to that.
procedure SimulateKeyDown(Key : byte);
begin
keybd_event(Key, 0, 0, 0);
end;
procedure SimulateKeyUp(Key : byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;
procedure SimulateKeystroke(Key : byte;
extra : DWORD);
begin
keybd_event(Key,
extra,
0,
0);
keybd_event(Key,
extra,
KEYEVENTF_KEYUP,
0);
end;
and
SimulateKeystroke(VK_SNAPSHOT, 0); - Print Screen
You can also use this procedure to send other keys.
procedure SendKeys(s : string);
var
i : integer;
flag : bool;
w : word;
begin
{Get the state of the caps lock key}
flag := not GetKeyState(VK_CAPITAL) and 1 = 0;
{If the caps lock key is on then turn it off}
if flag then
SimulateKeystroke(VK_CAPITAL, 0);
for i := 1 to Length(s) do begin
w := VkKeyScan(s[i]);
{If there is not an error in the key translation}
if ((HiByte(w) <> $FF) and
(LoByte(w) <> $FF)) then begin
{If the key requires the shift key down - hold it down}
if HiByte(w) and 1 = 1 then
SimulateKeyDown(VK_SHIFT);
{Send the VK_KEY}
SimulateKeystroke(LoByte(w), 0);
{If the key required the shift key down - release it}
if HiByte(w) and 1 = 1 then
SimulateKeyUp(VK_SHIFT);
end;
end;
{if the caps lock key was on at start, turn it back on}
if flag then
SimulateKeystroke(VK_CAPITAL, 0);
end;
Ex: SendKeys('Delphi Is RAD!');
Regards
Zeno
----- Original Message -----
From: "Jesper Stenlund" <jest02 at handelsbanken.se>
To: <delphi at elists.org>
Sent: Monday, April 15, 2002 12:56 AM
Subject: How to call PrintScreen
> Hello
>
> I want to include a button on my form which does the same thing as if I
pressed ALT + PRINTSCRN.
>
> I guess there is a Windows API for this but I can't find it.
>
> TCustomForm has a method Print but the result isn't exactly the same as if
I had used ALT + PRINTSCRN.
>
> Anyone got a clue?
>
> Thanks in advance
>
> file://Jesper Stenlund, Svenska Handelsbanken
>
>
>
> _______________________________________________
> Delphi mailing list -> Delphi at elists.org
> http://www.elists.org/mailman/listinfo/delphi
>
More information about the Delphi
mailing list