Jump to content

AverMedia ReCentral USB Button


Recommended Posts

Hi,

i changed a hid script i found here to support the avermedia HotButton, now you can execute autoit functions with the press of a stylish button.

Live_Gamer_HD_Button.thumb.jpg.a305ca0206b334a46644647bdb8c2b53.jpg

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Change2CUI=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#NoTrayIcon
#include <APISysConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPIGdi.au3>
#include <WinAPIMisc.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>

Global $g1_toogle = False

$atagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct'
$atagRID_INFO_HID = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_HID & ';dword Unused[2]'

Opt('TrayAutoPause', 0)
; Create GUI
Global $g_hForm = GUICreate('AVButton', 100, 25, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Local $tRID = DllStructCreate($tagRAWINPUTDEVICE)
DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK)
DllStructSetData($tRID, 'hTarget', $g_hForm)

DllStructSetData($tRID, 'UsagePage', 0xFFA0) ; AverMedia Hot Button
DllStructSetData($tRID, 'Usage', 0x01) ;
_WinAPI_RegisterRawInputDevices($tRID)

; Now iterate to find other devices
Local $tText, $aData = _WinAPI_EnumRawInputDevices()
If IsArray($aData) Then
    ReDim $aData[$aData[0][0] + 1][3]
    $tText = DllStructCreate('wchar[256]')
    For $i = 1 To $aData[0][0]
        If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then
            $aData[$i][2] = DllStructGetData($tText, 1)
        Else
            $aData[$i][2] = ''
        EndIf

        If $aData[$i][1] = $RIM_TYPEHID Then
            $devInf = DllStructCreate($atagRID_INFO_HID)

            If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO) Then
                If DllStructGetData($devInf, 'VendorId') = 0x07ca And DllStructGetData($devInf, 'ProductId') = 0x9850 Then ; ReCentral Button VID & PID
                    ConsoleWrite("Device Info:-" & @CRLF)
                    ConsoleWrite('VendorId: ' & Hex(DllStructGetData($devInf, 'VendorId'), 4) & @CRLF)
                    ConsoleWrite('ProductId: ' & Hex(DllStructGetData($devInf, 'ProductId'), 4) & @CRLF)
                    ConsoleWrite('VersionNumber: ' & DllStructGetData($devInf, 'VersionNumber') & @CRLF)
                    ConsoleWrite('UsagePage: ' & Hex(DllStructGetData($devInf, 'UsagePage'), 2) & @CRLF)
                    ConsoleWrite('Usage: ' & Hex(DllStructGetData($devInf, 'Usage'), 2) & @CRLF)

                    DllStructSetData($tRID, 'UsagePage', DllStructGetData($devInf, 'UsagePage'))
                    DllStructSetData($tRID, 'Usage', DllStructGetData($devInf, 'Usage'))
                    _WinAPI_RegisterRawInputDevices($tRID)
                EndIf
            EndIf
        EndIf
    Next
EndIf



; Register WM_INPUT message
GUIRegisterMsg($WM_INPUT, 'WM_INPUT')

GUISetState(@SW_HIDE)

Global $structHID_DATA = "struct;" & _
        "dword Type;" & _
        "dword Size;" & _
        "handle hDevice;" & _
        "wparam wParam;" & _
        "dword dwSizeHid;" & _
        "dword dwCount;" & _
        "endstruct;"


Global $structWACOM_PEN_DATA = "struct;" & _
        "dword Type;" & _
        "dword Size;" & _
        "handle hDevice;" & _
        "wparam wParam;" & _
        "dword dwSizeHid;" & _
        "dword dwCount;" & _
        "ubyte bRawData00;" & _
        "ubyte penvsEraser;" & _
        "word x;" & _
        "word y;" & _
        "word proximity;" & _
        "word pressure;" & _
        "ubyte bRawData09;" & _
        "ubyte bRawData10;" & _
        "ubyte bRawData11;" & _
        "ubyte bRawData12;" & _
        "ubyte bRawData13;" & _
        "ubyte bRawData14;" & _
        "ubyte bRawData15;" & _
        "ubyte bRawData16;" & _
        "ubyte bRawData17;" & _
        "ubyte bRawData18;" & _
        "ubyte bRawData19;" & _
        "ubyte bRawData20;" & _
        "ubyte bRawData21;" & _
        "ubyte bRawData22;" & _
        "ubyte bRawData23;" & _
        "ubyte bRawData24;" & _
        "ubyte bRawData25;" & _
        "ubyte bRawData26;" & _
        "ubyte bRawData27;" & _
        "ubyte bRawData28;" & _
        "ubyte bRawData29;" & _
        "ubyte bRawData30;" & _
        "ubyte bRawData31;" & _
        "ubyte bRawData32;" & _
        "ubyte bRawData33;" & _
        "ubyte tilt_ba;" & _
        "ubyte bRawData35;" & _
        "ubyte tilt_na;" & _
        "ubyte bRawData37;" & _
        "endstruct;"

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam


    Switch $hWnd
        Case $g_hForm
            Local $tRIM = DllStructCreate($tagRAWINPUTHEADER)
            If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_HEADER) Then ; Retrieves the raw input from the specified device
                $devType = DllStructGetData($tRIM, 'Type')
                $devSize = DllStructGetData($tRIM, 'Size')
            Else
                ConsoleWrite("Device Header Retrieval Failed" & @CRLF)
                Return
            EndIf

            ; Now use the handle to the device to get it's name
            Local $tText = DllStructCreate('wchar[256]')
            If _WinAPI_GetRawInputDeviceInfo(DllStructGetData($tRIM, 'hDevice'), $tText, 256, $RIDI_DEVICENAME) Then
                $devName = DllStructGetData($tText, 1)
            Else
                ConsoleWrite("Device Name Retrieval Failed" & @CRLF)
            EndIf

            If $devType = $RIM_TYPEHID Then

                $tRIM = DllStructCreate($structWACOM_PEN_DATA)
                If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then
                    If DllStructGetData($tRIM, 9) = 1 Then ; Button Pressed
                        ConsoleWrite("GO" & @CRLF)
                    EndIf
                EndIf
            EndIf

    EndSwitch
    Sleep(10)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_INPUT

 

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By JRSmile
      Hi,
      i searched the forum to communicate with a logitech G600 without using Shortcuts or Default Mouse Keys.
      the code below lets u use your sidekeys whenever you press down the ring key.
      before using the code you will have to unassign the keys in the logitech mouse driver software.
      The source of my code is a wacom usb script, wich was heavily modified to work.
      you might find some parts wierd, thats because this is my first attempt to communicate via raw hid. 
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #cs ; #include "CommMG.au3" $mgdebug = True Global $sportSetError $tset = _ComGetPortNames() for $i = 0 to UBound($tset) -1 if $tset[$i][1] = "Serielles USB-Gerät" Then $COMPort = StringTrimLeft($tset[$i][0],3) ConsoleWrite("Teensy an Port COM" & $COMPort & " gefunden!" & @CRLF) EndIf Next $resOpen = _CommSetPort($COMPort,$sportSetError,31250, 8,0,1,0,0,0) if $resOpen = 0 then ConsoleWrite($sportSetError & @LF) ;~ Exit EndIf #ce $atagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct' $atagRID_INFO_HID = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_HID & ';dword Unused[2]' Opt('TrayAutoPause', 0) ; Create GUI Global $g_hForm = GUICreate('G600', 100, 25, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $g_hForm) DllStructSetData($tRID, 'UsagePage', 0x80) ; Logitech G600 DllStructSetData($tRID, 'Usage', 0x0A) ; _WinAPI_RegisterRawInputDevices($tRID) ; Now iterate to find other devices Local $tText, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][3] $tText = DllStructCreate('wchar[256]') For $i = 1 To $aData[0][0] If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then $aData[$i][2] = DllStructGetData($tText, 1) Else $aData[$i][2] = '' EndIf If $aData[$i][1] = $RIM_TYPEHID Then $devInf = DllStructCreate($atagRID_INFO_HID) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO ) Then If DllStructGetData($devInf, 'VendorId') = 0x046D And DllStructGetData($devInf, 'ProductId') = 0xC24A then ; G600 VID & PID ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite ('VendorId: ' & Hex(DllStructGetData($devInf, 'VendorId'),4) & @CRLF) ConsoleWrite ('ProductId: ' & Hex(DllStructGetData($devInf, 'ProductId'),4) & @CRLF) ConsoleWrite ('VersionNumber: ' & DllStructGetData($devInf, 'VersionNumber') & @CRLF) ConsoleWrite ('UsagePage: ' & Hex(DllStructGetData($devInf, 'UsagePage'),2) & @CRLF) ConsoleWrite ('Usage: ' & Hex(DllStructGetData($devInf, 'Usage'),2) & @CRLF) DllStructSetData($tRID, 'UsagePage', DllStructGetData($devInf, 'UsagePage')) DllStructSetData($tRID, 'Usage', DllStructGetData($devInf, 'Usage')) _WinAPI_RegisterRawInputDevices($tRID) EndIf EndIf EndIf Next EndIf ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') GUISetState(@SW_SHOW) Global $structHID_DATA = "struct;" & _ "dword Type;" & _ "dword Size;" & _ "handle hDevice;" & _ "wparam wParam;" & _ "dword dwSizeHid;" & _ "dword dwCount;" & _ "endstruct;" Global $structWACOM_PEN_DATA = "struct;" & _ "dword Type;" & _ "dword Size;" & _ "handle hDevice;" & _ "wparam wParam;" & _ "dword dwSizeHid;" & _ "dword dwCount;" & _ "ubyte bRawData00;" & _ "ubyte penvsEraser;" & _ "word x;" & _ "word y;" & _ "word proximity;" & _ "word pressure;" & _ "ubyte bRawData09;" & _ "ubyte bRawData10;" & _ "ubyte bRawData11;" & _ "ubyte bRawData12;" & _ "ubyte bRawData13;" & _ "ubyte bRawData14;" & _ "ubyte bRawData15;" & _ "ubyte bRawData16;" & _ "ubyte bRawData17;" & _ "ubyte bRawData18;" & _ "ubyte bRawData19;" & _ "ubyte bRawData20;" & _ "ubyte bRawData21;" & _ "ubyte bRawData22;" & _ "ubyte bRawData23;" & _ "ubyte bRawData24;" & _ "ubyte bRawData25;" & _ "ubyte bRawData26;" & _ "ubyte bRawData27;" & _ "ubyte bRawData28;" & _ "ubyte bRawData29;" & _ "ubyte bRawData30;" & _ "ubyte bRawData31;" & _ "ubyte bRawData32;" & _ "ubyte bRawData33;" & _ "ubyte tilt_ba;" & _ "ubyte bRawData35;" & _ "ubyte tilt_na;" & _ "ubyte bRawData37;" & _ "endstruct;" Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $g_hForm Local $tRIM = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_HEADER) Then ; Retrieves the raw input from the specified device $devType = DllStructGetData($tRIM, 'Type') $devSize = DllStructGetData($tRIM, 'Size') Else ConsoleWrite ("Device Header Retrieval Failed" & @CRLF) Return EndIf ; Now use the handle to the device to get it's name Local $tText = DllStructCreate('wchar[256]') If _WinAPI_GetRawInputDeviceInfo(DllStructGetData($tRIM, 'hDevice'), $tText, 256, $RIDI_DEVICENAME) Then $devName = DllStructGetData($tText, 1) Else ConsoleWrite ("Device Name Retrieval Failed" & @CRLF) EndIf if $devType = $RIM_TYPEHID Then $tRIM = DllStructCreate($structWACOM_PEN_DATA) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then if DllStructGetData($tRIM, 8) = 32 Then ; filter for ring key down (G-Mode) Switch DllStructGetData($tRIM, 9) ; if in g mode assign the Keys G9 to G20 to autoit functions. case 0 Return ; key released case 1 g1() case 2 g2() case 4 g3() case 8 g4() case 16 g5() case 32 g6() case 64 g7() case 128 g8() case 256 g9() case 512 g10() case 1024 g11() case 2048 g12() Case Else ;;; ConsoleWrite(DllStructGetData($tRIM, 9) & @CRLF) EndSwitch EndIf EndIf EndIf EndSwitch sleep(50) Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT Func g1() ;~ Send("2") ConsoleWrite("g1" & @CRLF) ;~ _CommSendString("KEY_TAB" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_RELEASE_ALL" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_2" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_RELEASE_ALL" & @LF) EndFunc Func g2() ConsoleWrite("g2" & @CRLF) EndFunc Func g3() ConsoleWrite("g3" & @CRLF) EndFunc Func g4() ConsoleWrite("g4" & @CRLF) EndFunc Func g5() ConsoleWrite("g5" & @CRLF) EndFunc Func g6() ConsoleWrite("g6" & @CRLF) EndFunc Func g7() ConsoleWrite("g7" & @CRLF) EndFunc Func g8() ConsoleWrite("g8" & @CRLF) EndFunc Func g9() ConsoleWrite("g9" & @CRLF) EndFunc Func g10() ConsoleWrite("g10" & @CRLF) EndFunc Func g11() ConsoleWrite("g11" & @CRLF) EndFunc Func g12() ConsoleWrite("g12" & @CRLF) EndFunc  
×
×
  • Create New...