StrokesPlus.net教程及脚本持续更新

监控设备接入

0.5.5.7之前版本,新版本未测试

查看全部设备名称和ID

var devices = sp.AllDevices();
var deviceList = "";
for(var i = 0; i < devices.Count; i++)
{
    deviceList += `DeviceID: ${devices[i].DeviceID}
    Name: ${devices[i].Name}
    Description: ${devices[i].Description}
    Status: ${devices[i].Status}
`;
}
// Copy list to clipboard
clip.SetText(deviceList);

// Example to look for a specific device
if(devices.Where(d => d.Name == "Rob's Galaxy Note10").Count() > 0) {
    sp.MessageBox("Phone connected!", "Galaxy Phone via Bluetooth");
}

添加到 全局动作-硬件事件

//设置5000ms检查一次
sp.CreateTimer("DeviceWatch", 
               0, 
               5000, 
                `var devices = sp.AllDevices();
                //if(devices.Where(d => d.Name == "USB 输入设备").Count() > 0) {
                if(devices.Where(d => d.DeviceID == "HID\\VID_17EF&PID_6093\\6&18889FB2&0&0000").Count() > 0 && !sp.GetStoredBool("USBMouseDevice")) {
                    sp.MessageBox('Title', '设备连接');
                //}  else if(devices.Where(d => d.Name == "USB 输入设备").Count() === 0) {
                } else if(devices.Where(d => d.DeviceID == "HID\\\\VID_17EF&PID_6093\\\\6&38CD7B48&0&0000").Count() === 0) {
                    sp.MessageBox('Title', '设备断开连接');                    
                }
               `
);