Simulate Left Mouse Button (VK_LBUTTON)

This is a discussion on Simulate Left Mouse Button (VK_LBUTTON) within the Windows Programming forums, part of the Platform Specific Boards category; How could I simulate a left-click with a mouse. I have no trouble using keys (sendkeys project from codeproject), but ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Location
    USA::Colorado
    Posts
    155

    Simulate Left Mouse Button (VK_LBUTTON)

    How could I simulate a left-click with a mouse. I have no trouble using keys (sendkeys project from codeproject), but I can't get it to simulate a left-click.

    Can anyone help me?
    ~guitarist809~

  2. #2
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    http://p2p.wrox.com/topic.asp?TOPIC_ID=38639

    The OP is using .NET, but I believe he's attempting calls out of a win32 api dll so it should be enough to send you in the right direction.
    What is C++?

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    Quote Originally Posted by Vicious View Post
    The OP is using .NET, but I believe he's attempting calls out of a win32 api dll so it should be enough to send you in the right direction.
    It's the wrong direction (explanations in MSDN)
    The right method is SI()

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Since you posted in the Windows forum and not the C# forum, I'll assume you want to simulate a left mouse button using Win32 API.

    With that said, give the following a try to see if it works:

    Code:
      INPUT    Input={0};
      // left MB down 
      Input.type      = INPUT_MOUSE;
      Input.mi.dwFlags  = MOUSEEVENTF_LEFTDOWN;
      SendInput(1,&Input,sizeof(Input));
      // lef MB up
      ZeroMemory(&Input,sizeof(INPUT));
      Input.type      = INPUT_MOUSE;
      Input.mi.dwFlags  = MOUSEEVENTF_LEFTUP;
      SendInput(1,&Input,sizeof(Input));

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Code for holding down right mouse button
    By Bill83 in forum Windows Programming
    Replies: 2
    Last Post: 03-04-2006, 06:28 PM
  3. Release Configuration Problems
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2002, 04:54 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Please help me
    By teedee46 in forum C++ Programming
    Replies: 9
    Last Post: 05-06-2002, 11:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21