Hi guys,
I listen to online radio at work with my bluetooth headphones. When I go to toilet I don't remember to take my headphones off and the headphones' bluetooth disconnects with the computer and the radio switches to play on the computer's built-in speakers.
Could you please help me with a code to mute or stop the audio when bluetooth headphones disconnect?
Thank you very much guys!!
Mute audio when bluetooth headphones disconnect
Mute audio when bluetooth headphones disconnect
*** Thank you for reading. I am not in coding and know almost nothing about professional coding, hope for your patience and deeply appreciate any of your kind helps. My current interest in this awesome AHK is due to that my work is graphical ((architect/CAD) and, to reduce strains, my right hand is better off not leaving the mouse (an MMO mouse that has 12 side keys which I maps a lot of F keys and other keys in) as much as possible. All the best you lovely coders! ***
Re: Mute audio when bluetooth headphones disconnect
You could use SetTimer, periodically checking for your BT device. Maybe this helps: viewtopic.php?p=411138#p411138 (that has been created by @malcev)
Old, but seems to be able detecting a change via the registry!? https://www.autohotkey.com/board/topic/70836-any-way-to-detect-bluetooth-device-status/
Old, but seems to be able detecting a change via the registry!? https://www.autohotkey.com/board/topic/70836-any-way-to-detect-bluetooth-device-status/
Re: Mute audio when bluetooth headphones disconnect
Are you running Windows 10? I don't have Win 11, so I can't be certain it behaves the same, but would assume it does.
My Win 10 maintains separate volume levels for each output device attached (speakers, headphones, bluetooth, etc.) You can verify this by clicking on the speaker icon in your system tray with your headphones disconnected to see the value, then connect them and see the difference.
Simply disconnect your headphones, play the radio app and adjust the volume of the speakers to at or near zero (at least to a level that won't bother your co-workers). Then, connect the headset and adjust the volume to your preference. There shouldn't be a need for any scripting - at least I don't need any on my system at work for the same reason.
Russ
My Win 10 maintains separate volume levels for each output device attached (speakers, headphones, bluetooth, etc.) You can verify this by clicking on the speaker icon in your system tray with your headphones disconnected to see the value, then connect them and see the difference.
Simply disconnect your headphones, play the radio app and adjust the volume of the speakers to at or near zero (at least to a level that won't bother your co-workers). Then, connect the headset and adjust the volume to your preference. There shouldn't be a need for any scripting - at least I don't need any on my system at work for the same reason.
Russ
Re: Mute audio when bluetooth headphones disconnect
akirofe, I think You can try to intercept WM_DEVICECHANGE message.
Some info:
https://stackoverflow.com/questions/52968462/is-there-a-windows-event-to-find-out-if-a-bluetooth-device-is-getting-paired
viewtopic.php?t=37538
Some info:
https://stackoverflow.com/questions/52968462/is-there-a-windows-event-to-find-out-if-a-bluetooth-device-is-getting-paired
viewtopic.php?t=37538
Re: Mute audio when bluetooth headphones disconnect
SendMessage (Command)
WM_MESSAGEINDEX, ...where WM_DEVICECHANGE := 0x0219
Send-/PostMessage (Tutorial)
HTH
WM_MESSAGEINDEX, ...where WM_DEVICECHANGE := 0x0219
Send-/PostMessage (Tutorial)
HTH
Re: Mute audio when bluetooth headphones disconnect
BoBo, You dont need to send this message.
You need to receive notification about this message from Your bluetooth device.
qwerty12 alreay did it for usb and We need to do the same with our bluetooth device handle and capture GUID_BLUETOOTH_RADIO_IN_RANGE event, I think.
https://docs.microsoft.com/en-us/windows/win32/bluetooth/bluetooth-and-wm-devicechange-messages
You need to receive notification about this message from Your bluetooth device.
qwerty12 alreay did it for usb and We need to do the same with our bluetooth device handle and capture GUID_BLUETOOTH_RADIO_IN_RANGE event, I think.
https://docs.microsoft.com/en-us/windows/win32/bluetooth/bluetooth-and-wm-devicechange-messages