Arsip: procedure SendKey


by hasan_plg in Articles more 17 years ago 3470
Procedure SendKey ini dapat Anda tambahkan di inisial PUBLIC, contoh-nya sebagai berikut:

Form1 = Class(TForm)
...
...
private
public
procedure SendKey(Shift:TShiftState; Key: Word);
end;
implementation
procedure SendKey(Shift:TShiftState; Key: Word);
begin
if (ssCtrl in Shift) then keybd_event(VK_CONTROL, 1, 0, 0);
if (ssShift in Shift) then keybd_event(VK_SHIFT, 1, 0, 0);
if (ssAlt in Shift) then keybd_event(VK_MENU, 1, 0, 0);
keybd_event(Key, 1, 0, 0);
keybd_event(Key, 1, KEYEVENTF_KEYUP, 0);
if (ssAlt in Shift) then keybd_event(VK_MENU, 1, KEYEVENTF_KEYUP, 0);
if (ssShift in Shift) then keybd_event(VK_SHIFT, 1, KEYEVENTF_KEYUP, 0);
if (ssCtrl in Shift) then keybd_event(VK_CONTROL, 1, KEYEVENTF_KEYUP, 0);
end;
Syntax Highlighted with https://pascal-id.org/syntax




---------------------------
Contoh digunakan pada komponent TEdit:
Windows.SetFocus( Edit1.Handle ); //atau bisa juga: Edit1.SetFocus;
SendKey( [], VK_TAB );
SendKey( [ssShift], VK_TAB );
SendKey( [ssCtrl], VK_A );

procedure SendKey, event untuk mengirim perintah penekanan tombol ke keyboard.

AI Forward

๐Ÿš€ We're thrilled to partner with Alibaba Cloud for "AI Forward - Alibaba Cloud Global Developer Summit 2025" in Jakarta! Join us and explore the future of AI. Register now: https://int.alibabacloud.com/m/1000400772/
#AlibabaCloud #DeveloperSummit #Jakarta #AIFORWARD

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com