Debug Ligitech script help - 03/04/10 12:49 AM
keyArray = {
{ -- Profile 1
[6] = {"ctrl+O", "crtl+P"}
},
{ -- Profile 2
},
{ -- Profile 3
}
};
indexes = {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
lastGkey = 0;
lastMacro = 0;
function OnEvent(event, arg)
if (event=="G_PRESSED" and arg ~=1) then
pushKey(arg);
end
end
function pushKey(gkey)
-- gets key name
-- we check if the last gkey used was the same, if yes, cycle
if(lastGkey > 0 and lastGkey == gkey) then
indexes[profile][gkey] = indexes[profile][gkey] + 1;
if(indexes[profile][gkey] > table.getn(keyArray[profile][gkey])) then
indexes[profile][gkey] = 1;
end
end
lastGkey = gkey;
i = indexes[profile][gkey];
keyString = keyArray[profile][gkey][i];
-- we get modifiers to use
toCtrl = 0;
toAlt = 0;
toShift = 0;
if(string.find(keyString, "ctrl")) then
toCtrl = 1;
end
if(string.find(keyString, "alt")) then
toAlt = 1;
end
if(string.find(keyString, "shift")) then
toShift = 1;
end
-- now, we clean the key string to extract only the key
keyString = string.gsub(keyString, "ctrl", "");
keyString = string.gsub(keyString, "alt", "");
keyString = string.gsub(keyString, "shift", "");
keyString = string.gsub(keyString, "\+", "");
key = string.gsub(keyString, " ", "");
-- check if shift is already pushed
isSprint = IsModifierPressed("shift");
-- if needed release or press shift key
if((toCtrl == 1 or toAlt == 1) and isSprint and toShift == 0) then
ReleaseKey("lshift");
elseif(not isSprint and toShift == 1) then
PressKey("lshift");
end
-- press modifiers
if toCtrl == 1 then
PressKey("lctrl");
end
if toAlt == 1 then
PressKey("lalt");
end
-- press and release key
PressAndReleaseKey(key);
-- release modifiers
if toCtrl == 1 then
ReleaseKey("lctrl");
end
if toAlt == 1 then
ReleaseKey("lalt");
end
-- release or press shift if it was pressed before
if((toCtrl == 1 or toAlt == 1) and isSprint and toShift == 0) then
PressKey("lshift");
elseif(not isSprint and toShift == 1) then
ReleaseKey("lshift");
end
end
{ -- Profile 1
[6] = {"ctrl+O", "crtl+P"}
},
{ -- Profile 2
},
{ -- Profile 3
}
};
indexes = {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
lastGkey = 0;
lastMacro = 0;
function OnEvent(event, arg)
if (event=="G_PRESSED" and arg ~=1) then
pushKey(arg);
end
end
function pushKey(gkey)
-- gets key name
-- we check if the last gkey used was the same, if yes, cycle
if(lastGkey > 0 and lastGkey == gkey) then
indexes[profile][gkey] = indexes[profile][gkey] + 1;
if(indexes[profile][gkey] > table.getn(keyArray[profile][gkey])) then
indexes[profile][gkey] = 1;
end
end
lastGkey = gkey;
i = indexes[profile][gkey];
keyString = keyArray[profile][gkey][i];
-- we get modifiers to use
toCtrl = 0;
toAlt = 0;
toShift = 0;
if(string.find(keyString, "ctrl")) then
toCtrl = 1;
end
if(string.find(keyString, "alt")) then
toAlt = 1;
end
if(string.find(keyString, "shift")) then
toShift = 1;
end
-- now, we clean the key string to extract only the key
keyString = string.gsub(keyString, "ctrl", "");
keyString = string.gsub(keyString, "alt", "");
keyString = string.gsub(keyString, "shift", "");
keyString = string.gsub(keyString, "\+", "");
key = string.gsub(keyString, " ", "");
-- check if shift is already pushed
isSprint = IsModifierPressed("shift");
-- if needed release or press shift key
if((toCtrl == 1 or toAlt == 1) and isSprint and toShift == 0) then
ReleaseKey("lshift");
elseif(not isSprint and toShift == 1) then
PressKey("lshift");
end
-- press modifiers
if toCtrl == 1 then
PressKey("lctrl");
end
if toAlt == 1 then
PressKey("lalt");
end
-- press and release key
PressAndReleaseKey(key);
-- release modifiers
if toCtrl == 1 then
ReleaseKey("lctrl");
end
if toAlt == 1 then
ReleaseKey("lalt");
end
-- release or press shift if it was pressed before
if((toCtrl == 1 or toAlt == 1) and isSprint and toShift == 0) then
PressKey("lshift");
elseif(not isSprint and toShift == 1) then
ReleaseKey("lshift");
end
end