模拟键盘

SendMessage(Myhwnd, WM_KEYDOWN, VK_TAB, 1);  // 发送Tab键
SendMessage(Myhwnd, WM_KEYUP, VK_TAB, 1);
SendMessage(Myhwnd, WM_KEYDOWN, VK_RETURN, 1);  // 发送Enter键
SendMessage(Myhwnd, WM_KEYUP, VK_RETURN, 0);
SendMessage(Myhwnd, WM_LBUTTONDOWN, 0, MakeLParam(292, 179));  //移动到坐标292,179并点击
SendMessage(Myhwnd, WM_LBUTTONUP, 0, MakeLParam(292, 179));
SendMessage(Hwnd, WM_LBUTTONDBLCLK, 0, MakeLParam(175, 277));  //模拟双击
SendMessage(Hwnd, WM_LBUTTONUP, 0, MakeLParam(175, 277));
Str := '123456';
for I := 1 to Length(Str) do // 发送数字123456
SendMessage(Han, WM_CHAR, wParam(Str[I]), 1);
Procedure FindQQ(hWnd: Thandle; Str: String);
Var
  I: Integer;
Begin
  for I := 1 to Length(Str) do // 发送数字123456
  Begin
    PostMessage(hWnd, WM_KEYDOWN, 0, 1);
    PostMessage(hWnd, WM_CHAR, wParam(Str[I]), 1);
    PostMessage(hWnd, WM_KEYUP, 0, 1);
  End;
End;

  SwitchToThisWindow(RichEditComponent, true);
  FindQQ(RichEditComponent, '/140');
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0); // 按下 Ctrl键
keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0);
SetCursorPos(40, 48);  //移动鼠标位置到 X40、Y48
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);   //单击 左键
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
{前台模拟英文字母输入}
Var
  i: integer;
Begin
  for i := 1 to Length(A) do
  Begin
    Keybd_Event(VkKeyScan(A[i]), 0, 0, 0);
    Keybd_Event(VkKeyScan(A[i]), 0, KEYEVENTF_KEYUP, 0);
  End;
{后台发送中文}
Var
  Str: String;
Begin
    Str := '2020-11-09 ,我爱我家';
    //方法一
    SendMessage(69474,EM_REPLACESEL,0,Integer(pchar(Str)));
    //方法二
    SendMessage(69474,WM_SETTEXT,0,Cardinal(Str));
End;

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值