要为按键赋予新的触发器并取消实际的真实触发器,可以使用BetterTouchTool提供的AppleScript API。下面是一个示例代码,演示了如何使用AppleScript来设置和取消按键的触发器。
-- 设置按键的新触发器
tell application "BetterTouchTool"
set shortcutTrigger to make new shortcut trigger with properties {shortcut:"cmd+1"}
tell shortcutTrigger
set action to "trigger_named"
set additional_action_information to "my_custom_trigger"
end tell
end tell
-- 取消按键的触发器
tell application "BetterTouchTool"
set triggers to shortcut triggers
repeat with trigger in triggers
if shortcut of trigger is "cmd+1" then
delete trigger
end if
end repeat
end tell
在这个示例中,我们首先使用AppleScript API创建了一个新的shortcut trigger,将其快捷键设置为“cmd+1”,并将触发的动作设置为“trigger_named”,并指定了自定义触发器名称为“my_custom_trigger”。
然后,我们通过遍历所有shortcut trigger,找到快捷键为“cmd+1”的trigger并将其删除,从而取消实际的触发器。
请确保你已经在BetterTouchTool中启用了AppleScript支持,可以在BetterTouchTool的首选项中的“AppleScript”选项中启用它。
注意:上述示例仅为演示目的,如果你要在实际项目中使用该功能,请根据实际需求进行适当的修改。