Capturing nonstandard mouseclicks

This is a discussion on Capturing nonstandard mouseclicks within the Windows Programming forums, part of the Platform Specific Boards category; Hey, I just bought a new mouse. I installed the mouse software/driver, and then found out that it decreased the ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    Question Capturing nonstandard mouseclicks

    Hey, I just bought a new mouse. I installed the mouse software/driver, and then found out that it decreased the mouse's performance (if you moved the mouse slowly it wouldn't move the cursor at all); so I uninstalled it. Anyways, the only improvement the software offered was that it allowed one extra customizable button, which (without the software) can't be used.

    So, I was wondering if it's possible for me to write a program that runs as a service and captures that one mouse click, interpreting it accordingly.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    CS Student hartwork's Avatar
    Join Date
    Apr 2004
    Posts
    35
    download winspector (http://www.windows-spy.com/), start notepad, click with that mouse button and see if it generates any messages. if i it does and differs from default mouse buttons you got a chance by detecting these clicks using windows hooks. i hope i made it clear. if not i'll try again :-) good luck.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Interesting, I ran Spy++ (which came with MSVC), checking for a bunch of different types of messages. It seems that when the button is held down, I get a bunch of this:

    Message: WM_TIMER (0113)
    wParam: 00001000
    lParam: 00000000
    Nesting level: 0
    Posted with: PostMessage()
    wTimerID: 4096

    Seems odd to me that WM_TIMER messages would be generated from a mouse button, but that's what Spy++ gave me (I tested using Internet Explorer's window). I'll post more after I try this in a test program...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    OK, just ran a quick test program. Using Spy++, I traced all window messages to my test window. No messages were generated when I hit the button, although left/right/middle mouseclicks as well as wheel were all detected. So what's so special about Internet Explorer that it gets a WM_TIMER message on the special button and other windows don't?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Not sure if this would work but: Install the software again, then click on a window (e.g. Notepad), it should get a message, then uninstall the software and try again, it should lack 1 message, and thats the message you want.

    Also your probably getting a WM_TIMER message in IE because of some built in function or thats the way it handles the message, e.g. to detect if a mouse is over a hyperlink? Thats probably why you dont get the same message in Notepad

    PaYnE

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>it should lack 1 message, and thats the message you want.
    If I know what message I'm lacking, but have no way of getting that message, how does that help?

    >>Also your probably getting a WM_TIMER message in IE because of some built in function or thats the way it handles the message, e.g. to detect if a mouse is over a hyperlink?

    Oddly enough, I just ran another test on IE, and now it gets no message at all. Besides which, if it didn't get any message (like my test app didn't) notifying it of the click, how would it be able to handle a message that it didn't get?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Well i dont know if this is accurate or even right, but I think when you click that extra button on your mouse, it sends a message thats defined in its software (lets say WM_USER + 5), the software, which runs in the background, waits for this message, when this message arrives, it performs the task you set it to do.

    For example, on my logitech, i have like 5 extra buttons, without the software they dont work, but with the software, i make them do things like back and forward in IE, etc..

    So im guessing, you need the software installed for the message to be 'translated', that way when you click on notepad with that button, you will most likely get whatever you defined it to do in the program. Im gonna try and run some tests using my mouse and spy++ and notepad, ill post once i get results.

    PaYnE

    Edit:
    [Ok finished the tests, when i use the two buttons (back and forward on my mouse) with the software, notepad receives a WM_KEYDOWN/WM_KEYUP and WM_SYSKEYDOWN/WM_SYSKEYUP message, but without the software, i dont get anything.

    So what i think is happening is this: when you click the button, your mouse sends a custom message, that only your software knows, therefore it waits for that message to appear, once the message is received, it checks what you defined that button to do (e.g. minimize a window), the software then sends that message, and that is how i received those 4 messages on notepad with the software installed. Maybe you should try looking up your mouse manufacturer and maybe they have documentation on what messages it sends, and what exactly the software does.]
    Last edited by X PaYnE X; 04-10-2004 at 12:21 AM.

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    Quote Originally Posted by Hunter2
    >>it should lack 1 message, and thats the message you want.
    If I know what message I'm lacking, but have no way of getting that message, how does that help?
    Sorry for double posting,but i forgot to answer your question, lets say you installed the software, and clicked in notepad using all 3 buttons (or 4, however many your mouse has including that special button), you should get n number of messages, but when you uninstall, you should get n - 1 messages.

    check through both logs, and find out which message is missing in the second log, and thats the message that gets sent when you click that button.

    Im not entirely sure if any of it is right, but im pretty sure it should atleast work

    PaYnE

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Oh yeah, I know what you mean and it sounds like it should work, except for one thing... If you look at my original post, you'll see that I'm trying to do this without the software installed, because the software screwed up my mouse performance Any idea on how to do it without the software, (is assembly necessary or anything?) or am I gonna be stuck without a mousebutton?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    Well, I'm not sure how you'd go about doing it, sounds like windows gets a message from it but doesn't recognize it (without the driver) so unless you can write the company to find out (doubt they'd tell you) what event the button sends, you're screwed.

    Did you try messing with your mouse accel properties after you installed the driver? Maybe they got defaulted to a lower speed??
    PHP and XML
    Let's talk about SAX

  11. #11
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Well, without the driver the mouse moves at a certain speed; with the driver, the mouse moves too slow unless I increase the accel - then it moves the same as before. But in games, accel has weird effects... moving the mouse constantly makes the aim accel too, and at an ungodly rate So I turned the accel off, and increased the mouse sensitivity; but in the game, I could never get the sensitivity setting to work like before. Then I realized that if I moved the mouse slowly, it wouldn't register any moving at all, which was why my aim was always so jerky and unsteady. Without the driver, it picks up even the slightest touch, but without moving too fast.

    so unless you can write the company to find out (doubt they'd tell you) what event the button sends, you're screwed.
    I guess that's worth a shot. I agree with you though, they'll never tell me They'll probably think I'm trying to hack the mouse firmware
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #12
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Wow awesome! They have a whole section of their site for developers, and I never even noticed. They'll even send you a free dev kit for their products

    http://www.logitech.com/index.cfm/pa...CA/EN,CRID=932
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Image Capturing
    By Daedalsu AI in forum C++ Programming
    Replies: 1
    Last Post: 11-19-2005, 09:46 PM
  2. Capturing dos text screen in C
    By hednast in forum C Programming
    Replies: 13
    Last Post: 08-11-2005, 07:49 PM
  3. capturing mouse events
    By leojose in forum Windows Programming
    Replies: 7
    Last Post: 06-06-2005, 10:36 PM
  4. Capturing key stokes
    By subdene in forum C++ Programming
    Replies: 20
    Last Post: 08-13-2002, 03:51 PM
  5. checking mouseclicks... [bubba especially for you]
    By doubleanti in forum C++ Programming
    Replies: 2
    Last Post: 04-19-2002, 01:14 AM

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