Jump to content

Test mouse middle, side front and side back buttons


duckling78
 Share

  

1 member has voted

  1. 1. Was this useful?

    • Suuuure...
      0
    • Not really...


Recommended Posts

I made a script to test my mouse to see if the middle button and the two thumb buttons are registering correctly. Here it is!

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Local $r = 0x800000
Local $g = 0x008000

main()

Func main()
    Opt("GUIOnEventMode", 1)

    HotKeySet("{Esc}", "exitScript")

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Mouse Button Test", 310, 272, 192, 124)
    GUISetOnEvent($GUI_EVENT_CLOSE, "exitScript")
    $textMiddle = GUICtrlCreateLabel("Middle", 112, 8, 62, 27)
    GUICtrlSetFont($textMiddle, 12, 400, 0, "Arial Black")
    GUICtrlSetColor($textMiddle, $r)
    $textFront = GUICtrlCreateLabel("Side Front", 16, 80, 95, 27)
    GUICtrlSetFont($textFront, 12, 400, 0, "Arial Black")
    GUICtrlSetColor($textFront, $r)
    $textBack = GUICtrlCreateLabel("Side Back", 64, 144, 93, 27)
    GUICtrlSetFont($textBack, 12, 400, 0, "Arial Black")
    GUICtrlSetColor($textBack, $r)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    $dll = DllOpen("user32.dll")

    $MIDDLE_BUTTON = "04"
    $BACK_BUTTON = "05"
    $FORWARD_BUTTON = "06"

    $mP = False
    $bP = False
    $fP = False

    While True
        $mC = _IsPressed($MIDDLE_BUTTON)
        $bC = _IsPressed($BACK_BUTTON)
        $fC = _IsPressed($FORWARD_BUTTON)

        setColor($textMiddle, $mC)
        setColor($textFront, $fC)
        setColor($textBack, $bC)

        If ($mP <> $mC Or $bP <> $bC Or $fP <> $fC) Then
            ConsoleWrite("M: " & $mC & ", F: " & $fC & ", B: " & $bC & @CRLF)
            $mP = $mC
            $bP = $bC
            $fP = $fC
        EndIf

        Sleep(5)
    WEnd
EndFunc

Func setColor($text, $active)
    If ($active) Then
        GUICtrlSetColor($text, $g)
    Else
        GUICtrlSetColor($text, $r)
    EndIf
EndFunc

Func exitScript()
    Exit
EndFunc

One thing I found out was that the middle mouse button on the Logitech g9x is unreliable. If you hear the clicking sound it doesn't mean the mouse button is down. There are variable pressures in the button that will activate or deactivate the button. Very annoying! I'm going to see if Logitech can give me a new mouse without this problem...

Also I've noticed the two side buttons don't register properly using some specific mouse covers (using g9 mouse cover on the g9x). This was more of a troubleshooting step since I like the g9's mouse cover texture better than the newer g9x's.

Link to comment
Share on other sites

To avoid flickering of your labels you can do like this :

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Local $r = 0x800000
Local $g = 0xFF0000
Opt("GUIOnEventMode", 1)
HotKeySet("{Esc}", "_ExitScript")

$Form1 = GUICreate("Mouse Button Test", 310, 272, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_ExitScript")
$textMiddle = GUICtrlCreateLabel("Middle", 112, 30, 62, 27)
GUICtrlSetFont($textMiddle, 14, 1000, 0, "Arial Black")
GUICtrlSetColor($textMiddle, $r)
$textFront = GUICtrlCreateLabel("Side Front", 250, 100, 95, 27)
GUICtrlSetFont($textFront, 14, 1000, 0, "Arial Black")
GUICtrlSetColor($textFront, $r)
$textBack = GUICtrlCreateLabel("Side Back", 16, 100, 93, 27)
GUICtrlSetFont($textBack, 14, 1000, 0, "Arial Black")
GUICtrlSetColor($textBack, $r)
GUISetState(@SW_SHOW)

$dll = DllOpen("user32.dll")
$MIDDLE_BUTTON = "04"
$BACK_BUTTON = "05"
$FORWARD_BUTTON = "06"
Global $mP = False, $bP = False, $fP = False, $mCold, $bCold, $fCold

While True
    $mC = _IsPressed($MIDDLE_BUTTON)
    $bC = _IsPressed($BACK_BUTTON)
    $fC = _IsPressed($FORWARD_BUTTON)
    If $mC <> $mCold Then 
        _SetColor($textMiddle, $mC)
        $mCold = $mC
    EndIf
    If $fC <> $fCold Then 
        _SetColor($textFront, $fC)
        $fCold = $fC
    EndIf   
    If $bC <> $bCold Then 
        _SetColor($textBack, $bC)
        $bCold = $bC
    EndIf   
    If ($mP <> $mC Or $bP <> $bC Or $fP <> $fC) Then
        ConsoleWrite("M: " & $mC & ", F: " & $fC & ", B: " & $bC & @CRLF)
        $mP = $mC
        $bP = $bC
        $fP = $fC
    EndIf
    Sleep (5)
WEnd

Func _SetColor($text, $active)
    If ($active) Then
        GUICtrlSetColor($text, $g)
    Else
        GUICtrlSetColor($text, $r)
    EndIf
EndFunc

Func _ExitScript()
    Exit
EndFunc

I just noticed that my middle mouse button is dead Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...