Skip to content

Instantly share code, notes, and snippets.

@gabrielstelmach
Created June 22, 2023 19:31
Show Gist options
  • Save gabrielstelmach/60dcaba182ed8845b928a6b2655a139d to your computer and use it in GitHub Desktop.
Save gabrielstelmach/60dcaba182ed8845b928a6b2655a139d to your computer and use it in GitHub Desktop.
Attempts to switch Logitech device to channel 2 using all possible values
@echo off
setlocal EnableDelayedExpansion
rem Run trough values 0 to 31 in hex for position C
for /L %%a in (0, 1, 31) do (
for /F %%b in ('DecToHex.bat %%a') do (
@set "hex_c=%%b"
rem Pad left 0
if "%%a" lss 16 (
@set "hex_c=0!hex_c!"
)
)
rem Run trough values 0 to 31 in hex for position D
for /L %%c in (0, 1, 31) do (
for /F %%d in ('DecToHex.bat %%c') do (
@set "hex_d=%%d"
rem Pad left 0
if "%%c" lss 16 (
@set "hex_d=0!hex_d!"
)
)
rem Call the application attempting to change the channel
echo Attempting C = %%a
echo Attempting D = %%c
echo hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x!hex_c!,0x!hex_d!,0x01,0x00,0x00
hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x!hex_c!,0x!hex_d!,0x01,0x00,0x00
rem You have 3 seconds to check the device for an eventual change in the communication channel
timeout 3 > NUL
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment