b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

mouse_event_registerhotkey_Rtlmovememory

电脑杂谈  发布时间:2017-03-02 08:13:42  来源:网络整理

I need to detect when a user presses Ctrl+V (regardless of window focus - my app will likely be minimised) but I must not stop the actual paste operation.

I have tried a few things: (I am successfully binding to keystrokes with RegisterHotKey)

I have:

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

and I've tried the following:

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

and

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 which makes the app think the user wants
   * to save.
   */
}

Currently the only working solution I have is to bind to something different, e.g. Ctrl+B and then call SendKeys.SendWait("^v"); however this isn't ideal.

An ideal solution would be if my window didn't intercept the keystroke in the first place, just reacted.

You can do this by leveraging hooks using SetWindowsHookEx().

HHOOK WINAPI SetWindowsHookEx(
  __in  int idHook,
  __in  HOOKPROC lpfn,
  __in  HINSTANCE hMod,
  __in  DWORD dwThreadId
);

Basically, you can set up a low-level keyboard hook:

_hookHandle = SetWindowsHookEx(
    WH_KEYBOARD_LL,
    KbHookProc,                   // Your keyboard handler
    (IntPtr)0,
    0);                           // Set up system-wide hook.


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-35347-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 曲蒙蒙
      曲蒙蒙

      这也是一种方法

    • 陈哀公妫弱
      陈哀公妫弱

      合伙娶谢教授女儿或者孙女再或者外孙女做老婆

    • 龚书宽
      龚书宽

      有利益就有冲突

    热点图片
    拼命载入中...