|
发表于 2025-8-20 20:47:44
来自手机
|
显示全部楼层
// 按键精灵一键静音脚本
// 使用说明:运行后按F10键切换静音状态
// 初始化变量
Dim muteStatus
muteStatus = false
// 显示提示信息
Call ShowMessage()
// 主循环,监听热键
While True
// 检测F10键是否按下
If GetLastKey() = 122 Then // 122是F10的键码
Call ToggleMute()
Delay 300 // 防抖延迟
End If
Delay 100 // 降低CPU占用
Wend
// 切换静音状态函数
Sub ToggleMute()
// 发送静音快捷键(一般是Ctrl+Shift+F11,可根据系统调整)
KeyPress 162, 1 // 按下Ctrl
KeyPress 160, 1 // 按下Shift
KeyPress 122, 1 // 按下F11
Delay 50
KeyPress 122, 2 // 弹起F11
KeyPress 160, 2 // 弹起Shift
KeyPress 162, 2 // 弹起Ctrl
// 更新状态并显示提示
muteStatus = not muteStatus
If muteStatus Then
ShowMessage "系统已静音"
Else
ShowMessage "取消静音"
End If
End Sub
// 显示消息函数
Sub ShowMessage(Optional msg)
If IsEmpty(msg) Then
TracePrint "一键静音脚本已启动"
TracePrint "按 F10 键切换静音状态"
TracePrint "按 F12 键停止脚本"
Else
TracePrint msg
End If
End Sub
// 停止脚本热键检测(F12键停止)
Function GetLastKey()
GetLastKey = WaitKey()
If GetLastKey = 123 Then // 123是F12的键码
TracePrint "脚本已停止"
EndScript
End If
End Function// 按键精灵一键静音脚本
// 使用说明:运行后按F10键切换静音状态
// 初始化变量
Dim muteStatus
muteStatus = false
// 显示提示信息
Call ShowMessage()
// 主循环,监听热键
While True
// 检测F10键是否按下
If GetLastKey() = 122 Then // 122是F10的键码
Call ToggleMute()
Delay 300 // 防抖延迟
End If
Delay 100 // 降低CPU占用
Wend
// 切换静音状态函数
Sub ToggleMute()
// 发送静音快捷键(一般是Ctrl+Shift+F11,可根据系统调整)
KeyPress 162, 1 // 按下Ctrl
KeyPress 160, 1 // 按下Shift
KeyPress 122, 1 // 按下F11
Delay 50
KeyPress 122, 2 // 弹起F11
KeyPress 160, 2 // 弹起Shift
KeyPress 162, 2 // 弹起Ctrl
// 更新状态并显示提示
muteStatus = not muteStatus
If muteStatus Then
ShowMessage "系统已静音"
Else
ShowMessage "取消静音"
End If
End Sub
// 显示消息函数
Sub ShowMessage(Optional msg)
If IsEmpty(msg) Then
TracePrint "一键静音脚本已启动"
TracePrint "按 F10 键切换静音状态"
TracePrint "按 F12 键停止脚本"
Else
TracePrint msg
End If
End Sub
// 停止脚本热键检测(F12键停止)
Function GetLastKey()
GetLastKey = WaitKey()
If GetLastKey = 123 Then // 123是F12的键码
TracePrint "脚本已停止"
EndScript
End If
End Function |
|