相关疑难解决方法(0)

使用RegisterHotKey检测Ctrl + V但不拦截它

我需要检测用户何时按下Ctrl+ V(无论窗口焦点如何 - 我的应用程序可能会被最小化)但我不能停止实际的粘贴操作.

我尝试了一些事情:(我成功绑定了RegisterHotKey的键击)

我有:

protected override void WndProc(ref Message m)
{
  if (m.Msg == 0x312)
    hotKey();
  base.WndProc(ref m);
}
Run Code Online (Sandbox Code Playgroud)

我尝试过以下方法:

void hotKey()
{
  SendKeys.SendWait("^v"); //just puts 'v' instead of clipboard contents
}
Run Code Online (Sandbox Code Playgroud)

void hotKey()
{
  SendKeys.SendWait(ClipBoard.GetText());
  /* This works, but since Ctrl is still down, it triggers
   * all the shortcut keys for the app, e.g. if the keyboard
   * contains 's' then instead of putting 's' in the app, it
   * calls Ctrl+S …
Run Code Online (Sandbox Code Playgroud)

c# pinvoke hotkeys sendkeys registerhotkey

9
推荐指数
1
解决办法
3105
查看次数

标签 统计

c# ×1

hotkeys ×1

pinvoke ×1

registerhotkey ×1

sendkeys ×1