通过蓝牙连接 PS3 控制器并在断开连接时关闭它们时,启动 DS4Windows 和 Steam,无线耳机连接时,切换音频

#NoEnv
#SingleInstance, Force
SendMode Input
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 3

OnMessage(0x219, "notify_change")
return

notify_change(wParam, lParam, msg, hwnd)
{
	global
	MyClip := ClipboardAll
	Clipboard := ""
	ElapsedTime := A_TickCount - StartTime

	if (ElapsedTime) and (ElapsedTime < 2500) {
		StartTime := A_TickCount
		Clipboard := MyClip
		return
	}

	Device1 = 53F88889-1AAF-4353-A047-556B69EC6DA6 ; PS3 Controller
	Device2 = 0000110B-0000-1000-8000-00805F9B34FB ; Headset (Mpow MBits S Stereo)

	PS = Get-WmiObject Win32_PNPEntity | Sort-Object -Property DeviceID | Format-Table DeviceID | clip
	RunWait, PowerShell.exe -Command "%PS%",, Hide
	FoundPos := RegExMatch(Clipboard, Device1, Dev1) RegExMatch(Clipboard, Device2, Dev2)
	Clipboard := ""

	if Dev1 = %Device1%
	{
		Process, Exist, DS4Windows.exe
		if !errorLevel
			Run, C:\Programmes\DS4Windows\DS4Windows.exe,,Min ; Programs to Run when device1 is connected
		Sleep, 125
		Run, C:\Program Files (x86)\Steam\steam.exe,,Min
	}
	else {
		Process, Close, DS4Windows.exe  ; Programs to close when device1 is disconnected
		Sleep, 125
		Process, Close, steam.exe
	}

	if Dev2 = %Device2%
	{
		Run, C:\Programmes\nircmd-x64\nircmd.exe setDefaultsounddevice "Mpow MBits S" ; Program to Run when device2 is connected
	}

	StartTime := A_TickCount
	Clipboard := MyClip
}

给TA捐赠
共{{data.count}}人
人已捐赠
其他案例

USB退出自动执行的例子

2022-1-25 10:02:36

其他

AutoHotkey使用API函数检测蓝牙设备状态

2022-1-25 16:37:30

3 条回复 A文章作者 M管理员
  1. ?13800

    看看学习

个人中心
购物车
优惠劵
有新私信 私信列表
搜索