- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-19-2012 04:43 PM
Hi everyone,
I have following scenario.
G20 assigned to NUMPAD 2.
G13 assigned to E.
Now I would like to be able to hit G20 + G13 to get Ctrl+E.
Is this possible as G20 ist not bound to Ctrl?
Thanks in advance!
MemphiZ
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-19-2012 05:21 PM
It would be tough to impliment, as how is it supposed to know that you are going to hit the G13 key before G20 applies the Num pad 2. You'd have to make it so that Numpad 2 happens when you release the key, unless G13 was pressed before you release it, then it'll do a ctrl+E. to do that, you'd need to write a Lua script, as it you can't get that control with macros.
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-19-2012 05:33 PM
Does anyone have a script like this? Because I don't have any experience in lua scripting.
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-19-2012 06:41 PM
This may not be the most elagent solution, but it works:
log = OutputLogMessage
function OnEvent(event, arg)
if event == "G_PRESSED" and arg == 20 then
G20pressed = true
elseif event == "G_RELEASED" and arg == 20 then
if G13pressed then
G13pressed = nil
else
PressAndReleaseKey("num2")
log("num2\n")
end
G20pressed = nil
elseif event == "G_PRESSED" and arg == 13 and G20pressed then
PressKey("lctrl")
Sleep(5) -- small delay to make sure it's pressed before E
PressAndReleaseKey("e")
Sleep(5)
ReleaseKey("lctrl")
log("ctrl-e\n")
G13pressed = true
end
end
Just place that in the script editor and make sure you remove the default script first.
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 01:20 AM
Yes it's possible. I'm writing with only six keys with this system (video 30 sec).
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 05:48 AM
--G20 assigned to NUMPAD 2 and G13 assigned to E.
--Now I would like to be able to hit G20 + G13 to get Ctrl+E. Is this possible as G20 ist not bound to Ctrl?
-- here, one solution by Josick 03/20/2012
max=0
x=0
key1=13 --one of the 2 keys for use together
key2=20 --one of the 2 keys for use together
function OnEvent(event, arg)
if event == "G_PRESSED" and arg == key1 then
x=x+1
max = max+1
elseif event == "G_PRESSED" and arg == key2 then
x=x+2
max = max+2
elseif event == "G_RELEASED" and arg == key1 then
x=x-1
elseif event == "G_RELEASED" and arg == key2 then
x=x-2
end
if x==0 and max>0 then
if not (max>#ref_table) then ref_table[max]() end
max=0
end
end
ref_table = {
[1] = function() --key1 --> E
PressKey("lshift","e") ReleaseKey("lshift","e")
OutputLogMessage("E\n")
end,
[2] = function() --key2 --> num2
PressAndReleaseKey("num2")
OutputLogMessage("\tnum2\n")
end,
[3] = function() -- key1+key2 --> ctrl e
PressKey("lctrl","e") ReleaseKey("lctrl","e")
OutputLogMessage("\t\tctrl-e\n")
end,
}Is it good ?
Re: G13: Assign multiple G-Keys
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 11:01 AM - edited 03-20-2012 11:27 AM
Thanks for all the fast replies!
I created the following little script out of both solutions. For the style I prefer "bystander"'s code because I think its easier to understand.
Log = OutputLogMessage
function OnEvent(event, arg)
if event == "G_PRESSED" and arg == 20 then
G20Pressed = true
elseif event == "G_RELEASED" and arg == 20 then
if GPressed then
GPressed = nil
else
PressAndReleaseKey("num1")
PressAndReleaseKey("num2")
PressAndReleaseKey("num5")
Log("Pressed: Jump combination\n")
end
G20Pressed = nil
elseif event == "G_PRESSED" and arg == 4 and G20Pressed then --G20+4 = Ctrl+W
ReleaseKey("w") PressCtrlKey("w")
GPressed = true
elseif event == "G_PRESSED" and arg == 3 and G20Pressed then --G20+3 = Ctrl+1
PressCtrlKey("1")
GPressed = true
elseif event == "G_PRESSED" and arg == 9 and G20Pressed then --G20+9 = Ctrl+Q
PressCtrlKey("q")
GPressed = true
elseif event == "G_PRESSED" and arg == 5 and G20Pressed then --G20+5 = Ctrl+5
PressCtrlKey("5")
GPressed = true
end
end
function PressCtrlKey(key)
PressKey("lctrl", key) ReleaseKey("lctrl", key)
Log("Pressed: Ctrl+" .. string.upper(key) .. "\n")
endI have only one problem. If I hit for example G20+G3 which presses Ctrl+1 the action mapped to G3 in the Gaming Software is being executed as well (I think first). Is there any way to prevent this or do I have to put that logic also into the script? Which would mean for all keys that are used in any combinations I can't use the Gaming Software anymore ![]()
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 12:11 PM
yes, if you assign an action to a key in the Gaming Software, and you also assign an action via a Lua script, then when you press that key both actions will happen.
to avoid this, use Lua only. in all of my profiles, every key is assigned to Lua and I have no assignments done in the Gaming Software at all.
-ken
I do not work for Logitech. I'm just a user.
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 01:53 PM
That would completely kill the idea of having a great GUI like the Gaming Software has. Is there no way to prevent the Key Assignments in the Gaming Software from executeing for a few moments from within the script? Because I find it hard to believe that to rewrite every key with its basic functionallity can be done fast and uncomplicated (for every profile as well). Also when you want to reassign your buttons you can't just drag n drop the commands instead you have to look them up in code and fix any issues that come with that change. I just wanted to add some extra features (using ctrl+? when hitting 2 g-keys at a time) not rewrite the whole software
Re: G13: Assign multiple G-Keys
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
03-20-2012 03:26 PM
I do a lot of scripting myself, but I don't do it all through scripts except in rare cases. Most the time my profiles will be all normal macros with maybe a couple special ones, like the one above, and the rest are just hotkeys. I like to visually see the layout.
