我想在揚聲器和耳機之間輕鬆切換。這可能嗎?
答案1
有多種方法可以切換預設音訊設備。然而,由於沒有公開的 API,這些技術主要涉及諸如嘗試傳送密鑰,這不是很穩健。
API 保持封閉且無文件記錄,以避免硬體不相容,這樣製造商就不會像瀏覽器上的預設主頁那樣爭奪它。然而,有人已經設法在 Windows 7 中透過命令列切換音訊設備,並且在評論中 WarNov 已經“在 Windows 8 中進行了測試。完美運行”。
請記住,它使用的是未記錄的 API,因此可能會在未來版本的 Windows 中出現故障。
正如 Jerry 已經提到的,您可以創建帶圖塊的快捷方式,只要讓它呼叫C++程式碼即可。如果你想在.NET中使用它,你也可以使用包裝器。
該程式碼也發佈在 GitHub 上音訊端點控制器,帶有關於如何使用它的易於理解的文檔:
> EndPointController.exe --help
Lists active audio end-point playback devices or sets default audio end-point
playback device.
USAGE
EndPointController.exe [-a] [-f format_str] Lists audio end-point playback
devices that are enabled.
EndPointController.exe device_index Sets the default playback device
with the given index.
OPTIONS
-a Display all devices, rather than just active devices.
-f format_str Outputs the details of each device using the given format
string. If this parameter is ommitted the format string
defaults to: "Audio Device %d: %ws"
Parameters that are passed to the 'printf' function are
ordered as follows:
- Device index (int)
- Device friendly name (wstring)
- Device state (int)
- Device default? (1 for true 0 for false as int)
- Device description (wstring)
- Device interface friendly name (wstring)
- Device ID (wstring)''
答案2
那麼,磁貼可以是批次檔或 PowerShell 檔案的捷徑。點擊圖塊將執行批次或 PS 檔案。這意味著您可以建立一個磁貼來執行 Windows 中的任何操作。
這是CS技術:
未標記為答案的答案似乎是 Windows 7/8 的解決方案。
我很遺憾地說,對於這個特定的 API 來說,這可能是最好的了。
這是捷徑技術:http://www.howtogeek.com/74331/how-to-create-your-own-windows-8-shortcuts-for-shutdown-perhaps/
哦,順便說一句,Windows RT 裝置也有 PowerShell