Reply
Logi Browser
MariosX
Posts: 9
Registered: ‎05-01-2009
0

[Share] Logitech G13 Media Controls and more

[ Edited ]

Hello!

In this thread I'll share the script I have created so far.

This post will be updated regurarly and more keys will be added (like Refresh, Next/Previous Page, Launching Internet Browser, My Computer, etc.)

 

This script has been tested on Logitech G-Series Key Profiler 3.03.133 (08/13/2009 / 17:05:09) on Windows 7 Ultimate x64 and I'm unsure if this script works on 3.06 or 7.00 or other versions of Windows

Links for 3.03:

32 bit 64 bit

 

Credits go to:

 

ordibia for providing "Previous/Next Track, Play/Pause, Mute" keys and  getting the idea of how I will be able to customize more keys

kgober for providing this link

their posts can be found on this thread

 

How to add the script:

1) Right click Logitech G-series Key Profiler and select Open

2) On the menu go to: Edit > Script Editor

3) Paste the text from the spoiler on the empty text area and then go to Script > Save

 

 

Spoiler
function OnEvent(event, arg, lhc)
    if (event == "G_PRESSED" and arg == 3) then
        PressAndReleaseKey(0x110)
        ClearLCD ()
        OutputLCDMessage("Previous Track")
    end

    if (event == "G_PRESSED" and arg == 5) then
        PressAndReleaseKey(0x119)
        ClearLCD ()
        OutputLCDMessage("Next Track")
    end

    if (event == "G_PRESSED" and arg == 4) then
        PressAndReleaseKey(0x122)
        ClearLCD ()
        OutputLCDMessage("Play/Pause")
    end

    if (event == "G_PRESSED" and arg == 7) then
        PressAndReleaseKey(0x120)
        ClearLCD ()
        OutputLCDMessage("Mute")
    end

    if (event == "G_PRESSED" and arg == 2) then
        PressAndReleaseKey(0x12E)
        ClearLCD ()
        OutputLCDMessage("Volume -")
    end

    if (event == "G_PRESSED" and arg == 6) then
        PressAndReleaseKey(0x130)
        ClearLCD ()
        OutputLCDMessage("Volume +")
    end

    if (event == "G_PRESSED" and arg == 1) then
        PressAndReleaseKey(0x16D)
        ClearLCD ()
        OutputLCDMessage("Media Player")
    end

    if (event == "G_PRESSED" and arg == 20) then
        PressAndReleaseKey(0x16B)
        ClearLCD ()
        OutputLCDMessage("My Computer")
    end

    if (event == "G_PRESSED" and arg == 22) then
        PressAndReleaseKey(0x16C)
        ClearLCD ()
        OutputLCDMessage("E-Mail")
    end

    if (event == "G_PRESSED" and arg == 21) then
        PressAndReleaseKey(0x121)
        ClearLCD ()
        OutputLCDMessage("Calculator")
    end

    if (event == "G_PRESSED" and arg == 8) then
        PressAndReleaseKey(0x132)
        ClearLCD ()
        OutputLCDMessage("Web Browser")
    end

    if (event == "G_PRESSED" and arg == 9) then
        PressAndReleaseKey(0x165)
        ClearLCD ()
        OutputLCDMessage("Search")
    end

    if (event == "G_PRESSED" and arg == 10) then
        PressAndReleaseKey(0x16A)
        ClearLCD ()
        OutputLCDMessage("Previous Page")
    end

    if (event == "G_PRESSED" and arg == 11) then
        PressAndReleaseKey(0x167)
        ClearLCD ()
        OutputLCDMessage("Refresh")
    end

    if (event == "G_PRESSED" and arg == 12) then
        PressAndReleaseKey(0x169)
        ClearLCD ()
        OutputLCDMessage("Next Page")
    end

    if (event == "G_PRESSED" and arg == 13) then
        PressAndReleaseKey(0x166)
        ClearLCD ()
        OutputLCDMessage("Favorites")
    end

    if (event == "G_PRESSED" and arg == 14) then
        PressAndReleaseKey(0x168)
        ClearLCD ()
        OutputLCDMessage("Stop")
    end
end

That's all!

 

Script Button Guide v1.02:

G1 Launches Media Player

G2 Volume -

G3 Previous Track

G4 Play/Pause

G5 Next Track

G6 Volume +

G7 Mute

G8 Launches Web Browser

G9 Search (Browser & Windows)

G10 Previous Page (Browser & Windows)

G11 Refresh (Browser & Windows)

G12 Next Page (Browser & Windows)

G13 Bookmarks/Favorites (Browser & Windows)

G14 Stop (Browser & Windows)

G20 My Computer

G21 Calculator

G22 E-Mail Client

 

The only con of using this script is:  all macros are assigned to this script meaning that you cannot use your custom macros on your Default Profile

 

Can someone help me out:

1) finding more Virtul Key Codes? Like the link from Microsoft?

2) how I will be able to assign macrosand change to M1,2,3  via the script?

3) how to configure the joystick working as a mouse via the script?

 

PS) I wonder why Logitech has not officially supported Media Control Keys yet...

PS 2) I have them layed out like this because I like everything being centered

PS 3) This is going to be  the ultimate Script

To be updated soon....

Logi Nu
codinghorror
Posts: 1
Registered: ‎05-09-2011

Re: [Share] Logitech G13 Media Controls and more

This is awesome, but it only works with Logitech software 3.03 -- apparently newer Logitech G13 drivers don't support

 

- Lua scripting

- sending arbitrary key scan codes so media keys will work

 

I downgraded to 3.03 so I could use this, and refactored the script a bit:

 

 

Spoiler
function OnEvent(event, arg, family)

    action = ""
    key = 0

    if (event == "G_PRESSED") then

        if (arg == 3 or arg == 29) then
            key = 0x110        
            action = "Previous Track"        
        end

        if (arg == 5 or arg == 27) then
            key = 0x119
            action = "Next Track"
        end

        if (arg == 4 or arg == 24) then
            key = 0x122
            action = "Play/Pause"
        end

        if (arg == 7) then
            key = 0x120
            action = "Mute"
        end

        if (arg == 2 or arg == 28) then
            key = 0x12E
            action = "Volume [-]"
        end

        if (arg == 6 or arg == 26) then
            key = 0x130
            action = "Volume [+]"
        end

        if (arg == 1) then
            key = 0x16D
            action = "Media Player"
        end

        if (arg == 20) then
            key = 0x16B
            action = "My Computer"
        end

        if (arg == 22) then
            key = 0x16C
            action = "E-Mail"
        end

        if (arg == 21) then
            key = 0x121
            action = "Calculator"
        end

        if (arg == 8) then
            key = 0x132
            action = "Web Browser"
        end

        if (arg == 9) then
            key = 0x165
            action = "Search"
        end

        if (arg == 10) then
            key = 0x16A
            action = "Previous Page"
        end

        if (arg == 11) then
            key = 0x167
            action = "Refresh"
        end

        if (arg == 12) then
            key = 0x169
            action = "Next Page"
        end

        if (arg == 13) then
            key = 0x166
            action = "Favorites"
        end

        if (arg == 14) then
            key = 0x168
            action = "Stop"
        end
    end

    PressAndReleaseKey(key)
    --ClearLCD ()
    OutputLCDMessage(action)
    OutputLogMessage("\nevent = %s, arg = %s\n", event, arg);

end

 

 

In general the pattern is

 

function OnEvent(event, arg, family)

    action = ""
    key = 0

    if (event == "G_PRESSED") then
        if (arg == 7) then
            key = 0x120
            action = "Mute"
        end
    end

    PressAndReleaseKey(key)
    --ClearLCD ()
    OutputLCDMessage(action)
    OutputLogMessage("\nevent = %s, arg = %s\n", event, arg);

end

 You can create as many if blocks as you need to map other keys. 

 

I REALLY REALLY REALLY wish Logitech would get wise and re-include Lua scripting support AND arbitrary keyboard scan code support in their newer G13 driver.

 

It's crazy that they dropped this, it is the difference between something that is awesome that I will recommend to a bunch of people, and something I am "meh" about.

 

Jeff Atwood

CTO and co-founder http://stackexchange.com

blogger with 120k readers at http://www.codinghorror.com/blog

 

Logi Journeyman
h0rse
Posts: 430
Registered: ‎08-13-2010
0

Re: [Share] Logitech G13 Media Controls and more

[ Edited ]

@OP:

2) .. you can assing macros to M2 and M3 and just use your scripts on M1 (or only 2 modes, to leave people options to add macros) like this:

in your case you need just to take one of the e.g. "if GetMKeyState() == 1" sections to put your scripts in, and assign the keys to script in M1 ...

 

function OnEvent(event,arg)
    if GetMKeyState() == 1 then -- M1
       if event == "G_PRESSED" then
           if arg == 1 then
               -- M1-G1-pressed
           elseif arg = 2 then
               -- M1-G2-pressed
               -- ...
           end
       elseif event == "G_RELEASED" then
           if arg == 1 then
               -- M1-G1-released
           elseif arg = 2 then
               -- M1-G2-released
               -- ...
           end  
       end
    elseif GetMKeyState() == 2 then -- M2   
       if event == "G_PRESSED" then
           if arg == 1 then
               -- M2-G1-pressed
           elseif arg = 2 then
               -- M2-G2-pressed
               -- ...
           end
       elseif event == "G_RELEASED" then
           if arg == 1 then
               -- M2-G1-released
           elseif arg = 2 then
               -- M2-G2-released
               -- ...
           end  
       end    
    elseif GetMKeyState() == 3 then -- M3   
       if event == "G_PRESSED" then
           if arg == 1 then
               -- M3-G1-pressed
           elseif arg = 2 then
               -- M3-G2-pressed
               -- ...
           end
       elseif event == "G_RELEASED" then
           if arg == 1 then
               -- M3-G1-released
           elseif arg = 2 then
               -- M3-G2-released
               -- ...
           end  
       end 
    end
end

 you can also create those link macros and trigger them with PlayMacro("calculator.exe"), without assigning them to keys by macro.

 

3) configuring the mouse is via key-profiler, so you must make a macro clicking the settings in it. (there are workarounds to do this by script, but they would include a restart of key-profiler). Then you can use GetMouseSpeed() and SetMouseSpeed() by script to adjust...

 

yup scan-codes are all over the net and nowhere. some work for this app and others for that ... [sharing] helps!

 

...

-------------- UPIA --------------->