Logitech scripting combining keystroke and mouse click

12,410

First of all, you have to define EnablePrimaryMouseButtonEvents() to enables event reporting for mouse button 1

To avoid any endless loop you have to put sleep();

Press left control key then left mouse button it will repeat the click until you release the left mouse button then release left control key the script should be stopped

Your final code should be like:

EnablePrimaryMouseButtonEvents(true);

function OnEvent(event, arg)
    if IsModifierPressed("lctrl") then
        repeat  
            if IsMouseButtonPressed(1) then
                repeat
                    PressMouseButton(1)
                    Sleep(15)
                    ReleaseMouseButton(1)
                until not IsMouseButtonPressed(1)
            end             
        until not IsModifierPressed("lctrl")
    end         
end
Share:
12,410
Liam
Author by

Liam

Founder & CEO of PaidTabs.com The Complete Package For Music Scores Founder & CEO of iBitcoin.se Advanced cryptocurrency wallet & block explorer. Founder & CEO of Ziggs.io Secure, Easy, Private Messenger, Best to share data & files between developers. Programming knowledge in ReactJS, React Native(IOS & Android), ReduxJS, MobxJS, WebRTC, CSS, Javascript, JSON, Regular Expression. I also developed https://shrroy.github.io/react-snackbar-g/ Link to the package https://github.com/Shrroy/react-snackbar-g What is Ziggs? 💻Ziggs is like a meeting point with your devices, it helps you to transfer pictures, videos, and even APK apps with your friends seamlessly. 🗄Ziggs doesn't store any type of data and doesn't require your personal information. Messages are delivered directly from your device to the connected clients.

Updated on June 04, 2022

Comments

  • Liam
    Liam almost 2 years

    I'm trying to make a script that repeatedly clicks left mouse button when I hold left control key with left mouse button at the same time

    This is what I have so far:

    function OnEvent(event, arg, family)
      OutputLogMessage("clicked event = %s, arg = %s\n", event, arg);
     if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and Ctrl_Down == 1 then
          repeat
          PressMouseButton(1) //repeat while the left mouse button down
          until not PressMouseButton(1)
         else ReleaseMouseButton(3) //stop the repating on left mouse button up
      end
    
    end  
    

    Please note this is my first time looking over this type of coding as any help is greatly appreciated