procedure TForm1.Button1Click(Sender: TObject);
begin
PostMessage(edit1.Handle, WM_KEYDOWN, VK_CONTROL, MapVirtualKey(VK_CONTROL,0) shl 16 or 1);
PostMessage(edit1.Handle, WM_KEYDOWN, ord('Z'), MapVirtualKey(ord('Z'),0) shl 16 or 1);
PostMessage(edit1.Handle, WM_KEYUP, VK_CONTROL, MapVirtualKey(VK_CONTROL,0) shl 16 or 1);
PostMessage(edit1.Handle, WM_KEYUP, ord('Z'), MapVirtualKey(ord('Z'),0) shl 16 or 1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.SetFocus;
keybd_event( VK_Control, MapVirtualKey(VK_Control, 0 ), 0 , 0 ); //Control key down
keybd_event( ord('Z'), MapVirtualKey(ord('Z'), 0 ), 0 , 0 ); //Control key down
//keybd_event( VK_MENU, MapVirtualKey(VK_MENU, 0 ),KEYEVENTF_EXTENDEDKEY, 0 ); // Alt down
//keybd_event( VK_Down, MapVirtualKey(VK_Down, 0 ),KEYEVENTF_EXTENDEDKEY, 0 ); // down arrow key down
keybd_event( VK_Control, MapVirtualKey(VK_Control, 0 ), KEYEVENTF_KEYUP , 0 ); //Control arrow key up
keybd_event( ord('Z'), MapVirtualKey(ord('Z'), 0 ), KEYEVENTF_KEYUP , 0 );
//keybd_event( VK_MENU, MapVirtualKey(VK_MENU, 0 ), KEYEVENTF_KEYUP , 0 ); //Alt key up
//keybd_event( VK_Down, MapVirtualKey(VK_Down, 0 ), KEYEVENTF_KEYUP , 0 ); //Down key up
end;