使用 lua 发送垃圾密钥

Spamming Key with lua

我正在尝试创建一个脚本,该脚本在按下 windows 键时向 w 发送垃圾邮件,但它显示 Lua 错误 (5):无效参数:未指定修饰符,这是我的脚本。 . 任何帮助将不胜感激

EnablePrimaryMouseButtonEvents(true)

function OnEvent(event, arg)
   if  IsModifierPressed ("appkey") then --windows key is appkey i am assuming
      repeat
         Sleep(100)
         PressKey("w")
         Sleep(100)
         ReleaseKey("w")
      until  not IsModifierPressed ("appkey")
   end
end                                                      

而且我也在尝试制作一个快速切换脚本,如果我同时按下鼠标右键和鼠标左键,那么它会自动按下键 q,但是我得到了语法错误Error:Line:2

     EnablePrimaryMouseButtonEvents(true) 
        function OnEvent(event, arg)
     if (event == "MOUSE_BUTTON_PRESSED" and arg == "3","1" then
         repeat
         PressKey("q") 
        Sleep(2) 
        ReleaseKey("q") 
        end 
 end
          

根据手册,修饰符必须是以下字符串之一:

"lalt", "ralt", "alt", "lshift", "rshift", "shift", "lctrl", "rctrl", "ctrl"

"appkey" 不在该列表中。因此你得到一个错误。请阅读手册。

https://douile.github.io/logitech-toggle-keys/APIDocs.pdf 第 17 页

Windows 键是“lgui”和“rgui”,它只是一个键,不是修饰符。修饰符修改键的含义,顾名思义。

-- if I press the right mouse button and left mouse button at the same time 
-- then it would automatically press the key q

function OnEvent(event, arg)
   if event == "PROFILE_ACTIVATED" then
      EnablePrimaryMouseButtonEvents(true) 
   elseif event == "MOUSE_BUTTON_PRESSED" and arg < 3 then
      repeat
         Sleep(10)
         if IsMouseButtonPressed(1) and IsMouseButtonPressed(3) then 
            PressKey("q") 
            Sleep(10) 
            ReleaseKey("q") 
         else
            break 
         end 
      until nil
   end
end