罗技宏代码分享~
参考了如下内容:G-seriesLuaAPI.pdf。论坛大佬的例程http://bbs.d.163.com/forum.php?m ... 5879&fromuid=886696、http://bbs.d.163.com/forum.php?m ... 5879&fromuid=886696。(大佬做的脚本里面能记录屏幕坐标、能记录时间卡全能,堪称完美!!!)
这里做了个看着比较复杂的脚本,可以用来切换宏,随关随停,能防冲突。主要是想让开关按键在鼠标上,不用使用键盘上的三个lock键。
--function OnEvent(event, arg)
-- OutputLogMessage("event = %s, arg = %s\n", event, arg)
--end
--宏名仅支持英文字符(被这个坑到过QAQ)
--RestartMacro为无附加按键("lctrl""rctrl""ctrl""alt""shift")的情况
--RestartMacroAdd为有附加按键的情况
--非循环宏可受任意event打断;循环宏开启、关闭为同一按键,可受其他设置入脚本的宏打断。
--RestartMacroAdd("宏名(如tianqian)",MacroKey值(如4),event,arg,是否循环(如true));
--RestartMacroAdd("宏名(如aoyun)",MacroKey值(如4),"附加按键(如alt)",event,arg,是否循环(如true));
--可以调整的东西:
--目前共享一个标志位MacroStarted:0表示无脚本控制的宏运作,其余数字为脚本控制的对应序号的宏运作
--数字序号规律:G1-G8对应1-8为MacroKey值,引入num以区分各附加按键,引入50以区分非循环宏
--时序有点复杂,代码没精简,可能不是最佳(指不定有库函数直接解决问题呢、、)
EnablePrimaryMouseButtonEvents (true) --启用鼠标按键 1 的事件报告
MacroStarted = 0;--初始化标志位
function RestartMacro(MacroName, MacroKey, event, arg , circle)
k=1; --初始化k,用来区分有附加按键的情况
if IsModifierPressed("ctrl") then
k=0;
end
if IsModifierPressed("alt") then
k=0;
end
if IsModifierPressed("shift") then
k=0;
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == MacroKey and k==1) then
if circle == true then
if not (MacroStarted == MacroKey) then
AbortMacro(); --停止宏
PlayMacro(MacroName); --启动宏
MacroStarted = MacroKey; --宏已启动
else
if MacroStarted == MacroKey then
AbortMacro(); --停止宏
MacroStarted = 0; --宏已停止
end
end
else
PlayMacro(MacroName); --启动宏
MacroStarted = MacroKey+50;--引入50以区分非循环宏
end
end
end
function RestartMacroAdd(MacroName, MacroKey,str, event, arg,circle)
if str == "ctrl" then
num = 10; --引入num以区分各附加按键
end
if str == "alt" then
num = 20;
end
if str == "shift" then
num = 30;
end
if (event == "MOUSE_BUTTON_RELEASED" and arg == MacroKey and IsModifierPressed(str)) then
if circle == true then
if not (MacroStarted == MacroKey+num) then
AbortMacro(); --停止宏
PlayMacro(MacroName); --启动宏
MacroStarted = MacroKey+num; --宏已启动
else
if MacroStarted == MacroKey+num then
AbortMacro(); --停止宏
MacroStarted = 0; --宏已停止
end
end
else
PlayMacro(MacroName); --启动宏
MacroStarted = MacroKey+num+50;--引入50以区分非循环宏
end
end
end
function OnEvent(event, arg)
if MacroStarted > 50 then
AbortMacro(); --停止宏
MacroStarted = 0; --宏已停止
end
--以下区间添加控制
RestartMacroAdd("aoyun",4,"alt",event,arg,true);
RestartMacro("2(650ms)",4,event,arg,true);
RestartMacroAdd("aoyun1",5,"alt",event,arg,false);
--以上区间添加控制
end
很感谢分享,不过完全看不懂 只有两个功能键的能用吗?
页:
[1]