Jump to content

AverMedia ReCentral USB Button


JRSmile
 Share

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 comment
Share on other sites

  • 3 years later...

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

×
×
  • Create New...