Thread: Middle button mouse capture in another program

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    10

    Middle button mouse capture in another program

    I got a problem.

    I am making a DLL that needs to know when, in another program, user will press the middle mouse button and the mouse coord.

    Which functions can I use?

    Please help me.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    10
    Is it doable to see other programs' mouse event or not?

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Answering a question with a question. Now that is a true sign of intelligence. I'm pretty sure that you may be able to do this but it may not be as simple as you think. I'm sure that you can do it using some win32 api calls. However, I would try and find the memory location of the process. If you can do that then you can grab its WM_MBUTTON* messages. You must realize that I just made that sound easier than it actually is.

    Now this one is error prone but it may do the trick. Keep track of the mouse's position and assume that it is whatever window has focus. BUT that assumes way too much to be a dependable way of accomplishing what you need it to.

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    GetMsgProc:


    The GetMsgProc hook procedure is an application-defined or library-defined callback function that the system calls whenever the GetMessage function has retrieved a message from an application message queue. Before passing the retrieved message to the destination window procedure, the system passes the message to the hook procedure.

    LRESULT CALLBACK GetMsgProc(

    int code, // hook code
    WPARAM wParam, // removal flag
    LPARAM lParam // address of structure with message
    );
    Parameters

    code

    Specifies whether the hook procedure must process the message. If code is HC_ACTION, the hook procedure must process the message. If code is less than zero, the hook procedure must pass the message to the CallNextHookEx function without further processing and should return the value returned by CallNextHookEx.

    wParam

    Specifies whether the message has been removed from the queue. This parameter can be one of the following values:

    Value Meaning
    PM_NOREMOVE Specifies that the message has not been removed from the queue. (An application called the PeekMessage function, specifying the PM_NOREMOVE flag.)
    PM_REMOVE Specifies that the message has been removed from the queue. (An application called GetMessage, or it called the PeekMessage function, specifying the PM_REMOVE flag.)
    lParam

    Points to an MSG structure that contains details about the message.

    Return Values

    The return value should be zero.

    Remarks

    The GetMsgProc hook procedure can examine or modify the message. After the hook procedure returns control to the system, the GetMessage function returns the message, along with any modifications, to the application that originally called it.
    An application installs this hook procedure by specifying the WH_GETMESSAGE hook type and the address of the hook procedure in a call to the SetWindowsHookEx function.
    GetMsgProc is a placeholder for the application-defined or library-defined function name.

    See Also

    CallNextHookEx, GetMessage, MSG, PeekMessage, SetWindowsHookEx

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I think an app only gets mouse msg's after it calls SetCapture().
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    10
    Could you help me with setcapture? I am.. kinda a beginner.

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. (Windows) Send keyboard and mouse to another program?
    By Chrisname in forum Windows Programming
    Replies: 4
    Last Post: 06-13-2009, 06:13 PM
  3. Mouse Program
    By asbo60 in forum C++ Programming
    Replies: 23
    Last Post: 04-09-2006, 04:48 AM
  4. Program that finds the middle number
    By Zerohero11 in forum C++ Programming
    Replies: 17
    Last Post: 10-13-2005, 07:20 PM