Middle-Mouse button - Linux

This is a discussion on Middle-Mouse button - Linux ; Greeting's, I'm searching for a reliable technique that will allow me to capture middle mouse button clicks. I was hoping to do something other than constant polling for the status of the mouse buttons, as ideally, it would be best ...

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 55

Thread: Middle-Mouse button

  1. Middle-Mouse button

    Greeting's,

    I'm searching for a reliable technique that will allow me to capture middle
    mouse button clicks.

    I was hoping to do something other than constant polling for the status of
    the mouse buttons, as ideally, it would be best if I can 'eat' those mouse
    clicks and not pass them down to whatever process also 'sees' clicks.

    Thanks in advance,

    DanS



  2. Re: Middle-Mouse button

    On 2008-08-24, DanS wrote:
    > Greeting's,
    >
    > I'm searching for a reliable technique that will allow me to capture middle
    > mouse button clicks.
    >
    > I was hoping to do something other than constant polling for the status of
    > the mouse buttons, as ideally, it would be best if I can 'eat' those mouse
    > clicks and not pass them down to whatever process also 'sees' clicks.


    you give no clue about the intended environment you want this to work in,
    so I'll give you the most general solution.

    open the mouse and cut the wire that goes to the middle mouse button.

    Bye.
    Jasen

  3. Re: Middle-Mouse button

    On 2008-08-24, DanS wrote:
    > Greeting's,
    >
    > I'm searching for a reliable technique that will allow me to capture middle
    > mouse button clicks.
    >
    > I was hoping to do something other than constant polling for the status of
    > the mouse buttons, as ideally, it would be best if I can 'eat' those mouse
    > clicks and not pass them down to whatever process also 'sees' clicks.


    you give no clue about the intended environment you want this to work in,
    so I'll give you the most general solution.

    open the mouse and cut the wire that goes to the middle mouse button.

    Bye.
    Jasen

  4. Re: Middle-Mouse button

    Bernhard Agthe wrote in
    news:g8u97s$miv$1@daniel-new.mch.sbs.de:

    > DanS wrote:
    >> Greeting's,
    >>
    >> I'm searching for a reliable technique that will allow me to capture
    >> middle mouse button clicks.

    >
    > Try to re-map the mouse key to something useful for you. But, as
    > stated, you need to be a little more specific...


    OK....more specific......

    (I didn't want to say it but) In Windows, I would set a global mouse hook
    using the API call SetWindowsHookEx and my app would receive mouse event
    messages....MouseMove, Button Clicks/Dbl clicks, and button down and up
    messages.

    At that point, I can either do 'something', or not do 'something', as
    well as set a return value, to either pass the event down the hook chain
    or not.

    Re-mapping the mouse is not what I want to do.

    This is part of a replacment shell. When clicking the middle mouse
    button, I want to show my app, or at the very least, be able to show a
    popup menu to launch programs. Ideally, also be able to stop the middle
    mouse-click right there so it doesn't move down the (Windows terminology)
    hook chain, and result in a paste operation.

    Here.....a few screenshots...

    http://users.adelphia.net/~thisnthat...creenshots.zip

    These are from an older version as a lot of updates have been made since
    I made these pix. What happens, is when I middle-click the mouse, the
    window in screenshot1 is shown. This is the full shell replacement window
    with taskswapper/clock/a launching method, some quick menu tasks, and a
    sysmtemtray. The shell window is shown whereever the mouse is located.

    It started off as just a simple launcher program where the middle click
    would just immediately show the menu to launch programs...and over time
    evolved into a complete shell. This was done because of my intense
    disdain for the Windows Start menu...being forced to go to the left
    bottom corner of the screen, click start, move to programs, and then
    navigating that menu. Instead, one middle click shows the shell window,
    with the mouse over the 'Menu' button already. I am basically minimizing
    the amout of move movement required.

    At the very least, I would just like to be able to show a launching menu
    triggered by a middle mouse click.

    Thanks in advance,

    DanS










  5. Re: Middle-Mouse button

    DanS wrote:
    > Greeting's,
    >
    > I'm searching for a reliable technique that will allow me to capture middle
    > mouse button clicks.


    Try to re-map the mouse key to something useful for you. But, as stated,
    you need to be a little more specific...


  6. Re: Middle-Mouse button

    On a sunny day (Mon, 25 Aug 2008 14:33:18 +0000 (UTC)) it happened DanS
    wrote in
    :

    >It started off as just a simple launcher program where the middle click
    >would just immediately show the menu to launch programs...and over time
    >evolved into a complete shell.



    What you desribe sounds almost? like a normal X window manager.
    I mean left mouse in fvwm does pop up an application menu.
    Perhaps look as some window manager source code?

    But even on the application level you can do anthing you want if you monitor
    the xevent queue.
    xevent queue:


    #define M_MIDDLE_DOWN 2
    int a;
    while(1)
    {
    a = XEventsQueued(mydisplay, QueuedAfterReading);
    if(!a) break;

    XNextEvent(mydisplay, &myevent);

    switch (myevent.type)
    {
    if(myevent.xbutton.button == M_MIDDLE_DOWN)
    {
    /* do your thing here */
    break;
    }
    /* test for other events */
    }
    } /* end while test for new event */


  7. Re: Middle-Mouse button

    Jan Panteltje wrote in
    news:g8uijj$aas$1@aioe.org:

    > On a sunny day (Mon, 25 Aug 2008 14:33:18 +0000 (UTC)) it happened
    > DanS wrote in
    > :
    >
    >>It started off as just a simple launcher program where the middle
    >>click would just immediately show the menu to launch programs...and
    >>over time evolved into a complete shell.

    >
    >
    > What you desribe sounds almost? like a normal X window manager.
    > I mean left mouse in fvwm does pop up an application menu.


    It may, but I haven't used fvwm, so I'm guessing (assuming) that only
    happens when the click is over the desktop.

    My app opens above any active program. Since the mousehook is a global
    hook, it doesn't matter what app is active. My app receives the middle-
    click message prior to even the active app. So yes, if the program itself
    uses the middle-button, then whatever function that app has no longer
    works. But there aren't many I've seen that use a middle-click.

    > Perhaps look as some window manager source code?


    Perhaps.....

    >
    > But even on the application level you can do anthing you want if you
    > monitor the xevent queue.
    > xevent queue:
    >
    >
    > #define M_MIDDLE_DOWN 2
    > int a;
    > while(1)
    > {
    > a = XEventsQueued(mydisplay, QueuedAfterReading);
    > if(!a) break;
    >
    > XNextEvent(mydisplay, &myevent);
    >
    > switch (myevent.type)
    > {
    > if(myevent.xbutton.button == M_MIDDLE_DOWN)
    > {
    > /* do your thing here */
    > break;
    > }
    > /* test for other events */
    > }
    > } /* end while test for new event */


    App-level is really no good, it's got to be system wide, or have a way to
    monitor the queue of every GUI app open.

    TIA,

    DanS

  8. Re: Middle-Mouse button

    On a sunny day (Mon, 25 Aug 2008 16:21:53 +0000 (UTC)) it happened DanS
    wrote in
    :

    >> What you desribe sounds almost? like a normal X window manager.
    >> I mean left mouse in fvwm does pop up an application menu.

    >
    >It may, but I haven't used fvwm, so I'm guessing (assuming) that only
    >happens when the click is over the desktop.

    Yes

    >My app opens above any active program.


    Well, I dunno your application, but if I had an application like that,
    then I would erase it.
    Because it would then interfere with any other program that uses middle mouse,
    including cut and paste in a text window.


  9. Re: Middle-Mouse button

    Jan Panteltje wrote in
    news:g8un07$sgn$1@aioe.org:

    > On a sunny day (Mon, 25 Aug 2008 16:21:53 +0000 (UTC)) it happened
    > DanS wrote in
    > :
    >
    >>> What you desribe sounds almost? like a normal X window manager.
    >>> I mean left mouse in fvwm does pop up an application menu.

    >>
    >>It may, but I haven't used fvwm, so I'm guessing (assuming) that only
    >>happens when the click is over the desktop.

    > Yes
    >
    >>My app opens above any active program.

    >
    > Well, I dunno your application, but if I had an application like that,
    > then I would erase it.


    Maybe. But it's great to not have to move to the taskbar, or alt-tab to
    switch programs...just middle click, and move the mouse maybe 1 inch to
    the app you want and click....or not having to go to the

    > Because it would then interfere with any other program that uses
    > middle mouse, including cut and paste in a text window.


    To each his own. I haven't distributed my app, so I'm the only one that
    uses it.

    IIRC, the only thing I've seen that uses the middle-click was a browser,
    to scroll if you don't have a scroll-wheel. Not that there aren't any, I
    just haven't ran into any others.

    Thanks anyway.

    DanS


  10. Re: Middle-Mouse button

    On a sunny day (Mon, 25 Aug 2008 18:32:36 +0000 (UTC)) it happened DanS
    wrote in
    :

    >>
    >>>My app opens above any active program.

    >>
    >> Well, I dunno your application, but if I had an application like that,
    >> then I would erase it.

    >
    >Maybe. But it's great to not have to move to the taskbar, or alt-tab to
    >switch programs...just middle click, and move the mouse maybe 1 inch to
    >the app you want and click....or not having to go to the


    What I use is fvwm, one of the oldest filemanagers I think, with 9
    virtual screens, those virtual screens are in a pager to right.
    Does not MS call thos virtual desktops? I dunno.
    Anyways, one of those has icons for commonly used applications,
    the rest all have 'xterms'.

    It is much faster to type 'route' in an xterm. or 'ls -rtl /mnt/hdd4/video/*.ts'
    then to go to it with a file manager...
    And perhaps even safer.
    There are thousands of commands in Linux, over time you will learn some,
    you cannot possibly have them all in a menu structure.



    >> Because it would then interfere with any other program that uses
    >> middle mouse, including cut and paste in a text window.

    >
    >To each his own. I haven't distributed my app, so I'm the only one that
    >uses it.
    >
    >IIRC, the only thing I've seen that uses the middle-click was a browser,
    >to scroll if you don't have a scroll-wheel. Not that there aren't any, I
    >just haven't ran into any others.


    If you double click mouse left on a word in the xterm, then it gets selected.
    If you then click middle mouse, you can paste it anywhere in a text field.
    It is one of the most important features there is :-)


  11. Re: Middle-Mouse button

    DanS wrote:
    > Jan Panteltje wrote in
    > news:g8un07$sgn$1@aioe.org:


    > > On a sunny day (Mon, 25 Aug 2008 16:21:53 +0000 (UTC)) it happened
    > > DanS wrote in
    > > :
    > >
    > >>> What you desribe sounds almost? like a normal X window manager.
    > >>> I mean left mouse in fvwm does pop up an application menu.
    > >>
    > >>It may, but I haven't used fvwm, so I'm guessing (assuming) that only
    > >>happens when the click is over the desktop.

    > > Yes
    > >
    > >>My app opens above any active program.


    Then you must "convince' the window manager to invoke your
    program when the left mouse button is clicked. That's where
    you could get in between, how it can be done will depend on
    the window manager you're using. No "normal" program should
    be able to interfere globally with what other applications
    can receive, so there's no other global way for that (short
    of hooking into the handling of the mouse at a very low level
    before the events ever get through to the X server).

    > > Well, I dunno your application, but if I had an application like that,
    > > then I would erase it.


    > Maybe. But it's great to not have to move to the taskbar, or alt-tab to
    > switch programs...just middle click, and move the mouse maybe 1 inch to
    > the app you want and click....or not having to go to the


    I would recommend that you restrict yourself to clicks into the
    background, outside any normal windows, see below. Again, you
    have to ask the window manager nicely to do that for you.

    > > Because it would then interfere with any other program that uses
    > > middle mouse, including cut and paste in a text window.


    > To each his own. I haven't distributed my app, so I'm the only one that
    > uses it.


    > IIRC, the only thing I've seen that uses the middle-click was a browser,
    > to scroll if you don't have a scroll-wheel. Not that there aren't any, I
    > just haven't ran into any others.


    I use the middle mouse button all the time. The most common
    application is to mark some text with the left mouse button,
    go into another window that accepts text and press the middle
    mouse button to get a copy of the marked text. That's standard
    since I don't know how long (at least long before someone came
    up with Ctrl-C and Ctrl-V, which many applications don't under-
    stand). So every program interfering with the middle mouse button
    globally would keep me from doing copy and paste. And there are
    at least 20 programs I use constantly where the middle mouse
    button is essential for using the program (in some cases when
    combined with the Alt or Ctrl key). Just to name a few: under
    Firefox I can click with the middle mouse button onto a link
    to open the new page in a new tab. The PostScript viewer 'gv'
    lets me draw a box with the middle mouse button to mark a
    region I want to magnify. The 'display' program from the
    ImageMagick suite opens up a magified part of an image I am
    viewing when I click the middle mouse button (and then let me
    move the selected region). 'acroread' lets you scroll up and
    down and left and right with adjustable speeds when you press
    down the middle mouse button. So anything "stealing" middle
    mouse button clicks would cripple all these programs seriously.

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

  12. Re: Middle-Mouse button

    Jan Panteltje wrote in
    news:g8v14o$4gf$1@aioe.org:

    > There are thousands of commands in Linux, over time you will learn
    > some, you cannot possibly have them all in a menu structure.


    I understand that. And nothing like I would want to do.

    I am speaking of the apps I use regularly.

    Typically, the top-level menu items are:

    -Apps
    -Internet
    -Games
    -Multimedia
    -Programming
    -Utilities

    And in those, sub-items for launching apps that I use all the time.

    That's it. No more levels.

    Thanks for your input.

    DanS

  13. Re: Middle-Mouse button

    On a sunny day (Mon, 25 Aug 2008 21:59:00 +0000 (UTC)) it happened DanS
    wrote in
    :

    >But, my current version does have a modifier key that if pressed when the
    >middle-click happens, it does just pass it through down the line and my
    >app does not react nor eat the mouse click, so that middle-click
    >functionality does remain (although this passthrough is not thouroughly
    >tested).


    Now that you mention that, I use special keys on the keyboard for lots of stuff.
    For example I have some special key on the [Logitech] keyboard configured
    to pop up a ceefax application when I am watching fullscreen video.

    I have special keys configured for audio mute/unmute, media player, email,
    volume up/down, newsreader, database manager, etc.
    This is very nice and fast, and does not interfere with anything.


    Here is a little howto how to find the code for the special keys,
    and how to add one:

    to find key code in X:
    xev

    to assign a F key to keycode:
    joe /root/.xmodmaprc

    to merge it into the keymap:
    xmodmap ~/.xmodmaprc

    to view the modified keymap:
    xmodmap -pk

    Now install xbindkeys

    Edit the xbindkeysrc for commands associated with F keys.
    joe /root/.xbindkeysrc

    restart xbindkeys
    killall xbindkeys;xbindkeys

    make sure xbindkeys is started with X
    in /root/.xsession add:
    xbindkeys &




  14. Re: Middle-Mouse button

    Jens Thoms Toerring wrote:

    > there's no other global way for that (short
    > of hooking into the handling of the mouse at a very low level
    > before the events ever get through to the X server).


    I require modifications in this area, because I want the operators to be
    able to use their applications using single button mouse devices and
    touchscreen devices that have no middle finger / forefinger
    differentiation. For accessibility purposes, there should be no difference
    in functionality between left and right buttons.

    I also would like to be able to use the keyboard to replicate all mouse
    movement, and to be able to record and script mouse events for the
    purpose of application automation.

    Some graphical user interface application designs are weak in areas of
    accessibility and automation.

    Mark.

    --
    Mark Hobley,
    393 Quinton Road West,
    Quinton, BIRMINGHAM.
    B32 1QE.

  15. Re: Middle-Mouse button

    >>But, my current version does have a modifier key that if pressed when
    >>the middle-click happens, it does just pass it through down the line
    >>and my app does not react nor eat the mouse click, so that
    >>middle-click functionality does remain (although this passthrough is
    >>not thouroughly tested).

    >
    > Now that you mention that, I use special keys on the keyboard for lots
    > of stuff. For example I have some special key on the [Logitech]
    > keyboard configured to pop up a ceefax application when I am watching
    > fullscreen video.
    >
    > I have special keys configured for audio mute/unmute, media player,
    > email, volume up/down, newsreader, database manager, etc.
    > This is very nice and fast, and does not interfere with anything.
    >
    >
    > Here is a little howto how to find the code for the special keys,
    > and how to add one:
    >
    > to find key code in X:
    > xev
    >
    > to assign a F key to keycode:
    > joe /root/.xmodmaprc
    >
    > to merge it into the keymap:
    > xmodmap ~/.xmodmaprc
    >
    > to view the modified keymap:
    > xmodmap -pk
    >
    > Now install xbindkeys
    >
    > Edit the xbindkeysrc for commands associated with F keys.
    > joe /root/.xbindkeysrc
    >
    > restart xbindkeys
    > killall xbindkeys;xbindkeys
    >
    > make sure xbindkeys is started with X
    > in /root/.xsession add:
    > xbindkeys &


    Interesting. The hope page says this...'It links commands to keys or
    mouse buttons,....', that might work. Source is available too.

    Thanks !!!

    Regards,

    DanS

  16. Re: Middle-Mouse button

    Hi,

    > It started off as just a simple launcher program where the middle click
    > would just immediately show the menu to launch programs...and over time

    [...]

    Actually it sounds like you're trying to apply a Windows-problem to
    Linux. Don't bother - good launcher applications do exist and they
    usually are assigned to a hot-key.

    So just have your application assigned to any hot key (for example you
    could dis-use the windows-key) and pop up whenever the key is pressed.
    You don't have to mess with system-wide mouse-handling and you can still
    use the extremely helpful middle-mouse-button for copy-and-paste
    operation (actually your web browser is likely to use the middle button
    as well, at least if you're using firefox).

    Have fun!


  17. Re: Middle-Mouse button

    DanS wrote:
    >
    > IIRC, the only thing I've seen that uses the middle-click was a browser,
    > to scroll if you don't have a scroll-wheel. Not that there aren't any, I
    > just haven't ran into any others.


    Under Linux and other X11 based systems as well, the middle-click is
    used as one of the X-Selections (clipboard if you will) features. I use
    it more that the (Windows) standard Copy/Paste.

    Try it out. Simply select some text, for example in you web browser
    (don't close the application which contains the selection), now open a
    text editor or something and middle-click. The selection (is now queried
    from the other application) and pasted into the new (editor) window.

    Most (old) X11 based applications worked like this. The truly nice
    thing is that you can select as much as you want, and it doesn't use any
    memory, compared to the Windows Copy/Paste which copies the content to a
    clipboard window. X-Selections simply registers which windows contains
    the selection and on middle-click, requests the selection content from
    that window (no intermediate clipboard storage required).

    Graeme.


  18. Re: Middle-Mouse button

    DanS wrote:
    > Greeting's,
    >
    > I'm searching for a reliable technique that will allow me to capture middle
    > mouse button clicks.
    >
    > I was hoping to do something other than constant polling for the status of
    > the mouse buttons, as ideally, it would be best if I can 'eat' those mouse
    > clicks and not pass them down to whatever process also 'sees' clicks.


    I don't think this is allowed or desired in X11 desktops. Global Hooks
    like in Windows are not desired in X11 as far as I know.

    Instead go into your Window Manager's shortcut (hotkey) setup, and
    assign some keyboard combination to launch your menu application. I do
    this often for some specific apps I use regularly. The Win-keys might be
    a good choice or the Search/Home, Mail, Calculator buttons. Or if you
    have one of the more fancy keyboard like I have (Microsoft Natural
    Ergonomic Keyboard 4000), you have 5 'My favourites" buttons you can
    assign to anything. ;-)


    Regards,
    - Graeme -

  19. Re: Middle-Mouse button

    On 2008-09-01, Graeme Geldenhuys wrote:
    > DanS wrote:
    >> Greeting's,
    >>
    >> I'm searching for a reliable technique that will allow me to capture middle
    >> mouse button clicks.
    >>
    >> I was hoping to do something other than constant polling for the status of
    >> the mouse buttons, as ideally, it would be best if I can 'eat' those mouse
    >> clicks and not pass them down to whatever process also 'sees' clicks.

    >
    > I don't think this is allowed or desired in X11 desktops. Global Hooks
    > like in Windows are not desired in X11 as far as I know.


    it depends on the window manager, twm whilst not looking very flash
    is extremely configurable in how it handles user input.

    gnome has "stardards" and doesn't go for such things to the same
    extent

    Bye.
    Jasen

  20. Re: Middle-Mouse button

    Bernhard Agthe wrote in news:g90a40$q4r$1@daniel-
    new.mch.sbs.de:

    > Hi,
    >
    >> It started off as just a simple launcher program where the middle

    click
    >> would just immediately show the menu to launch programs...and over

    time
    > [...]
    >
    > Actually it sounds like you're trying to apply a Windows-problem to
    > Linux. Don't bother - good launcher applications do exist and they
    > usually are assigned to a hot-key.


    I haven't found any good launcher programs. Of course, good in my opinion
    is one that acts as mine does. The only motion required is to move a
    finger 1/2" to the middle button and click. The one's I have seen require
    you to click on the destop (which means possibly having to move/min/unmax
    a window), or have a 'hot-spot' on the screen, or move to this edge or
    that edge.

    It all started like 15 years ago whe I ran across this freeware menu
    program called Flash!Menu, which operated as mine, but just a plain menu,
    not even icons. I used it until I decided I wanted it to be a bit more
    'flashy'. And then it evolved into full-blown shell.

    Look, I'm all for using s/w that has been written already, and decided a
    long time ago, that there was so much freeware and shareware available to
    do almost anything you want that writing something myself was futile
    unless I really had to have functions that nothing out there offered.

    > So just have your application assigned to any hot key (for example you
    > could dis-use the windows-key) and pop up whenever the key is pressed.
    > You don't have to mess with system-wide mouse-handling and you can

    still
    > use the extremely helpful middle-mouse-button for copy-and-paste
    > operation (actually your web browser is likely to use the middle button
    > as well, at least if you're using firefox).


    All this mention of a hot-key.....seems like it wouldn't be the most
    optimum way for my app to be run. In my understanding, a hot-key setup
    will run a program. My program should be constantly running. In order for
    that to work, the hot key would need to be used to launch a second
    instance of the app, which would then check for an existing instance, and
    if it finds it, notify my previously running app to show itself.

    Is this correct ?

    All this talk of Linux and how it's so flexible and can do things you
    can't do in Windows, it seems as if I can't do this. Nor can I seem to
    disable the middle-click paste either. It should be my choice right ?

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast