外设天下 - 电脑外设发烧友聚集地

12345下一页
我的人缘0
发表于 2014-9-20 21:11 显示全部楼层 阅读模式
本帖最后由 AndroidOL 于 2014-10-13 15:58 编辑

  自从入了第一把机械后就在外设长期潜水(似乎没注册帐号应该连潜水也算不上吧),最近由于某些需求需要使用一些脚本就行自动操作,无意间发现 Logitech Gaming Software 集成 Lua 脚本功能并且为用户提供了 API 参考文档,但是同学说全英文的他实在提不起劲看下去,于是就做了一些简单的翻译,欢迎各位找错。

  市面上大多数可编程键盘都是录制宏键或者进行一些简单的鼠标操作等等,而 Logitech Gaming Software 中所提供的 API 包括了日常使用中进行的所有操作,比如获取某键状态、按下或释放某键、获取日期以及时间、移动鼠标至屏幕某处、模拟鼠标按键按下状态等,并且兼容 LUA 脚本代码。支持所有 Logitech G 系列外设。

  翻译项目已完成,如果需要脚本代码请留下需求,等有时间了我会在本帖回复:)

G-series Lua API 参考文档.zip (514.85 KB, 下载次数: 8634)

评分

参与人数 4技术分 +2 发烧值 +37 收起 理由
kohyzsc123 + 2
LuckyBird929 + 2 + 32 你真棒!
冰火英雄 + 2 碉堡了
jihang1991 + 1 碉堡了

查看全部评分

回复

使用道具 举报

我的人缘0
发表于 2014-9-21 08:03 显示全部楼层

LUA 接近于自然语言编程所以应该不会有多少学习障碍。

if (event == "G_RELEASED") then
 ReleaseKey(2)
 ReleaseKey(1 + arg - 4)
end

如果 (事件 为 G键释放) 则
 释放按键 2
 释放按键 1 + arg - 4
结束
回复 支持 1 反对 1

使用道具 举报

我的人缘0
发表于 2014-9-21 13:42 显示全部楼层

调用 API 移动鼠标以及输出按键信息

本帖最后由 AndroidOL 于 2014-10-12 15:30 编辑
  1. flag = 0
  2. --ClearLog()

  3. --[[
  4. function getScanCode()
  5.   OutputLogMessage("Call Function.\n")
  6.   PressAndReleaseMouseButton(1)
  7. end
  8. ]]--

  9. function OnEvent(event, arg)
  10.   --getScanCode()
  11.   if (flag > 10) then
  12.     ClearLog()
  13.     flag = 0
  14.   else
  15.     flag = flag + 1
  16.   end
  17.   flag_MKey = GetMKeyState()
  18.   if (event == "M_PRESSED") then
  19.     OutputLogMessage("M%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  20.     flag_MKey = arg
  21.   elseif (event == "M_RELEASED") then
  22.     OutputLogMessage("M%d-Key was released. Event time: %s!\n", arg, GetDate())
  23.     flag_MKey = arg
  24.   elseif (flag_MKey == 1) then
  25.     if (event == "G_PRESSED") then
  26.       OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  27.       PressKey(1 + arg)
  28.     end
  29.     if (event == "G_RELEASED") then
  30.       OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  31.       ReleaseKey(1 + arg)
  32.     end
  33.   elseif (flag_MKey == 2) then
  34.     if (arg < 4) then
  35.       if (event == "G_PRESSED") then
  36.         OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  37.         PressKey(7 + arg)
  38.       end
  39.       if (event == "G_RELEASED") then
  40.         OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  41.         ReleaseKey(7 + arg)
  42.       end
  43.     elseif (arg == 4) then
  44.       if (event == "G_PRESSED") then
  45.         OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  46.         PressKey(2)
  47.         PressKey(11)
  48.       end
  49.       if (event == "G_RELEASED") then
  50.         OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  51.         ReleaseKey(2)
  52.         ReleaseKey(11)
  53.       end
  54.     elseif (arg == 5) then
  55.       if (event == "G_PRESSED") then
  56.         OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  57.         PressKey(2)
  58.         ReleaseKey(2)
  59.         PressKey(1 + arg - 4)
  60.       end
  61.       if (event == "G_RELEASED") then
  62.         OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  63.         --ReleaseKey(2)
  64.         ReleaseKey(1 + arg - 4)
  65.       end
  66.     else
  67.       if (event == "G_PRESSED") then
  68.         OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  69.         PressKey(2)
  70.         PressKey(1 + arg - 4)
  71.       end
  72.       if (event == "G_RELEASED") then
  73.         OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  74.         ReleaseKey(2)
  75.         ReleaseKey(1 + arg - 4)
  76.       end
  77.     end
  78.   elseif (flag_MKey == 3) then
  79.     if (event == "G_PRESSED") then
  80.       OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  81.       PressKey(2)
  82.       PressKey(3 + arg)
  83.     end
  84.     if (event == "G_RELEASED") then
  85.       OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  86.       ReleaseKey(2)
  87.       ReleaseKey(3 + arg)
  88.     end
  89.   else
  90.     OutputLogMessage("Bad Input!")
  91.   end
  92. --[[
  93.   if (arg == 1) then
  94.     MoveMouseToVirtual(0, 0)
  95.   elseif (arg == 2) then
  96.     MoveMouseToVirtual(65535, 0)
  97.   elseif (arg == 3) then
  98.     MoveMouseToVirtual(0, 65535)
  99.   elseif (arg == 4) then
  100.     MoveMouseToVirtual(65535, 65535)
  101.   else
  102.     MoveMouseToVirtual(65535 / 2, 65535 / 2)
  103.   end
  104. ]]--
  105. end
复制代码
回复 支持 1 反对 0

使用道具 举报

我的人缘0
发表于 2014-9-21 10:51 显示全部楼层
硬伤啊,才发现居然一秒检测一次,理论无法执行超过一秒的脚本。。。
回复 支持 1 反对 0

使用道具 举报

我的人缘1
发表于 2014-9-20 22:16 显示全部楼层
测试
没看懂- -

点评

LUA 接近于自然语言编程所以应该不会有多少学习障碍。 if (event == "G_RELEASED") then  ReleaseKey(2)  ReleaseKey(1 + arg - 4) end 如果 (事件 为 G键释放) 则  释放按键 2  释放按键 1 + arg -  详情 回复 发表于 2014-9-21 08:03
回复 支持 1 反对 0

使用道具 举报

我的人缘0
发表于 2014-9-20 22:11 显示全部楼层
貌似很高端
回复 支持 1 反对 0

使用道具 举报

我的人缘0
发表于 2014-9-20 21:14 显示全部楼层

使用 G1~G6 联合 M1~M3 输出数字 1~18 且不影响原功能

本帖最后由 AndroidOL 于 2014-10-12 19:25 编辑
  1. flag = 0
  2. --ClearLog()

  3. --[[
  4. function getScanCode()
  5.   OutputLogMessage("Call Function.\n")
  6.   PressAndReleaseMouseButton(1)
  7. end
  8. ]]--

  9. function OnEvent(event, arg)
  10.   --getScanCode()
  11.   if (flag > 10) then
  12.     ClearLog()
  13.     flag = 0
  14.   else
  15.     flag = flag + 1
  16.   end
  17.   flag_MKey = GetMKeyState()
  18.   if (flag_MKey == 1) then
  19.     if (event == "G_PRESSED") then
  20.       OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
  21.       PressKey(1 + arg)
  22.     end
  23.     if (event == "G_RELEASED") then
  24.       OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
  25.       ReleaseKey(1 + arg)
  26.     end
  27.   elseif (flag_MKey == 2) then
  28.     if (arg < 4) then
  29.       if (event == "G_PRESSED") then
  30.         PressKey(7 + arg)
  31.       end
  32.       if (event == "G_RELEASED") then
  33.         ReleaseKey(7 + arg)
  34.       end
  35.     elseif (arg == 4) then
  36.       if (event == "G_PRESSED") then
  37.         PressKey(2)
  38.         PressKey(11)
  39.       end
  40.       if (event == "G_RELEASED") then
  41.         ReleaseKey(2)
  42.         ReleaseKey(11)
  43.       end
  44.     elseif (arg == 5) then
  45.       if (event == "G_PRESSED") then
  46.         PressKey(2)
  47.         ReleaseKey(2)
  48.         PressKey(1 + arg - 4)
  49.       end
  50.       if (event == "G_RELEASED") then
  51.         --ReleaseKey(2)
  52.         ReleaseKey(1 + arg - 4)
  53.       end
  54.     else
  55.       if (event == "G_PRESSED") then
  56.         PressKey(2)
  57.         PressKey(1 + arg - 4)
  58.       end
  59.       if (event == "G_RELEASED") then
  60.         ReleaseKey(2)
  61.         ReleaseKey(1 + arg - 4)
  62.       end
  63.     end
  64.   elseif (flag_MKey == 3) then
  65.     if (event == "G_PRESSED") then
  66.       PressKey(2)
  67.       PressKey(3 + arg)
  68.     end
  69.     if (event == "G_RELEASED") then
  70.       ReleaseKey(2)
  71.       ReleaseKey(3 + arg)
  72.     end
  73.   else
  74.     OutputLogMessage("Bad Input!")
  75.   end
  76. --[[
  77.   if (arg == 1) then
  78.     MoveMouseToVirtual(0, 0)
  79.   elseif (arg == 2) then
  80.     MoveMouseToVirtual(65535, 0)
  81.   elseif (arg == 3) then
  82.     MoveMouseToVirtual(0, 65535)
  83.   elseif (arg == 4) then
  84.     MoveMouseToVirtual(65535, 65535)
  85.   else
  86.     MoveMouseToVirtual(65535 / 2, 65535 / 2)
  87.   end
  88. ]]--
  89. end
复制代码
回复 支持 1 反对 0

使用道具 举报

我的人缘0
发表于 2014-9-21 14:21 显示全部楼层
测试
有意思的东西。

点评

问个问题~罗技G系列最便宜的是100s么?602和700差在哪儿?为何价格差那么多。。。600的G键那么多为何销量那么低。。。  详情 回复 发表于 2014-9-25 19:12
我觉得任何宏都可以用这个完成,用 Lua 鼠标也没问题。  详情 回复 发表于 2014-9-21 18:47
回复 支持 反对

使用道具 举报

我的人缘0
发表于 2014-9-21 18:47 显示全部楼层

我觉得任何宏都可以用这个完成,用 Lua 操作鼠标也没问题。
回复 支持 反对

使用道具 举报

我的人缘0
发表于 2014-9-25 19:12 显示全部楼层
测试

问几个问题哈~

罗技G系列最便宜的是100s么?100似乎停产?
602和700差在哪儿?为何价格差一倍?
600的G键那么多为何销量居然那么低?

点评

G系列鼠标最便宜的应该是G90吧?100停产了。 G602是中端产品,作为第一款02结尾的G系列鼠标G602充其量也就是罗技的一个试水产品, G700算是高端,引擎、微动、滚轮等多方面因素决定了价格。 G600定位一样也是中端  详情 回复 发表于 2014-10-12 16:31
如果告诉你G602的引擎和G100一样的?  详情 回复 发表于 2014-9-29 18:54
回复 支持 反对

使用道具 举报

12345下一页
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则