Logitech G系鼠标脚本编程,实现鼠标自动定位控制
利用罗技官方提供的API来写一个鼠标自动定位移动脚本
点击脚本编辑器中的帮助选项,查看罗技官方提供的API说明,有很多实现好的鼠标功能

G-series Lua API V8.45 Overview and Reference

下面是我写的一个自动压枪代码。在csgo游戏中实现SG553,AUG两种步枪的自动压枪功能,以及通用武器自动压枪功能
--全局变量区
condition = false --功能启用状态开关
weapon = nil --当前所用的武器 --武器弹道参数--------------------------------------------------------------------------
--AUG步枪
onWeaponAUG = function()
local arr = {}
local arrLength =
local weaponDuration =
local x ={}
local y ={} x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]=- y[]=
x[]=- y[]=
x[]= y[]=
x[]= y[]= arr[] = x
arr[] = y
arr[] = weaponDuration
arr[] = arrLength
return arr
end
----------------------------------------------------------------------------
--SG553步枪
onWeaponSG553 = function()
local arr= {}
local arrLength =
local weaponDuration =
local x ={}
local y ={} x[]= - y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]=2
x[]=- y[]=2
x[]=- y[]=2
x[]=- y[]=2
x[]=- y[]=2
x[]=- y[]=2
x[]=- y[]=
x[]=- y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]=- y[]=-
x[]=- y[]=-
x[]=- y[]=
x[]= y[]=-
x[]= y[]=-
x[]= y[]=-
x[]= y[]=-
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]=- y[]=
x[]=- y[]=
x[]=- y[]= arr[] = x
arr[] = y
arr[] = weaponDuration
arr[] = arrLength
return arr
end
----------------------------------------------------------------------------
--通用武器
onWeaponAll = function()
local arr= {}
local arrLength =
local weaponDuration =
local x ={}
local y ={} x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]=
x[]= y[]= arr[] = x
arr[] = y
arr[] = weaponDuration
arr[] = arrLength
return arr
end
----------------------------------------------------------------------------
--入口函数
function OnEvent(event,arg)
--控制台格式化输出当前的按健
--OutputLogMessage("event = %s, arg = %d\n", event, arg)
activate(event,arg)
decide(event,arg)
end ---------------------------------------------------------------------------
--激活鼠标按健报告函数
activate = function(event,arg)
if (event == "PROFILE_ACTIVATED") then --配置文件被激活
EnablePrimaryMouseButtonEvents(true) --启用鼠标按健1的事件报告
elseif event == "PROFILE_DEACTIVATED" then --配置文件没有被激活
EnablePrimaryMouseButtonEvents(false) --禁用鼠标按健1的事件报告
end
end ---------------------------------------------------------------------------
--功能判断函数
decide = function(event,arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == then -- 按下6键 关闭压枪功能
ClearLog()
OutputLogMessage(">>>OFF\n")
condition = false
weapon = nil
elseif event == "MOUSE_BUTTON_PRESSED" and arg == then -- 按下4键 选择SG553步枪
ClearLog()
OutputLogMessage(">>>USING SG553")
condition = true
weapon = onWeaponSG553()
elseif event == "MOUSE_BUTTON_PRESSED" and arg == then -- 按下5键 选择aug步枪
ClearLog()
OutputLogMessage(">>>USING AUG")
condition = true
weapon = onWeaponAUG()
elseif event == "MOUSE_BUTTON_PRESSED" and arg == then -- 按下5键 选择aug步枪
ClearLog()
OutputLogMessage(">>>USING All")
condition = true
weapon = onWeaponAll()
elseif event == "MOUSE_BUTTON_PRESSED" and arg == and condition == true then --按住鼠标1键 自动开火并鼠标自动压枪
fire(weapon)
end
end ---------------------------------------------------------------------------
--武器开火,执行功能函数
fire = function ( parametersArr )
local arr = parametersArr
local arrX = arr[]
local arrY = arr[]
local weaponDuration = arr[]
local length = arr[] for x=,length, do
for y=x,length, do
if moveMouse(arrX[x],arrY[y],weaponDuration) == false then break end
break
end
end
end ----------------------------------------------------------------------------
--鼠标自动移动函数
moveMouse = function(x,y,time)
if IsMouseButtonPressed() then
MoveMouseRelative(x,y)
Sleep(time)
return true
else
return false
end
end
代码功能
以上代码按健的配置是基于罗技G502鼠标,其它
按下鼠标6键关闭自动控制功能
按下鼠标7 键开启指定武器鼠标控制
按下鼠标5 键开启指定武器鼠标控制
按下鼠标4 键开启指定武器鼠标控制
按住鼠标1 键,检查自动控制功能是否开启,如果开启便调用指定函数执行
关键功能函数说明,具体使用说明请参考官方说明文档
MoveMouseRelative(x,y) 移动鼠标指针至当前屏幕中的目标绝对坐标位置
Sleep(time) 暂停脚本并等待所设置的时间后再继续执行
OnEvent() 方法为脚本提供了一系列事件句柄以方便用户对触发的事件进行操
OutputLogMessage() 在控制台输出指定内容
EnablePrmaryMouseButtonEvent() 开启鼠标1键的事件报告
Logitech G系鼠标脚本编程,实现鼠标自动定位控制的更多相关文章
- MFC控件编程之鼠标跟键盘消息
MFC控件编程之鼠标跟键盘消息 在MFC中鼠标消息.键盘消息我们很常用.所以说一下. 鼠标消息分为客户区消息.跟非客户区消息. 一丶客户区消息 我们可以处理消息.来进行我们相应的函数即可. MFC添加 ...
- SVG脚本编程简介
本文主要介绍SVG的脚本编程,并分别给出放大.缩小,查询,鼠标事件等实例. 一. SVG简介 SVG,全称为Scalable Vector Graphics(可伸缩矢量图形).它是W3C制定的.用矢量 ...
- Vbs 脚本编程简明教程之一
—为什么要使用 Vbs ? 在 Windows 中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改名.删除,也许你每天启动 计算机第一件 ...
- 脚本命令高级Bash脚本编程指南(31):数学计算命令
题记:写这篇博客要主是加深自己对脚本命令的认识和总结实现算法时的一些验经和训教,如果有错误请指出,万分感谢. 高等Bash脚本编程指南(31):数学盘算命令 成于坚持,败于止步 操作数字 factor ...
- javascript进阶——分离式DOM脚本编程
编写分离式(unobstrusive)代码意味着对HTML内容的完全分离:数据来自服务器端,javascript代码用来动态化和交互.这种分离的好处是在不同浏览器之间使用是可以完全降级或升级运行,对于 ...
- Linux shell脚本编程(一)
Linux shell脚本编程: 守护进程,服务进程:启动?开机时自动启动: 交互式进程:shell应用程序 广义:GUI,CLI GUI: CLI: 词法分析:命令,选项,参数 内建命令: 外部命令 ...
- linux脚本编程技术
linux脚本编程技术 一.什么是脚本 脚本是一个包含一系列命令序列的可执行(777)文本文件.当运行这个脚本文件时,文件中包含的命令序列将得到自动执行. 二.脚本编程 #!/bin/sh 首行固定格 ...
- linux脚本编程技术---8
一.什么是脚本 脚本是一个包含一系列命令序列的可执行(777)文本文件.当运行这个脚本文件时,文件中包含的命令序列将得到自动执行. 二.脚本编程 #!/bin/sh 首行固定格式 #!表明该脚本的的解 ...
- 【Linux】Shell脚本编程(一)
Linux shell脚本编程: 守护进程,服务进程:启动?开机时自动启动: 交互式进程:shell应用程序 广义:GUI,CLI GUI: CLI: 词法分析:命令,选项,参数 内建命令: 外部命令 ...
随机推荐
- E.XKC's basketball team(The Preliminary Contest for ICPC Asia Xuzhou 2019)
https://nanti.jisuanke.com/t/41387 解: 离散化+线段树. #define IOS ios_base::sync_with_stdio(0); cin.tie(0); ...
- js跨域原理及解决方案
方法一:jsonp函数 在HTML DOM中,Script标签是可以跨域访问服务器上的数据的.因此,可以指定script的src属性为跨域的url,基于script标签实现跨域.script标签本身就 ...
- Huge Packet Drops (Tx drops) Observed on NetScaler
Huge Packet Drops (Tx drops) Observed on NetScaler 来源 https://support.citrix.com/article/CTX215843 ...
- wpf之二进制资源
一.当需要添加图片.音频.视屏的资源到wpf项目里是,可以直接把文件添加到项目里 右击add->existing item. 1.如果想将外部文件编异常目标成为二进制资源,在文件的属性窗口 Bu ...
- JQuery --- 第六期 (Ajax)
欢迎访问我的个人博客,获取更多有用的东西 链接一 链接二 也可以关注我的微信订阅号:CN丶Moti 点击查看Ajax
- Java8 常用Function、Predicate、Consumer、Supplier接口
1.常用函数是接口: (1)Function<T, R> => R apply(T t) ———— 接受一个T类型的参数,返回R类型结果. Function<Integer, ...
- 嵌套For循环性能优化
请对以下的代码进行优化 for (int i = 0; i < 1000; i++) for (int j = 0; j < 100; j++) for (int k = 0; k < ...
- 描述Cookie和Session的作用,区别和各自的应用范围,Session工作原理
Session用于保存每个用户的专用信息. 每个客户端用户访问时,服务器都为每个用户分配一个唯一的会话ID(Session ID) . 她的生存期是用户持续请求时间再加上一段时间(一般是20分钟左右) ...
- CentOS 7自动以root身份登录GNOME桌面
CentOS 7自动以root身份登录GNOME桌面 修改配置文件 /etc/gdm/custom.conf,在 [daemon] 下面添加一下两行 AutomaticLoginEnable=true ...
- linux命令详解——crontab
基本格式 : * * * * * command 分 时 日 月 周 命令 第1列表示分钟1-59 每分钟用*或者 */1表示 第2列表示小时1-23(0表示0点) 第3列表示日期1-31 第4列表示 ...