1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53:
| procedure EnterText(AText: String); var lCount : Integer; lScanCode : Smallint; lWithAlt, lWithCtrl, lWithShift : Boolean; begin for lCount := 1 To Length(AText) Do begin lScanCode := VkKeyScan(AText[lCount]); lWithShift := lScanCode and (1 shl 8) <> 0; lWithCtrl := lScanCode and (1 shl 9) <> 0; lWithAlt := lScanCode and (1 shl 10) <> 0;
if lWithShift then keybd_event(VK_SHIFT, 0, 0, 0); if lWithCtrl then keybd_event(VK_CONTROL, 0, 0, 0); if lWithAlt then keybd_event(VK_MENU, 0, 0, 0);
keybd_event(lScanCode, 0, 0, 0); keybd_event(lScanCode, 0, KEYEVENTF_KEYUP, 0);
if lWithAlt then keybd_event(VK_MENU, 0, KEYEVENTF_KEYUP, 0); if lWithCtrl then keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); if lWithShift then keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0); end; end;
procedure TFormMain.WMHotKey(var Msg: TWMHotKey); var TypeText : String; i : Integer; begin if Msg.HotKey = Hotkey1_id then begin TypeText := 'test1'; end;
if Msg.HotKey = Hotkey2_id then begin TypeText := 'test2'; end;
EnterText(TypeText); end; |