介绍
这个脚本在看视频时很有用,通过热键可以切换鼠标的锁定,从此不用担心误碰鼠标导致弹出进度条了。
脚本
使用的热键是ScrollLock的扫描码,一般情况下不会用到,但我很喜欢这个热键。
可以根据自身喜好进行更改。
注意: 这里依旧使用了先前分享的
更常用的ToolTip
,作用是显示提示,并在几秒钟后关闭它。
使用
alt + ScrollLock 切换鼠标锁定状态。
!SC046::
{
static flag := true
if flag {
BlockInput("MouseMove")
Tip.ShowTip('Block Mouse')
} else {
BlockInput("MouseMoveOff")
Tip.ShowTip('Unlock Mouse')
}
flag := !flag
}
2024/06/25 补充
在许久前我给此添加了新功能,现在抽空来更新了。
添加了锁定时按热键执行任务列表,可以前进和回退。
我记得当时是看视频时,锁定了鼠标,想移动鼠标还需要解锁;于是添加了热键,可以在锁定时执行函数,也可以撤销此次操作。
#Requires AutoHotkey v2.0
#SingleInstance Force
#Include G:\AHK\git-ahk-lib\Extend.ahk
#Include G:\AHK\git-ahk-lib\Tip.ahk
flag_mouse_block := false
!SC046:: {
global flag_mouse_block
if flag_mouse_block
BlockInput("MouseMoveOff"), Tip.ShowTip('Unlock Mouse')
else BlockInput("MouseMove"), Tip.ShowTip('Block Mouse')
flag_mouse_block := !flag_mouse_block
}
{
#HotIf flag_mouse_block
LButton:: ActionCtrl.undo()
RButton:: ActionCtrl.do()
#HotIf
}
/**
* @example
* actions := [
* [Fn(MsgBox, '1'), Fn(MsgBox, '-1')],
* [Fn(MsgBox, '2'), Fn(MsgBox, '-2')],
* [Fn(MsgBox, '3'), Fn(MsgBox, '-3')]
* ]
* ActionCtrl.init(actions)
* n:: ActionCtrl.do()
* m:: ActionCtrl.undo()
*/
class ActionCtrl {
static actions := [], idx := 1, step := 0
static resetIdx() => this.idx := 1
static resetStep() => this.step := 0
static init(actions) => this.actions := actions
static do() {
if !this.actions.Length
return Tip.ShowTip('没有下一步喵~')
if this.idx > this.actions.Length
this.resetIdx(), this.resetStep(), Tip.ShowTip('重新开始喵~')
this.actions[this.idx++][1](), this.step++
}
static undo() {
if this.step {
this.actions[--this.idx][2](), this.step--
} else Tip.ShowTip('没有上一步喵~')
}
}