islanq

Logitech LUA - Tutorial 1

Apr 29th, 2014
1,651
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.13 KB | None | 0 0
  1. -- /// Wrote by islanq 04/29/14 ///
  2. -- ///////////////////////////////
  3.  
  4. EnablePrimaryMouseButtonEvents (true) -- This allows the LButton events to be read
  5. function OnEvent(event, arg, family)
  6.     OutputLogMessage("event = %s, arg = %s\n", event, arg)
  7.     if event == "PROFILE_ACTIVATED" then -- If the profile is loaded
  8.         SetMouseDPITableIndex(2) -- Set the DPI to my favorite!
  9.     end
  10.  
  11. -- /// Let's Start with something easy.
  12.  
  13.  
  14.                 --{} EXAMPLE # 1 {}____________________________}--
  15.                 --{ ___________________________________________}--
  16.                 --{ basic starting example_____________________}--
  17.  
  18.  
  19.     if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then       --{A} If you press LButton then..
  20.         PressMouseButton(1)                    --{B} Press LButton (down state)
  21.     elseif event  == "MOUSE_BUTTON_RELEASED" and arg == 1 then --{C} If you release LButton then...
  22.         ReleaseMouseButton(1)                  --{D} Release the LButton (up state)    
  23.     end
  24.  
  25.  
  26. -- /// Now that you have the basics, let's try something a little more advanced. We'll use a button that is out of the way.
  27.  
  28.    
  29.                 --{} EXAMPLE # 2 {}_______________________________________}--
  30.                 --{ ______________________________________________________}--
  31.                 --{ the benefit of this is having control of the downward }--
  32.                 --{ as we well as the upward timing_______________________}--
  33.  
  34.  
  35.     if event == "MOUSE_BUTTON_PRESSED" and arg == 11 then      --{A} If our targed mouse button is pressed..
  36.         PressKey ("lalt")                  --{-}-------------------------------------------
  37.         Sleep(40)                      --{B} Press the left alt key, take a rest, press
  38.         PressMouseButton(3)                    --{-} middle mouse button ----------------------
  39.     elseif event == "MOUSE_BUTTON_RELEASED" and arg == 11 then --{C} ELSEIF.. target button is released.. THEN!
  40.         ReleaseKey ("lalt")                --{-}-------------------------------------------
  41.         ReleaseMouseButton(3)                  --{D} Release left alt & middle mouse button (3)
  42.     end                                --{-}-------------------------------------------
  43.                                        --NOTE: I was explicit with my use of LEFT ALT,
  44.                                                                    --however, it can be just any ALT with: ("alt")
  45.  
  46. -- /// Alternate Way to complete above
  47.  
  48.                  --{} EXAMPLE # 2A {} __________________________}--
  49.                  --{ ___________________________________________}--
  50.                  --{ to perform a sequence of keystrokes without}--
  51.                  --{ up/down control, you can use a macro ______}--
  52.  
  53.  
  54. --{ Step 1: Record your macro in LGS using the mutli key function.
  55. --{ Step 2: Name your macro!
  56. --{ Note: At this point you could just assign it to the recorded key. Done, however, those who want to learn can read on.
  57.  
  58.     if event == "MOUSE_BUTTON_PRESSED" and arg == 11 then       --{A} If our targed mouse button is pressed..
  59.         PlayMacro("MyExampleMacro")             --{B} Plays MyExampleMacro which you recorded earlier
  60.     elseif event == "MOUSE_BUTTON_RELEASED" and arg == 11 then  --{C} If it's a non-repeating macro you can replace this with END
  61.         AbortMacro()                        --{D} If your macro repeats you need to abort it upon release
  62.     end                             --NOTE: It should follow it's repeat / toggle per the recording
  63. end
Advertisement
Add Comment
Please, Sign In to add comment