Windows 筆電有一個奇怪的 bug

那就是當筆電開啟藍芽時,會去搶別人的連線,導致連線中的藍芽耳機 (eg. Airpods) 被迫中斷而跟它連線。

  •  https://discussions.apple.com/thread/250063688

  •  https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware/bluetooth-keeps-re-connecting-my-airpods/3561d945-c4e2-41ef-80de-f797c01b4c6c

  •  https://superuser.com/questions/1310471/how-do-i-keep-my-bluetooth-headphones-from-connecting-to-my-windows-10-machine-w

這是 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 給關閉;需要用藍芽時,要再手動打開來。

未命名.png

4.   於動作中選擇「啟動程式」,程式碼填寫「powershell」,引數填寫「C://PATH_TO_YOUR_PS1 Off」。

      其中,C://PATH_TO_YOUR_PS1 要替換成你第一步所建立的檔案之路徑。

未命名.png

5.   於條件中,把「只有在電腦是使用 AC 電源時才啟動這個工作」取消勾選。


 

經過以上的步驟,就能讓電腦在從休眠或睡眠中恢復時,自動關閉藍芽連線了!

這樣就能避免從睡眠中恢復的電腦,搶走正在聆聽音樂的藍芽耳機。

如果你有用藍芽滑鼠、藍芽鍵盤等裝置的話,也會使得這些裝置跟著中斷連線,因此可能就要另尋解方了!

arrow
arrow
    創作者介紹
    創作者 Davidhu127 的頭像
    Davidhu127

    I Stand Up For Myself

    Davidhu127 發表在 痞客邦 留言(0) 人氣()