How to send Ctrl/Shift/Alt + Key combinations to an application window? (via SendMessage)

后端 未结 5 631
日久生厌
日久生厌 2021-02-13 18:24

I can successfully send any single key message to an application, but I don\'t know how to send combinations of keys (like Ctrl+F12, Shift+

5条回答
  •  走了就别回头了
    2021-02-13 19:04

    Maybe you are looking something like that:

    procedure GoCursorUp(Obj: TControl);
    var   KeyState : TKeyboardState;
    begin
      GetKeyboardState(KeyState);
      KeyState[VK_CONTROL] := KeyState[VK_CONTROL] or $80;
      SetKeyboardState(KeyState);// control down
      Obj.Perform(WM_KEYDOWN,VK_HOME,0); //ex. with HOME key
      KeyState[VK_CONTROL] := $0;
      SetKeyboardState(KeyState);// control up
    end;
    

    ...

    GoCursorUp(Self);

    Or something like this:

      //for example: SHIFT + TAB
      keybd_event(VK_SHIFT, 0, 0, 0);
      keybd_event(VK_TAB, 0, 0, 0);
      keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
    

提交回复
热议问题