Arsip: procedure SendKey


by hasan_plg in Articles more 13 years ago 2535
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.
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com