1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mimicing L Mouse Button Click on 3rd Party App

Discussion in 'Win32' started by woodced, Oct 24, 2008.

  1. woodced

    woodced New Member

    Oct 24, 2008
    Likes Received:
    Trophy Points:
    Hi all,

    I'm a video editor and my software of choice is Avid Media Composer. I was recently moved to try to add some personal enhancements to Avid's keymapping system which in places is somewhat wanting. Media Composer has a Window called Audio Mixer in which there are a series of buttons (though not windows buttons). I'm using Windows Hooks to try to intercept a keypress and spoof a keypress on the buttons in the Audio Mixer window.

    My thought was to use the Win32 SendMessage function to send an WM_LBUTTONDOWN and WM_LBUTTONUP with the appropriate x and y positions in the Audio Mixer window. Using a similar method I can, for instance, fake a press of the Windows Start button. However, this method doesn't seem to work with the Audio Mixer window. I get no response at all from the UI. [as an aside when I do it with the Start button watching the Start button messages with Spy++ I cannot see the WM_LBUTTONDOWN message I send to the button. Is this normal? Why is it?]

    Being an editor, I'm not the greatest programmer in the world, so am not completely au fait with win32 calls. I've tried using both SendMessage and PostMessage and neither seem to be doing anything. Without being able to see the messages in Spy++ or any UI feedback it's not clear what is going on, or indeed what to try next. Can anyone give me some pointers? By the way I'm hooking the WH_MOUSE_LL hook.

  2. shabbir

    shabbir Administrator Staff Member

    Jul 12, 2004
    Likes Received:
    Trophy Points:
    No you should see the same message when using the mouse and when sending using external application.

    Did you get the handle and other stuff correctly
  3. xpi0t0s

    xpi0t0s Mentor

    Aug 6, 2004
    Likes Received:
    Trophy Points:
    Senior Support Engineer
    It depends how the application reads the mouse. Some use the WM_LBUTTONDOWN and UP messages; others just have a look at the state of the keys, for example GetAsyncKeyState(VK_LBUTTON) will tell you if the left button is up or down.

    SendMessage and PostMessage do the same thing, but differ in when the message is sent. SendMessage sends it NOW and returns control to you when the message has been sent. PostMessage just sticks the message on the queue to be handled whenever it gets round to it. So if SendMessage(WM_LBUTTONDOWN) doesn't do it, neither will PostMessage(WM_LBUTTONDOWN).

Share This Page