发送Ctrl +键到第三方应用程序 [英] Send Ctrl+Key to a 3rd Party Application

查看:187
本文介绍了发送Ctrl +键到第三方应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用导出文件的第三方应用程序。应用程序使用热键( Ctrl + E )作为此功能的快捷方式。

Im using a 3rd Party Application that exports a file. The application uses a hot key (Ctrl + E) as a shortcut for this function.

将此组合从我的Delphi XE应用程序发送到第三方?

How can I send this key combination from my Delphi XE application to the 3rd Party one?

推荐答案

这是一个示例,显示如何发送< kbd> Ctrl + E 到前台应用程序使用 SendInput

Here is an example which shows how to send Ctrl+E to the foreground application using SendInput:

var
  Inputs: array [0..3] of TInput;
begin
  // press
  Inputs[0].Itype := INPUT_KEYBOARD;
  Inputs[0].ki.wVk := VK_CONTROL;
  Inputs[0].ki.dwFlags := 0;

  Inputs[1].Itype := INPUT_KEYBOARD;
  Inputs[1].ki.wVk := Ord('E');
  Inputs[1].ki.dwFlags := 0;

  // release
  Inputs[2].Itype := INPUT_KEYBOARD;
  Inputs[2].ki.wVk := Ord('E');
  Inputs[2].ki.dwFlags := KEYEVENTF_KEYUP;

  Inputs[3].Itype := INPUT_KEYBOARD;
  Inputs[3].ki.wVk := VK_CONTROL;
  Inputs[3].ki.dwFlags := KEYEVENTF_KEYUP;

  SendInput(Length(Inputs), Inputs[0], SizeOf(TInput));
end;

我还使用Steve Seymour的SendKeys.pas稍微修改版本。它与不同的键盘布局有一些问题,并且是从1999年起。在网络中找不到它。

I also use a slightly modified version of SendKeys.pas from Steve Seymour. It had some problems with different keyboard layouts and is from 1999. Couldn't find it anywhere in the net.

这篇关于发送Ctrl +键到第三方应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆