Windows 筆電有一個奇怪的 bug
那就是當筆電開啟藍芽時,會去搶別人的連線,導致連線中的藍芽耳機 (eg. Airpods) 被迫中斷而跟它連線。
• https://discussions.apple.com/thread/250063688
這是 Windows 的 "功能" 之一,看起來近期內應該不會修復....QQ
這邊提供一個簡單的解法:(不太適合藍芽滑鼠、藍芽鍵盤使用者)
1. 首先,根據這篇 StackExchange 文的步驟,將以下程式碼貼進記事本,並將檔名存成 "bluetooth.ps1":
[CmdletBinding()] Param (
[Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$BluetoothStatus
)
If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv }
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
[Windows.Devices.Radios.Radio,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
[Windows.Devices.Radios.RadioAccessStatus,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
Await ([Windows.Devices.Radios.Radio]::RequestAccessAsync()) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null
$radios = Await ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]])
$bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' }
[Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null
Await ($bluetooth.SetStateAsync($BluetoothStatus)) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null
2. 接下來,開啟工作排程器 (Task Schedular),按右邊的「建立工作」。
3. 於觸發程序中選擇「事件發生時」,記錄檔選擇「系統」,來源選擇「Power-Troubleshooter」,識別碼寫 「1」。
如此一來,當電腦從休眠或睡眠中恢復時,就會將 Bluetooth 給關閉;需要用藍芽時,要再手動打開來。
4. 於動作中選擇「啟動程式」,程式碼填寫「powershell」,引數填寫「C://PATH_TO_YOUR_PS1 Off」。
其中,C://PATH_TO_YOUR_PS1 要替換成你第一步所建立的檔案之路徑。
5. 於條件中,把「只有在電腦是使用 AC 電源時才啟動這個工作」取消勾選。
經過以上的步驟,就能讓電腦在從休眠或睡眠中恢復時,自動關閉藍芽連線了!
這樣就能避免從睡眠中恢復的電腦,搶走正在聆聽音樂的藍芽耳機。
如果你有用藍芽滑鼠、藍芽鍵盤等裝置的話,也會使得這些裝置跟著中斷連線,因此可能就要另尋解方了!