How Do I Use SendInput in Delphi?

前端 未结 1 1143
傲寒
傲寒 2021-02-06 17:39

I was using the Mouse_Event Function in Delphi 2009, but the Delphi documentation says this function has been superceded and to use SendInput instead.<

相关标签:
1条回答
  • 2021-02-06 17:54

    Here is how to simulate a left click for more details visit http://msdn.microsoft.com/en-us/library/ms646310(VS.85).aspx

    var
    eu: array [0..1] of TInput;
    begin
      ZeroMemory(@eu,sizeof(eu));
      eu[0].Itype := INPUT_MOUSE;
      eu[0].mi.dwFlags :=MOUSEEVENTF_LEFTDOWN;
      eu[1].Itype := INPUT_MOUSE;
      eu[1].mi.dwFlags :=MOUSEEVENTF_LEFTUP;
      SendInput(2,eu[0],sizeof(TInput));
    end;
    

    And here is for simulating right click

    var
    eu: array [0..1] of TInput;
    begin
      ZeroMemory(@eu,sizeof(eu));
      eu[0].Itype := INPUT_MOUSE;
      eu[0].mi.dwFlags :=MOUSEEVENTF_RIGHTDOWN;
      eu[1].Itype := INPUT_MOUSE;
      eu[1].mi.dwFlags :=MOUSEEVENTF_RIGHTUP;
      SendInput(2,eu[0],sizeof(TInput));
    end;
    
    0 讨论(0)
提交回复
热议问题