0
function OnEvent(event, arg)

EnablePrimaryMouseButtonEvents(1)

    if (event == "MOUSE_BUTTON_PRESSED" and arg == 1) do
        PressAndReleaseKey("lalt")
            Sleep(15000)
end
end

当我左键单击时,我有这个脚本可以按 Alt,但我不希望它每次都发生。

我想添加一个 15 秒的“冷却时间”,这样脚本就不会在 15 秒内重复。

我添加的睡眠功能在 PressAndReleaseKey 之前运行。

我怎样才能交换这两个?

4

1 回答 1

0
local prev_time = -math.huge

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true)
   elseif event == "MOUSE_BUTTON_PRESSED" and arg == 1 then
      local this_time = GetRunningTime()
      if this_time - prev_time > 15000 then
         prev_time = this_time
         PressKey("lalt")
         Sleep(50)
         ReleaseKey("lalt")
      end
   end
end
于 2020-06-08T15:07:46.940 回答