本文介绍了释放LMB时如何将MoveMouseRelative反转到确切的第一位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试为Logitech鼠标创建一个脚本:
I am trying to make a script for Logitech mouse that:
- 第1步:按下LMB时->进行反冲模式
- 第2步:释放LMB后->在按下之前将MoveMouseRelative移到精确位置
那么有什么办法可以尝试步骤2?这是脚本:
So is there any way to try out step 2? This is the script:
local Recoil_Pattern = {
{x = 0 ,y = 10 } ,--1st Shot
{x = 0 ,y = 10 } ,--2nd Shot (hold LMB 100ms)
{x = 0 ,y = 10 } ,--3rd Shot (hold LMB 200ms)
{x = 0 ,y = 10 } ,--4rd Shot (hold LMB 300ms)
{x = 0 ,y = 10 } ,--5rd Shot (hold LMB 400ms)
}
local Shot_Sleep = 100
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
if (IsMouseButtonPressed(1)) then
for i = 1, #Recoil_Pattern do
Sleep(10)
if IsMouseButtonPressed(1) then
Sleep(Shot_Sleep)
MoveMouseRelative( Recoil_Pattern[i].x, Recoil_Pattern[i].y )
end
end
end
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then
if not (IsMouseButtonPressed(1)) then
Sleep(10)
-- How to reverse the MoveMouseRelative to exact first position when releasing LMB
-- Ex.
-- If press and release LMB -> move mouse relative (0,-10)
-- If press and hold LMB for 100ms then release LMB -> move mouse relative (0,-20)
-- If press and hold LMB for 400ms then release LMB -> move mouse relative (0,-50)
end
end
end
Edit2:太好了,在全自动拍摄模式下可以正常工作,但在半自动模式下(我将暂停"按钮用作拍摄按钮),如果i == 3,则不会触发(它不会执行PressAndReleaseKey( 暂停")更多).请帮助我使其完美,我在Edit 2中更新了半自动触发模式
Great, it works fine with full auto shooting mode, but with semi-auto (I use the "pause" button as the shot button), after if i == 3 then it doesn't fire (it doesn't execute PressAndReleaseKey ( "pause") more). Please help me to make it perfect, I updated the semi-auto firing mode in Edit 2
local Recoil_Pattern = {
{x = 0 ,y = 10 } ,--1st Shot
{x = 0 ,y = 10 } ,--2nd Shot (hold LMB 100ms)
{x = 0 ,y = 10 } ,--3rd Shot (hold LMB 200ms)
{x = 0 ,y = 10 } ,--4th Shot (hold LMB 300ms)
{x = 0 ,y = 10 } ,--5th Shot (hold LMB 400ms)
}
local Shot_Sleep = 100
local recoil_sum_x, recoil_sum_y = 0, 0
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
for i = 1, #Recoil_Pattern do
Sleep(10)
if IsMouseButtonPressed(1) then
PressAndReleaseKey("pause")
Sleep(Shot_Sleep)
local dx, dy = Recoil_Pattern[i].x, Recoil_Pattern[i].y
recoil_sum_x, recoil_sum_y = recoil_sum_x - dx, recoil_sum_y - dy
MoveMouseRelative( dx, dy )
Sleep(Shot_Sleep)
if i == 3 then
ctrl_is_down = true
PressKey("lctrl")
end
else
break
end
end
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then
if ctrl_is_down then
ctrl_is_down = false
ReleaseKey("lctrl")
end
while recoil_sum_x ~= 0 or recoil_sum_y ~= 0 do
local dx, dy = recoil_sum_x, recoil_sum_y
dx = dx > 127 and 127 or dx < -127 and -127 or dx
dy = dy > 127 and 127 or dy < -127 and -127 or dy
MoveMouseRelative( dx, dy )
recoil_sum_x, recoil_sum_y = recoil_sum_x - dx, recoil_sum_y - dy
Sleep(10)
end
end
end
推荐答案
local Recoil_Pattern = {
{x = 0 ,y = 10 } ,--1st Shot
{x = 0 ,y = 10 } ,--2nd Shot (hold LMB 100ms)
{x = 0 ,y = 10 } ,--3rd Shot (hold LMB 200ms)
{x = 0 ,y = 10 } ,--4rd Shot (hold LMB 300ms)
{x = 0 ,y = 10 } ,--5rd Shot (hold LMB 400ms)
}
local Shot_Sleep = 100
local recoil_sum_x, recoil_sum_y = 0, 0
local ctrl_is_down
EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
for i = 1, #Recoil_Pattern do
Sleep(Shot_Sleep)
if IsMouseButtonPressed(1) then
local dx, dy = Recoil_Pattern[i].x, Recoil_Pattern[i].y
recoil_sum_x, recoil_sum_y = recoil_sum_x - dx, recoil_sum_y - dy
MoveMouseRelative( dx, dy )
if i == 3 then
ctrl_is_down = true
PressKey("lctrl")
end
else
break
end
end
elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then
if ctrl_is_down then
ctrl_is_down = false
ReleaseKey("lctrl")
end
while recoil_sum_x ~= 0 or recoil_sum_y ~= 0 do
local dx, dy = recoil_sum_x, recoil_sum_y
dx = dx > 127 and 127 or dx < -127 and -127 or dx
dy = dy > 127 and 127 or dy < -127 and -127 or dy
MoveMouseRelative( dx, dy )
recoil_sum_x, recoil_sum_y = recoil_sum_x - dx, recoil_sum_y - dy
Sleep(10)
end
end
end
这篇关于释放LMB时如何将MoveMouseRelative反转到确切的第一位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!