Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Logitech G-keyboards LUA Scripting

News Programmable Keyboards Recommended Links Lua G-keyboards LUA Scripting  Troubleshooting Logitech G-keyboards macros
Logitech G110

 Logitech G510s Gaming Keyboard

 Microsoft Sidewinder X4 and X6 Keyboards

Sysadmin Horror Stories Humor Etc

Introduction

The Logitech Gaming Software (LGS) contains a built-in script editor that enables advanced users to create scripts using the Lua programming language.

Lua is an open source programming language specifically designed for extending applications. For information on Lua, visit www.lua.org. Scripts created using Lua can be shared by the gaming community, so G-keyboard  users can not only create scripts for themselves, but import and modify somebody else script. they can also export and publish their own scripts. 

An introduction to  Lua programming can be found in the book:

Programming in Lua
by Roberto Ierusalimschy
Lua.org, third edition, January 2013
ISBN 859037985X (also available as e-book)

This book is now in the third edition covering Lua 5.2. The first edition which cover Lua 5.0 is available online; it is still largely relevant. 

When you have selected a profile in The Gaming Software window, you can create, import, and edit a script for that profile.

Each profile can have one script attached to it. You can access the script editor in order to maintain scripts from the main Gaming Software window. To do so:

  1. Within the Logitech Gaming Software, if you have more than one gaming device, choose the relevant one using the Device Selector on the Device bar.
  2. Display the Profiles View (by clicking the Customize G-keys/buttons icon on the Device bar).
  3. Right-click the correct profile in the Profiles area or click its arrow, and select Scripting.

The built-in Script editor window is displayed. You can use its menus and features to perform a range of tasks, including the creation and saving of new scripts, and the importing and exporting of scripts.

All profile scripts are activated when the profile is activated and deactivated when the profile is deactivated.

Lua documentation is accessible from the Help menu of the Script window.

Using LUA you can press keys on the keyboard from your script much like in-built multi key menu of LGS but you have slightly more control as you have access to all LUA control structures, string functions and can save temporary variables (they are not persistent).

LUA API reference for LGS scripting

Open up the script editor and look at the help section for the Scripting API. It has a list in the Appendix. I have also found that coroutines are included, and possibly a few other libraries it failed to mention in their list.

kgober

there isn't an *online* reference that I know of. you have to install LGS, which will put a copy of the Scripting API pdf document on your computer. once you have a copy of that pdf, I suppose you could put a copy of it on a personal website of your own if you want to be able to access it online (without installing LGS everywhere you go).

Since I almost always have my laptop with me, I have a copy of LGS installed on it (although I rarely actually use a Logitech G-series device on my laptop).

Limitations

The functions available to you in Lua fall into two categories:

  1. G-keyboard LUA API: functions added to the Lua engine by Logitech. These are documented in the Scripting API that can be accessed via the script editor Help menu.
  2. A subset of LUA built-in functions. Only a subset of functions that came with the Lua engine (i.e. built-in functions defined by the LUA language specs) can be used. These can be accessed via the script editor Help menu.

The following LUA built-in functions described in the Lua Online Reference are not available in Logitech's implementation:

and possibly debug.*. In Logitech forum was reported that debug.traceback() will crash the software, but other debug functions may work.

So LUA functionality is severely castrated. Especially bad is absence of file.* and io.* packages. You can work only with the clipboard. No functions built into Logitech implementation of Lua that give you direct access to Windows DLLs and Logitech doesn't provide any wrapper functions. Here is a pretty interesting take on the situation Re Gaming Software and Lua 

05-23-2011 |  Logitech Forums

Dear Logitech Developers

I have a couple of requests to make, regarding the logitech gaming software.

Note that these are feature requests, but at least the first should not take long to implement for any competent developer with access to the original source code.

First off, the most important of the features: Ungimp Lua.

I do realize that you would worry allowing the full feature-set of Lua, as malicious code spreading through logitech-profiles being shared sounds bad. This, however, is easily avoided by providing a setting that the user has to manually enable to bring Lua out of the current sandbox-mode. Anyone who can use the added flexibility of non-gimped Lua-code would probably also have the sense to actually read any code they would consider adding to their profile before allowing it to run. If not, they probably deserved whatever happened.

Why gimped lua is bad:

Right now, people turn to awkward solutions with third party programs like AutoIT, binding program files to macro keys, instead of getting a clean lua-only way to do these things, provided by you. 

Example

-- This is the primary event handler
-- You must implement this function

function OnEvent(event, arg)
    OutputLogMessage("event = %s, arg = %s\n", event, arg)
    if (event == "PROFILE_ACTIVATED") then
       -- profile has been activated
    end
    if (event == "PROFILE_DEACTIVATED") then
       -- profile has been deactivated
    end
    if (event == "G_PRESSED" and arg == 4) then
    -- G1 has been pressed
       current_mkey = GetMKeyState()
       if (current_mkey == 1) then 
          -- Display the current date/time in Jan 1, 2016 format
          month=GetDate("%b")
          day=GetDate("%d")
          year=GetDate("%Y")
          timestamp=string.format("%s %02d, %04d",month,day,year)
          OutputLogMessage("Today’s date/time is: %s\n", timestamp)
         for i=1,12,1 do
            s = string.sub(timestamp,i,i)
            if ( s == " " ) then 
                s="spacebar"
            elseif (s == "," ) then
                s="comma"
            end 
            OutputLogMessage("%02d   %s\n",i,s)
            if (i == 1 ) then 
                PressKey("rshift")
            end
            PressKey(s)
            ReleaseKey(s)
            if (i == 1 ) then
               ReleaseKey("rshift")
            end
                 
         end
        
       end
   end 
end

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Dec 15, 2014] logitech - game Lua scripting - using couroutine or polling

Jul 4, 2014 | Stack Overflow
I am starting to learn how to use Lua scripting for different game profile with logitech software.

First I tried to use onevent (I know it isn't very advanced) and created this attack combo script

function OnEvent(event, arg) 
    if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then --set flag for mb1
        mb1_pressed = true
    elseif event == "MOUSE_BUTTON_RELEASED" and arg == 1 then --set flag for mb1=false
        mb1_pressed = false
    end
end

if mb1_pressed then --using flags to determine whether to start attack or not
    repeat
        presskey("A")
        Sleep(50)
        releasekey("A")
        Sleep(100)
        --if MB1 is release, it will also break script. if i only tap mb1, this will only execute the first line of attack without the rest below
        if not (**argument**, can be MB1/ismouse1) then break end
        presskey("S")
        Sleep(50)
        releasekey("")
        Sleep(120)
        presskey("A")
        Sleep(50)
        releasekey("A")
        Sleep(200)
        if not (**argument**, can be MB1/ismouse1) then break end --if MB1 is release, it will also break script. this point will prevent script from looping from start if mb1 release
    until not (**argument**, i use ismouse1) --end the loop of script
end

So I am trying to bind this to G6 button of my logiech mouse (using mouse_button_press == 6) Setting a flag with MB6 works, but ending a loop/breaking a loop cannot be triggered by MB6

After some research on SDK/Lua forum of logitech support, it seems that there is a problem with my script

  1. Flags cannot be used/detect as an argument while a script is performing a loop sequence
  2. IsMouseButtonPressed (reads windows keypress) can be used in place or arguments
  3. Windows only detects MB1-5, so binding to G6 is not possible (registers as 6th button)

I read that using couroutine.yield() or polling can be used for stopping repeat scripts in loop. But I cannot find a tutorial for beginners online.

Sorry for the noobish question!

I'm sorry for the mistake. I don't know what to tag it with, so I included logitech since I'm using the script with their software/mouse (LGS 8.53.154). I'm not too sure about the SDK, it says "logitech 8.5" when I open the scripting API/command list. – Yellow_13 Jul 4 at 18:00
Please don't confuse between Lua and LUA. Both languages are different. "Lua" is a name, and means "Moon" in Portugese. Please do not write it as "LUA", which is both ugly and confusing, because then it becomes an acronym with different meanings for different people. – hjpotter92 Jul 4 at 19:02
Is the software used by logitech use Lua or LUA? – Yellow_13 Jul 5 at 6:58
You are using "Lua". – Schollii Jul 6 at 1:23
1
Not sure what you are asking. Please clarify what is the problem, the symptom, and what you have tried. Is there a link to online docs for the logitec Lua API? I found manualez.com/logitech/logitech-g-series-lua-api.html, is that what you are using? – Schollii Jul 6 at 1:32

activeoldestvotes

I don't know anything about Logitech mice so I will try to explain things using a simplified, pure Lua example. Lets model the autoattack script as a loop that prints "A" and "B" alternatively. The "A" corresponds to the first part of your loop (press and release A) and the "B" represents the second part (press and release S and A).
function autoattack()
    while true do
        print("A")
        print("B")
    end
end

autoattack()

So far we are OK but the loop will obviously run forever and we need to add a way to stop it. I think what you are trying to do is something along the lines of:

local autoattacking = false

function autoattack()
    autoattacking = true
    while true do
        print("A")
        if not autoattacking then break end
        print("B")
        if not autoattacking then break end
    end
end

function stop_autoattack()
    autoattacking = false
end

autoattack()    
stop_autoattack()

However, since autoattack is an infinite loop, stop_autoattack never runs and the autoattacking flag never gets updated. How can we fix this?

Polling

Instead of calling a function and setting a flag to stop the loop, what if we could call some code to see if the loop should be stopped or not?

function continue_autoattack()
    print("continue autoattacking? y/n")
    return (io.read("*l") == "y")
end 

function autoattack()
    while true do
        print("A")
        if not continue_autoattack() then break end
        print("B")
        if not continue_autoattack() then break end
    end
end

autoattack()

In your mouse this would probably mean using some sort of isKeyPressed function, if its available in the API. Its also important to note that the autoattack loop is still an infinite loop - its just that we changed it so its in control of its stopping condition.

Coroutines

If we want to keep the code to stop the loop outside the loop we will need a way to run the autoattack loop one step at a time. Here is an example:

local state = 1
function autoattack_step()
    if state == 1 then
        print("A")
        state = 2
    elseif state == 2
        print("B")
        state = 1
    elseif state == 3
        print("STOPPED")
        --state remains as 3
    else
        error("bad state") -- defensive programming; I hate if/elseif without an else
    end
end

function stop_autoattack()
    state = 3
end

autoattack_step()
autoattack_step()
autoattack_step()
stop_autoattack()
autoattack_step()

Since we broke up the autoattack loop, we now have a chance to call stop_autoattack between calls to autoattack_step. To do this in your mouse script, I think stop_autoattack can go in "release button" handlers but I dont know where I would put the autoattack_step calls. Maybe the API includes something similar to setTimeout or setInterval in Javascript.

As for coroutines, where do they come in? Did you notice how we needed to do some substantial code refactoring to break the loop into single step chinks for autoattack_step? Coroutines are a Lua feature that lets you write code using loops while still being able to run them "one step at a time". When a coroutine reaches a coroutine.yield, it returns back to its caller. The thing is that when you call coroutine.resume again the coroutine will continue executing from where it stopped instead of going back to the start like a normal function would.

 local autoattacking = true

 autoattack = coroutine.create(function()
     while true do
         print("A")
         coroutine.yield()
         if not autoattacking then break end            
         print("B")
         coroutine.yield()
         if not autoattacking then break end
     end
 end)

 function stop_autoattack()
     autoattacking = false
 end

 coroutine.resume(autoattack)
 coroutine.resume(autoattack)
 coroutine.resume(autoattack)
 stop_autoattack()
 coroutine.resume(autoattack)
 coroutine.resume(autoattack)

Very often, coroutines let you keep code more readable, without turning inside out with lots of explicit "state" variables. We still need to have some "higher up" code calling coroutine.resume though, just like we needed to have some higher level code calling autoattack_step.

lua scripting help

02-04-2011 | Logitech Forums

in Lua, values are always passed by value. since the 'internal' value of a string or a table is actually a pointer, the result is that strings and tables are effectively passed by reference. however, because strings are immutable you might as well think of them as being passed by value.

the end result is that only tables can effectively be passed by reference.

it helps to remember that in Lua, a table serves the same purpose as an array, a class and a struct all rolled into one. so passing a table to a function is just like passing a pointer to a struct. the function can then modify struct members as it sees fit, using the struct notation you're used to:

s = {}
s.x = 5
s.y = -3

move_northeast(s)

function move_northeast(s)
  s.x = s.x + 1
  s.y = s.y + 1
end

also, in many cases the need to pass by reference is eliminated by Lua's ability to return multiple values from a single function call. for example:

r,g,b = brighten(r,g,b)

function brighten(r,g,b)
  return r+1, g+1, b+1
end

-ken

testdev.lua - jabb-g13-lua - Lua scripts for the Logitech G13 - Google Project Hosting

Setup creates a table of families, and each family contains handlers for the various keyboard functions

For example, setup for the G13 left-handed controller occurs in the lhc family; G keys begin with G and are followed by the key number, while M keys begin with (suprise!) M followed by the key number. Profile activation/deactivation doesn't have a family value, so those functions go under the "any" family. Also, (at least on the G13) the controller passes 0 as the arg to OnEvent for Profile events - thus, the Profile key is P0

function Setup()
 
    return {
 
        kb = {
 
        },
 
        lhc = {
 
            -- setup for the G1 key
 
            -- This inherits from ButtonHandler and implements
 
            -- the OnPressed and OnReleased functions. This sample
 
            -- will press and release the "a" key for a single tap,
 
            -- while a double tap of G1 will press/release "b"
 
            G1 = (function(this)
 
                    function this.OnPressed(tapCount)
 
                        if tapCount == 1 then PressKey("a")
 
                        elseif tapCount == 2 then PressKey("b")
 
                        else PressKey("c")
 
                        end
 
                    end
 

 
                    function this.OnReleased(tapCount)
 
                        if tapCount == 1 then ReleaseKey("a")
 
                        elseif tapCount == 2 then ReleaseKey("b")
 
                        else ReleaseKey("c")
 
                        end
 
                    end
 

 
                    return this
 
                end)(ButtonHandler(300, 3))
 
        },
 
        any = {
 
            -- Profile activation/deactivation performed here
 
            P0 = (function(this)
 
                    
 
                    function this.Activated()
 
                        poll.Start()
 
                    end
 
                    
 
                    function this.Deactivated()
 
                        poll.Stop()
 
                    end
 

 
                    return this
 
                end)({})
 
        }
 
    }
 
end
ButtonHandler is a closure that returns a table - this is basically a means of emulating a class, where the function itself is the constructor that returns the object created

ButtonHandler can handle multiple key taps - i.e. a different action can be performed if a key is tapped twice in rapid succession. Note that the single tap action is always performed before a double tap action - this can be changed if a polling mechanism is implemented

 
function ButtonHandler(
 
    multiTapSpan,   -- the number of milliseconds multiple key-taps must occur within
 
    maxTapCount     -- the maximum number of mulitple key-taps handled
 
    )
 
    -- private variables
 
    local this = {}         -- the object to return
 
    local isPressed = false -- whether or not the button is pressed
 
    local pressTime = 0     -- when the button was pressed
 
    local tapCount = 0      -- the number of key taps that have occurred
 
    --local releaseCount = 1  -- the number of key releases (matches tapCount)
 
    local isPolling = false
 

 
    -- set default values
 
    if multiTapSpan == nil then multiTapSpan = 0 end
 
    if maxTapCount == nil then maxTapCount = 0 end
 
    
 
    function PollRoutine()
 
        local time = GetRunningTime() - pressTime
 
        if time < multiTapSpan and tapCount < maxTapCount then
 
            return true
 
        end
 

 
        isPolling = false
 
        this.OnPressed(tapCount)
 
        
 
        if isPressed == false then
 
            this.OnReleased(tapCount)
 
            tapCount = 0
 
        end
 
        
 
        return false
 
    end
 

 
    -- called when the button is pressed
 
    function this.Pressed()
 
        isPressed = true
 
        
 
        -- don't poll when only single taps are allowed
 
        if maxTapCount <= 1 then
 
            pressTime = GetRunningTime()
 
            this.OnPressed(1)
 
            return
 
        end
 
        
 
        if tapCount < maxTapCount then
 
            tapCount = tapCount + 1
 
        end
 
        
 
        if isPolling == false then
 
            pressTime = GetRunningTime()
 
            poll.RegisterPollRoutine(PollRoutine)
 
            isPolling = true
 
        end
 
    end
 

 
    -- called when the button is released
 
    function this.Released()
 
        isPressed = false
 
        
 
        -- don't poll when only single taps are allowed
 
        if maxTapCount <= 1 then
 
            this.OnReleased(1)
 
            return
 
        end
 
        
 
        if isPolling == false then
 
            this.OnReleased(tapCount)
 
            tapCount = 0
 
        end
 
    end
 

 
    -- expose isPressed using a public getter function
 
    function this.IsPressed()
 
        return isPressed
 
    end
 

 
    -- subclasses can override (i.e. replace) these functions to implement
 
    -- specific actions
 
    function this.OnPressed(tapCount) end
 
    function this.OnReleased(releaseCount) end
 

 
    -- export public members
 
    return this
 
end
original source borrowed from bystander http://www.logitechusers.com/showthread.php?t=11168&highlight=poll&page=2
 
function Poll(pollFamily, delay, deviceFamily)
 
    if delay == nil then delay = 25 end
 
    if deviceFamily == nil then deviceFamily = pollFamily end
 
    
 
    local this = {}
 
    local pressCount = 0
 
    local pollMKeyState = GetMKeyState(pollFamily)
 
    local deviceMKeyState = GetMKeyState(deviceFamily)
 
    local pollRoutines = {}
 
    local polling = false
 
    
 
    function this.Start()
 
        if polling == true then return end
 
        polling = true
 
        pressCount = 1
 
        this.Run("PROFILE_ACTIVATED", 0, "")
 
    end
 
    
 
    function this.Stop()
 
        polling = false
 
    end
 
    
 
    function this.Run(event, arg, family)
 
        if polling == false or family ~= pollFamily and event ~= "PROFILE_ACTIVATED" then
 
            return
 
        end
 

 
        if event == "M_PRESSED" then
 
            pressCount = pressCount + 1
 
        elseif event == "M_RELEASED" or event == "PROFILE_ACTIVATED" then
 
            if pressCount == 1 then
 
                RunPollRoutines(event, arg, family)
 
                SetMKeyState(GetMKey(arg, family), pollFamily)
 
                Sleep(delay)
 
            end
 
            pressCount = pressCount - 1
 
        end
 
    end
 
    
 
    function GetMKey(arg, family)
 
        if family == pollFamily and pollMKeyState ~= arg then
 
            pollMKeyState = arg
 
        end
 
        return pollMKeyState
 
    end
 
    
 
    function RunPollRoutines(event, arg, family)
 
        idx = 1
 
        routine = pollRoutines[1]
 

 
        while routine ~= nil do
 
            if routine(event, arg, family) == false then
 
                table.remove(pollRoutines, idx)
 
                routine = pollRoutines[idx]
 
            else
 
                idx = idx + 1
 
                routine = pollRoutines[idx]
 
            end
 
        end
 
    end
 
    
 
    function this.RegisterPollRoutine(routine)
 
        if type(routine) == "function" then
 
            table.insert(pollRoutines, routine)
 
        end
 
    end
 

 
    return this
 
end
poll = Poll("lhc", 25)
 
-- setup the handlers
 
handlers = Setup()
NewHandler returns a function that finds the handler object-function (i.e. method) in the handlers table for a given event, arg, and family. The name parameter provides a means of distinguishing between press and release - so, for example, G_PRESSED is divided into an event "G" and a name "Pressed". See the events table for more.
 
function NewHandler(event, name)
 
    return function(arg, family)
 
        local familyTable = family ~= null and handlers[family] or handlers.any
 
        if type(familyTable) == "table" then
 
            local eventTable = arg ~= nil and familyTable[event..arg] or familyTable[event]
 
            if type(eventTable) == "table" then
 
                local fn = eventTable[name]
 
                if type(fn) == "function" then
 
                    fn()
 
                end
 
            end
 
        end
 
    end
 
end
 

 
-- divide controller events into event and name
 
events = {
 
    PROFILE_ACTIVATED = NewHandler("P", "Activated"),
 
    PROFILE_DEACTIVATED = NewHandler("P", "Deactivated"),
 
    G_PRESSED = NewHandler("G", "Pressed"),
 
    G_RELEASED = NewHandler("G", "Released"),
 
    M_PRESSED = NewHandler("M", "Pressed"),
 
    M_RELEASED = NewHandler("M", "Released")
 
}
 

 
-- entry point for logitech G* controllers
 
function OnEvent(event, arg, family)
 
    poll.Run(event, arg, family)
 
    local fn = events[event]
 
    if type(fn) == "function" then fn(arg, family) end
 
end
 
HISTORY

00.03 2011-04-01 Use polling in button multi-tap

00.02 2011-04-01 Added Polling

00.01 2011-03-31 Initial revision

[May 23, 2011] Gaming Software and Lua

Logitech Forums

Keltinray

‎05-23-2011 08:50 PM

Dear Logitech Developers

I have a couple of requests to make, regarding the logitech gaming software.

Note that these are feature requests, but at least the first should not take long to implement for any competent developer with access to the original source code.

First off, the most important of the features: Ungimp Lua.

I do realize that you would worry allowing the full feature-set of Lua, as malicious code spreading through logitech-profiles being shared sounds bad. This, however, is easily avoided by providing a setting that the user has to manually enable to bring Lua out of the current sandbox-mode. Anyone who can use the added flexibility of non-gimped Lua-code would probably also have the sense to actually read any code they would consider adding to their profile before allowing it to run. If not, they probably deserved whatever happened.

Why gimped lua is bad:

Right now, people turn to awkward solutions with third party programs like AutoIT, binding program files to macro keys, instead of getting a clean lua-only way to do these things, provided by you.

Why the current sandbox mode should be default:

How you can implement the feature:

The easiest way: Check the directo Software for lua5.1.dll. If it's present, add the Logitech-specific functions to the global area of that implementation of Lua. If not, run the default implementation that is currently available.

If you don't want random DLLs interfering with the software, add the official Lua source-code into the plugin itself, and use a setting within the program itself to determine which lua-implementation to use. ( I would still want to be able to load lua-libraries through the use of "require" though )

The second feature request is an update to the scripting-engine's LCD-interaction.

The G19 has a great screen, with plenty of colours and space. Allow us to use it properly from our scripts. All that is required is a handful of extra functions:
•Add simple functions to draw simple shapes and images onto the screen
•Allow arbitrary placement of text-fields on the screen
•Let the LCD App trigger Lua-events when it's active, so we can respond to the LCD-buttons being pressed.

Mind you, if you implement the -first- of these two features, I can make this myself as a separate LCD-Applet, and if that is the case, I would probably release it here, along with a Lua-libary to make it easier to use.

So in essence, I guess my primary point here would be, Logitech - Please ungimp my beloved Lua.

We would all benefit from it if you did.

kgober

‎05-24-2011 06:19 AM - edited ‎05-24-2011 06:20 AM

I've asked for something similar in the past, and the answer I got was that the Lua engine is deliberately limited to avoid making it so powerful that it could be used for botting / unattended macroing in games. because if *that* happens, there is a significant risk that game developers will stop adding G-series keyboard support to their games (including LCD support), and a significant risk that they will use anti-cheat software like GameGuard to block the Logitech software more often.

also, don't forget that Logitech's Lua implementation is supposed to be cross-platform. Leaving out the os.* library helps ensure that the same scripts work on both PC and Mac.

Guide How to add auto run function for G510-compliant keyboards

DayZ Mod General Discussion - DayZ Forums

Posted 13 July 2012 - 04:30 PM

Greetings,

With much help from UPIA over @ the.logitechusers forums. I'm pleased to present you with an option to add a "auto run" function to Arma 2 via a script.

1. Open the Logitech Gaming Software suite and select the giant G. Aka the profiler. You can find the software/drivers here: http://www.logitech....g-keyboard-g510 and download the software/driver package for your specific OS. I'm currently using version 8.30.86.

3. Create or use a pre exsisting profile for Dayz (via the + symbol).

4. Click the profile icon, use the drop down menu to select "scripting"

toggleW = 0
function OnEvent(event, arg, family)
family = family or ""
if family == "kb" and event == "G_PRESSED" and arg == 1 then
	 if toggleW == 0 then
		 toggleW = 1
		 PressKey("w")
	 else
		 toggleW = 0
		 ReleaseKey("w")
	 end
end
end
	

Logitech G510 auto run - auto sprint

Pastebin.com
DayZ auto run and auto sprint script for Logitech G510 keyboard.
		
		Version: 1.0
		
		Created by Durux, admin on EU13 Spongebob Squarepants server.
		
		Info:
		The script uses M1-G8 for auto run and M1-G7 for auto sprint.
		
		If needed to change the key setup, change the 8 or 7 in:
		
			if (event == "G_PRESSED" and arg == 8) then
			or
			if (event == "G_PRESSED" and arg == 7) then
		
		If you want to change the time the information is diplayed on the LCD, change:
			iLCDTimer = 5000;
			The time is in Miliseconds, so 5000 is 5 seconds.
]]

bAutoRun = false;
bAutoSprint = false;
sAutoRun = "OFF";
sAutoSprint = "OFF";
iLCDTimer = 5000;

function OnEvent(event, arg)

    current_mkey = GetMKeyState();

		if (current_mkey == 1) then

		if (event == "G_PRESSED" and arg == 8) then

			AutoRun();

		end
		
		if (event == "G_PRESSED" and arg == 7) then

			AutoSprint();

		end

	end

end

function AutoRun()

	local outputLCD;
	
	if (bAutoSprint == true) then
	
		ReleaseKey("w");
		bAutoSprint = false;
		sAutoSprint = "OFF";
	
	end

	if (bAutoRun == false) then
	
		sAutoRun = "ON";
		bAutoRun = true;
		
		outputLCD = string.format("Auto run: %s\nAuto Sprint: %s", sAutoRun, sAutoSprint);
		
		ClearLCD();
		OutputLCDMessage(outputLCD, iLCDTimer);
		PressKey("w");
	
	else
	
		sAutoRun = "OFF";
		bAutoRun = false;
		
		outputLCD = string.format("Auto run: %s\nAuto Sprint: %s", sAutoRun, sAutoSprint);
		
		ClearLCD();
		OutputLCDMessage(outputLCD, iLCDTimer);
		ReleaseKey("w");
	
	end
	
end

function AutoSprint()

	local outputLCD;
	
	if (bAutoRun == true) then
	
		ReleaseKey("w");
		bAutoRun = false;
		sAutoRun = "OFF";
	
	end
	
	if (bAutoSprint == false) then
	
		sAutoSprint = "ON";
		bAutoSprint = true;
		
		outputLCD = string.format("Auto run: %s\nAuto Sprint: %s", sAutoRun, sAutoSprint);
		
		ClearLCD();
		OutputLCDMessage(outputLCD, iLCDTimer);
		
		PressAndReleaseKey("w");
		Sleep(50);
		PressKey("w");
	
	else
	
		sAutoSprint = "OFF";
		bAutoSprint = false;
		
		outputLCD = string.format("Auto run: %s\nAuto Sprint: %s", sAutoRun, sAutoSprint);
		
		ClearLCD();
		OutputLCDMessage(outputLCD, iLCDTimer);
		
		ReleaseKey("w");
	
	end

end

G15 Scripting, using F1 instead of G Keys. [ New ]

06-02-2014 07:00 AM

I've created a script thats working flawlessly, the only issue I have is that I can't figure out how to run the script on anything other than a "G" key.

I've basically just looked at other peoples scripts, and figure out how to make the one I want. I can't find anywhere to make it run off a "F" key, instead of the "G" keys.

I want "f1" to trigger it.

I tried replacing "G_PRESSED" and arg == 5 then
with
"KeyPressed" and arg == "f1" then

but that didn't work. Ideas?

function OnEvent(event, arg)

--OutputLogMessage("event = %s, arg = %s\n", event, arg);

if event == "G_PRESSED" and arg == 5 then

EquipmentSwitch()

end

Me too

bystander Logi Guru Re: G15 Scripting, using F1 insead of G Keys. [ New ]

‎06-02-2014 07:10 AM

You cannot run it on anything but a G key using the Logitech software. At least without polling, in which case you are still very limited. With polling it is possible to get it to work on keylocks and modifiers as well, but not F keys.

Re: G15 Scripting, using F1 instead of G Keys. [ New ]
‎06-03-2014 05:45 AM

if it's a Logitech G-series mouse that's supported by LGS, then you can use a mouse button to trigger your script directly. you will need to have the mouse in Automatic Game Detection mode though.

-ken

________________________________
I do not work for Logitech. I'm just a user. .

Pchild
Re: G15 Scripting, using F1 insead of G Keys. [ New ]

It's a Logitech G400s, so yep it is.

> bystander Logi Guru
Registered: ‎06-04-2010
Re: G15 Scripting, using F1 insead of G Keys. [ New ]
‎06-03-2014 03:58 PM

The same way you do it with G keys on other devices, only the events are "MOUSE_BUTTON_PRESSED" and "MOUSE_BUTTON_RELEASED".

Family is "mouse", though given that the events are different, you don't normally need to check the family.

Re Gaming Software and Lua

05-23-2011 | Logitech Forums

Dear Logitech Developers

I have a couple of requests to make, regarding the logitech gaming software.

Note that these are feature requests, but at least the first should not take long to implement for any competent developer with access to the original source code.

First off, the most important of the features: Ungimp Lua.

I do realize that you would worry allowing the full feature-set of Lua, as malicious code spreading through logitech-profiles being shared sounds bad. This, however, is easily avoided by providing a setting that the user has to manually enable to bring Lua out of the current sandbox-mode. Anyone who can use the added flexibility of non-gimped Lua-code would probably also have the sense to actually read any code they would consider adding to their profile before allowing it to run. If not, they probably deserved whatever happened.

Why gimped lua is bad:

Right now, people turn to awkward solutions with third party programs like AutoIT, binding program files to macro keys, instead of getting a clean lua-only way to do these things, provided by you.

Why the current sandbox mode should be default:

How you can implement the feature:

The second feature request is an update to the scripting-engine's LCD-interaction.

The G19 has a great screen, with plenty of colours and space. Allow us to use it properly from our scripts. All that is required is a handful of extra functions:

Mind you, if you implement the -first- of these two features, I can make this myself as a separate LCD-Applet, and if that is the case, I would probably release it here, along with a Lua-libary to make it easier to use.

So in essence, I guess my primary point here would be, Logitech - Please ungimp my beloved Lua.

We would all benefit from it if you did.

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites

Top articles

Sites

Youtube

Logitech



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: July, 28, 2019