2

PROBLEM: microsoft Designer Bluetooth Mouse and Keyboard disconnect if idle for 10min

UNSUCCESSFUL:

--> probably to weird BT connection

WORKAROUND: setting my laptop on Airplane mode on and off resets the clock in my devices; so tried to use Task Scheduler to run a batch file that would turn this mode on and off if the computer has been idle for 5 minutes.

QUESTION: could not find a command line / batch / script to turn this mode on or off. Even better would be to turn only Bluetooth on and off. Anyone?

Thanks a million, lots of questions around on how to fix such disconnect issues, have done all they suggested but now focusing on tihs workaround.

jmw
  • 21

1 Answers1

1

Yes you can turn Bluetooth on/off via batch script.

devcon enable "your_bluetooth_device_instance_id"
devcon disable "your_bluetooth_device_instance_id"

Here's an example script that would turn it on/off. Just get Windows Task Scheduler to run it every 5 minutes when idle.

@echo off

REM Set the threshold of idle time (in seconds) set IDLE_TIME=300

REM Set the device instance IDs of your Bluetooth devices set MOUSE_ID=your_mouse_device_instance_id set KEYBOARD_ID=your_keyboard_device_instance_id

REM Get the last input time (in ticks) for /f "usebackq tokens=3 delims=: " %%i in (quser ^| findstr /B /C:">>>") do set LAST_INPUT=%%i

REM Loop forever :loop

REM Get the current input time (in ticks) for /f "usebackq tokens=3 delims=: " %%i in (quser ^| findstr /B /C:">>>") do set CURRENT_INPUT=%%i

REM Calculate the idle time (in seconds) set /a IDLE_TIME_DIFF=%CURRENT_INPUT% - %LAST_INPUT% if %IDLE_TIME_DIFF% geq %IDLE_TIME% (

REM Turn off Bluetooth
devcon disable %MOUSE_ID%
devcon disable %KEYBOARD_ID%

REM Wait for 5 seconds to make sure Bluetooth is turned off
timeout /t 5 /nobreak > nul

REM Turn on Bluetooth
devcon enable %MOUSE_ID%
devcon enable %KEYBOARD_ID%

REM Reset the last input time
for /f "usebackq tokens=3 delims=: " %%i in (`quser ^| findstr /B /C:">>>"`) do set LAST_INPUT=%%i

)

REM Wait for 1 second before checking the input time again timeout /t 1 /nobreak > nul

goto loop