Author Topic: How to simulate a click of LMB in c ++?  (Read 2566 times)

poundei

  • Guest
How to simulate a click of LMB in c ++?
« on: February 27, 2020, 05:20:36 am »
Please tell me how to simulate clicking LMB.

When I specify 'VK_TAB' or 'keyboard character' then everything works
but when I enter VK_LBUTTON nothing happens. Why is that?

After all, if you had written the wrong name for the button, the program would not have compiled at all.

Here is the code:
Code
#include <iostream>
#include <Windows.h>
#pragma comment(lib,"user32")
using namespace std;



int main()
{
    string txt;

    for(int i=0;i <100;i++ ){
        keybd_event (VK_LBUTTON,0,0,0);
 
        cout << i <<endl;
        Sleep(100);
    }
   
    return 0;
}
« Last Edit: July 28, 2023, 03:58:07 pm by MortenMacFly »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: How to simulate a click of LMB in c ++?
« Reply #1 on: February 27, 2020, 09:02:22 am »
This is not the correct forum for such questions...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]