lua - 是否可以将 .ahk 转换为 .lua?
问题描述
我想在LUA中为罗技鼠标制作一个简单的宏。我完全是新手,我只是从几个来源将几行粘贴在一起。首先,它看起来像一团糟,但有点工作,对不起,我完全是新手。现在我遇到的问题是;
我想要完成的是当我按下我分配给它的任何键时,它会切换这个脚本以循环/重复,直到我再次按下任何键。
我希望能够在鼠标上按 CTRL+7 并打开重复,直到我再次按 CTRL+7 来关闭重复。
请帮忙。感谢您的时间。
OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
if event == "MOUSE_BUTTON_PRESSED" and arg == nil then
repeat
MoveMouseRelative(1280,-5000)
PressAndReleaseMouseButton(1)
Sleep(3200)
until not IsMouseButtonPressed(nil)
end
end
解决方案
第 1 步。
您在游戏中使用鼠标按钮 4(“返回”)吗?
- 如果是(游戏中某些动作设置为 MB#4),则继续“步骤 2”。
- 如果否(游戏忽略 MB#4 按下),跳过“步骤 2”并继续进行“步骤 3”。
第 2 步。
您必须将游戏动作从 MB#4 重新映射到其他键。
请执行下列操作:
- 选择您当前未在游戏中使用的键盘键
(假设F12
当前未使用该键) - 转到 GHUB(鼠标设备、“作业”屏幕、KEYS 选项卡);
分配F12
给您的物理 MB#4 - 转到您的游戏设置;
将游戏动作设置为F12
而不是 MB#4
现在,当您按下物理 MB#4 时,游戏会接收F12
并激活游戏动作。
跳过“步骤 3”并继续执行“步骤 4”。
步骤 3.
转到 GHUB(鼠标设备,“作业”屏幕)。
从物理 MB#4 取消分配标准命令“Back”(单击并从下拉菜单中选择 DISABLE)。
禁用的 MB#4 看起来像一个白色圆圈,里面有黑色。
步骤 4.
转到 GHUB(键盘设备,“作业”屏幕)。
将标准命令“Back”分配给物理键 G7。
步骤 5.
设置脚本:
local toggle, prev_down
local function Interruptable_Sleep(ms)
local tm = GetRunningTime() + ms
repeat
local now = GetRunningTime()
if now < tm then
Sleep(math.min(10, tm - now))
local down = IsMouseButtonPressed(4) -- 4 = "Back"
toggle, prev_down = toggle or not prev_down and down, down
end
until toggle or now >= tm
end
function OnEvent(event, arg)
OutputLogMessage("Event: "..event.." Arg: "..arg.."\n")
if event == "G_PRESSED" and arg == 7 then
toggle = not toggle
if toggle then
prev_down, toggle = true
repeat
for j = 1, 40 do
MoveMouseRelative(1280/40,-5000/40)
Interruptable_Sleep(10)
end
if not toggle then
PressAndReleaseMouseButton(1)
Interruptable_Sleep(3200)
end
until toggle
end
end
end
现在您可以通过按键盘键 G7 来启动和停止循环
推荐阅读
- reactjs - NPM 包包含与其他包冲突的 node_modules
- c# - C#自定义字体问题
- regex - 在 Sublime Text 3 中构建 Cargo 的 file_regex
- wso2 - 在类中查找主要方法时出错:org.wso2.carbon.bootstrap.Bootstrap:org.wso2.carbon.bootstrap.Bootstrap
- kotlin - 尽管如此,没有在所有路径上返回的自定义 getter 仍然可以编译
- docker - 如何重新访问 Docker 中的 bash 控制台?
- node.js - node-postgres:连接太多时 ECONNREFUSED
- android - 为部分添加空间项装饰
- python - 打印 1-100 的数字,跳过可被 3 和 5 整除的数字
- python - 自定义用户不是来自 django 的超级用户