keyArray = { { -- Profile 1 }, { -- Profile 2 }, { -- Profile 3 [21] = {"ctrl+alt+shift+1", "ctrl+alt+shift+2", "ctrl+alt+shift+3", "ctrl+alt+shift+4", "ctrl+alt+shift+5"}, -- heal self [13] = {"alt+shift+1", "alt+shift+2", "alt+shift+3", "alt+shift+4", "alt+shift+5", "alt+shift+6", "alt+shift+7", "alt+shift+8", "alt+shift+9", "alt+shift+0"}, -- buff other [14] = {"alt+O", "alt+K", "alt+B", "alt+J"}, -- big AoEs [16] = {"ctrl+5", "ctrl+6", "ctrl+7", "ctrl+8"}, -- debuffs [17] = {"alt+F1", "alt+F2", "alt+F3", "alt+F6", "alt+F7", "alt+F8", "alt+F9", "alt+F10", "alt+F11", "alt+F12"}, -- buff other [18] = {"alt+1", "alt+2", "alt+3", "alt+4", "alt+5", "alt+6", "alt+7", "alt+8", "alt+9", "alt+0"}, -- buff self [19] = {"ctrl+alt+shift+6", "ctrl+alt+shift+7", "ctrl+alt+shift+8", "ctrl+alt+shift+9", "ctrl+alt+shift+0"}, -- heal other [5] = {"alt+shift+F1", "alt+shift+F2", "alt+shift+F3", "alt+shift+F4", "alt+shift+F5", "alt+shift+F6", "alt+shift+F7", "alt+shift+F8", "alt+shift+F9", "alt+shift+F10"}, -- debuffs spells } }; -- list of macros to launch. Format : key = {"macro name", "profile to activate"} macros = { [26] = {"2Hander", 2}, [27] = {"Bow", 2}, [28] = {"staff", 3}, [29] = {"1Hander", 1}}; 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}}; -- when the profile is changed the pad lose all pressed key, so we have to manage this movements = {[4] = "W", [10] = "A", [11] = "S", [12] = "D"}; lastGkey = 0; profile = 1; lastMacro = 0; function OnEvent(event, arg) if (event=="G_PRESSED" and arg ~=1) then -- gets profile number profile = GetMKeyState(); pushKey(arg); end if (event=="G_RELEASED" and movements[arg]) then releaseKey(arg); end -- loot key, usefull for moving stuff quick (like 2000 pants) if(event=="G_PRESSED" and arg==1) then x, y = GetMousePosition(); PressMouseButton(1); Sleep(10); MoveMouseTo(55000, 45000); Sleep(10); ReleaseMouseButton(1); Sleep(10); MoveMouseTo(x, y); end end function releaseKey(gkey) ReleaseKey(movements[gkey]); end function pushKey(gkey) -- launch macro if needed if(macros[gkey]) then macroKey(gkey); return; end -- manage movement if needed if(movements[gkey]) then PressKey(movements[gkey]); return; end -- 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 -- I have macros set for these keys and some need to change the active profile function macroKey(key) if(lastMacro ~= key) then -- Abort old macro AbortMacro(); end isSprint = IsModifierPressed("lshift"); oldState = GetMKeyState(); -- Activate macro PlayMacro(macros[key][1]); -- Change profile SetMKeyState(macros[key][2]); if(isSprint and (macros[key][2] ~= oldState)) then ReleaseKey("lshift"); Sleep(20); PressKey("lshift"); end end