Page 1 of 1

5 button mouse

Posted: Sun Dec 12, 2010 8:25 am
by Blue Steel
I have a 5 button mouse .. can someone plz tell me how i can read when i've pressed one of them.. and so that it tells mew which one.. I know i can do it for 3 but how about the other 2 (and also combinations there of)

Re: 5 button mouse

Posted: Sun Dec 12, 2010 4:51 pm
by Rook Zimbabwe
Is it a CAD mouse or a programmable mouse?

CAD mouse you probably just have to scan for inputs... programmable mouse it would be handled by the driver of that mouse!

I have a logitech gaming mouse with 4 buttons and a roller... all set uppable in the mouse icon under control panel as I installed the driver.

Re: 5 button mouse

Posted: Sun Dec 12, 2010 7:52 pm
by IdeasVacuum
You can use the API commands such as GetAsyncKeyState()

Microsoft has some constants:
VK_LBUTTON Left mouse button
VK_RBUTTON Right mouse button
VK_MBUTTON Middle mouse button (three-button mouse)
VK_XBUTTON1 (0x05) X1 mouse button
VK_XBUTTON2 (0x06) X2 mouse button

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Re: 5 button mouse

Posted: Mon Dec 13, 2010 3:33 am
by Blue Steel
Thanks for the info, can you write an example please ;) I've never been able to get api calls to weork properly for me from in PureBasic.. I've always stuffed them up

I've just been searching the net since i posted that message.. i've found out that you need to use

DIMOUSESTATE2 (reports up to 8 buttons) as opposed to DIMOUSESTATE (reports 4 buttons)

so maybe just might need a tweak in the compiler ( hint.. for future release of PureBasic) that is if Pure basic is using those routines

Re: 5 button mouse

Posted: Mon Dec 13, 2010 5:51 am
by IdeasVacuum
Something like this:

Code: Select all

Procedure ShowWin()

       If OpenWindow(0, 0, 0, 500, 500, "Mouse Clicks", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) : EndIf

EndProcedure


Procedure WaitForUser()
;----------------------

    iEvent.i = 0
    iGdgID.i = 0
    #VK_XBUTTON1 = $05
    #VK_XBUTTON2 = $06

    Repeat ; Start of the event loop

              iEvent = WaitWindowEvent(1)

              If GetAsyncKeyState_(#VK_LBUTTON) & 1 :  Debug "Left Mouse Clicked" : EndIf
              If GetAsyncKeyState_(#VK_RBUTTON) & 1 :  Debug "Right Mouse Clicked" : EndIf
              If GetAsyncKeyState_(#VK_MBUTTON) & 1 :  Debug "Middle Mouse Clicked" : EndIf
              If GetAsyncKeyState_(#VK_XBUTTON1) & 1 : Debug "X1 Mouse Clicked" : EndIf
              If GetAsyncKeyState_(#VK_XBUTTON2) & 1 : Debug "X2 Mouse Clicked" : EndIf

    Until iEvent = #PB_Event_CloseWindow

EndProcedure


ShowWin()
WaitForUser()

End
PB may even 'know' the VK_XBUTTONs already, I don't know as I only have a 3-button mouse. There are other 'OEM' constants that could also be used for mouse button input, so a little bit of experimenting and perhaps a manufacturer's guide will be necessary.

Re: 5 button mouse

Posted: Mon Dec 13, 2010 3:30 pm
by PureLust
IdeasVacuum wrote:..., I don't know as I only have a 3-button mouse.
Your example works fine on the System I'm working on right now :
- WinXP-SP3, x86
- 5-Button Mouse (Raptor LM1 - standard MS-Driver, Version: 5.1.2600.0, Date: 01.07.2001)

Re: 5 button mouse

Posted: Mon Dec 13, 2010 5:14 pm
by Blue Steel
yup.. it works .. how about 7 button now ;)

Re: 5 button mouse

Posted: Tue Dec 14, 2010 4:00 pm
by IdeasVacuum
..... the input devices are getting too complicated. I think at some time we will evolve and grow twice as many fingers just so we can use them.

Re: 5 button mouse

Posted: Wed Dec 15, 2010 1:57 am
by Blue Steel
lol.. there are already mice out there with 15 buttons .. lol
but they are only for right handed ppl .. unfortunatly I only have a left hand which really makes things difficult and limiting me emensly which is why I need to be able to support what i have and can use and test

Re: 5 button mouse

Posted: Sat Feb 27, 2016 5:15 pm
by Fredi
How can detect this keys in system global?
For example detect #VK_XBUTTON1 when press it in Firefox.

Unfortunately This code not working:

Code: Select all

#VK_XBUTTON1 = $05
#VK_XBUTTON2 = $06

Repeat ; Start of the event loop
     
     
     If GetAsyncKeyState_(#VK_LBUTTON) & 1 :  Debug "Left Mouse Clicked" : EndIf
     If GetAsyncKeyState_(#VK_RBUTTON) & 1 :  Debug "Right Mouse Clicked" : EndIf
     If GetAsyncKeyState_(#VK_MBUTTON) & 1 :  Debug "Middle Mouse Clicked" : EndIf
     If GetAsyncKeyState_(#VK_XBUTTON1) & 1 : Debug "X1 Mouse Clicked" : EndIf
     If GetAsyncKeyState_(#VK_XBUTTON2) & 1 : Debug "X2 Mouse Clicked" : EndIf
     
     Delay(1)
     
Forever