--[===[ Author: YoucefHam Email: youcefham20@gmail.com Discord: YoucefHam#5634 inside "Lua Engine" and "Lua Editor" and "AutoAssemble Editor" Ctrl + Mouse Wheel to Zoom code. Auto complete with selected code "" '' () [] {}. Ctrl+Q to comment selected code in lua block --[==[Code --[=[Code --[[Code]]--]=]----]==]--. Ctrl+Shift+Q to uncomment selected code in lua block. ]===] -- local timer = createTimer(nil, false) timer.Interval = 2000 timer_times = 1 timer.OnTimer = function(timer) timer.Enabled = false timer.destroy() local frmCE local function getCEForms() frmCE = {} for i = 0, getFormCount() - 1 do frmVarName = 'frm' .. (getForm(i).Name ~= '' and getForm(i).Name or getForm(i).ClassName) frmCE[frmVarName] = getForm(i) end end local function mnLuaEngineUseZoom(frmluaEngine) if not frmluaEngine then frmluaEngine = getLuaEngine() end local mnLuaUseZoom = false local mnLuaOutput = frmluaEngine.ComponentByName['mOutput'] local mnLuaScript = frmluaEngine.ComponentByName['mScript'] if not mnLuaOutput or not mnLuaScript then return end local oldmScriptOnKeyPress = mnLuaScript.OnKeyPress mnLuaScript.OnKeyPress = function(sender, key) if key == '' then -- VK_Q & VK_CONTROL local cPtrStart = '%-%-%[=*%[' local cPtrEnd = '%]=*%]%-*%-*' if mnLuaScript.SelText ~= '' then if isKeyPressed(VK_SHIFT) then -- VK_Q & VK_CONTROL & VK_SHIFT if mnLuaScript.SelText:find( '^(.*)' .. cPtrStart .. '.*' .. cPtrEnd .. '(.*)$') then local insideComment = mnLuaScript.SelText:match( '%-%-%[(=*)%[(.*)%]=*%]%-*%-*') mnLuaScript.SelText = mnLuaScript.SelText:gsub('^(.*)%-%-%[' .. insideComment .. '%[(.*)%s*%]' .. insideComment .. '%]%-*%-*(.*)$', '%1%2%3') end else if mnLuaScript.SelText:find( '^(%s*)' .. cPtrStart .. '(.*)' .. cPtrEnd .. '(%s*)$') then mnLuaScript.SelText = mnLuaScript.SelText:gsub('^(%s*)' .. cPtrStart .. '(.*)%s*' .. cPtrEnd .. '(%s*)$', '%1%2%3') elseif mnLuaScript.SelText:find( cPtrStart .. '.*' .. cPtrEnd) then local insideComment = mnLuaScript.SelText:match( '%-%-%[(=*)%[(.*)%](=*)%]%-*%-*') mnLuaScript.SelText = mnLuaScript.SelText:gsub('^(.*)$', '--[' .. insideComment .. '=[%1 ]' .. insideComment .. '=]--') else mnLuaScript.SelText = ('--[[%s ]]--'):format(mnLuaScript.SelText) end end else if isKeyPressed(VK_SHIFT) then return end mnLuaScript.SelText = '--[[]]--' end return end local useSelectBack = false if tostring(key):find("[([{'" .. '"]') then local newText = '(%s)' if tostring(key) == '(' then newText = '(%s)' elseif tostring(key) == '[' then newText = '[%s]' useSelectBack = true elseif tostring(key) == '{' then newText = '{%s}' elseif tostring(key) == '"' then newText = '"%s"' elseif tostring(key) == "'" then newText = "'%s'" end if mnLuaScript.SelText == '' then mnLuaScript.SelText = newText:format(mnLuaScript.SelText) mnLuaScript.SelStart = mnLuaScript.SelStart - 1 else local SelStart = mnLuaScript.SelStart local SelEnd = mnLuaScript.SelEnd local oldSelStart = mnLuaScript.SelStart mnLuaScript.SelText = newText:format(mnLuaScript.SelText) if useSelectBack then mnLuaScript.SelEnd = oldSelStart end end else return oldmScriptOnKeyPress and oldmScriptOnKeyPress(sender, key) or key end end local mnLuaOutputoldOnKeyDown = mnLuaOutput.OnKeyDown mnLuaOutput.OnKeyDown = function(sender, key) if key == VK_CONTROL and not UseZoom then if isKeyPressed(VK_CONTROL) and not mnLuaUseZoom then mnLuaUseZoom = true end end if mnLuaOutputoldOnKeyDown then return mnLuaOutputoldOnKeyDown(sender, key) end return key end local mnLuaScriptoldOnKeyDown = mnLuaScript.OnKeyDown mnLuaScript.OnKeyDown = function(sender, key) if key == VK_CONTROL and not UseZoom then if isKeyPressed(VK_CONTROL) and not mnLuaUseZoom then mnLuaUseZoom = true end end if mnLuaScriptoldOnKeyDown then return mnLuaScriptoldOnKeyDown(sender, key) end return key end local mnLuaOutputoldOnKeyUp = mnLuaOutput.OnKeyUp mnLuaOutput.OnKeyUp = function(sender, key) if isKeyPressed(VK_CONTROL) and mnLuaUseZoom then mnLuaUseZoom = false end if mnLuaOutputoldOnKeyUp then return mnLuaOutputoldOnKeyUp(sender, key) end return key end local mnLuaScriptoldOnKeyUp = mnLuaScript.OnKeyUp mnLuaScript.OnKeyUp = function(sender, key) if isKeyPressed(VK_CONTROL) and mnLuaUseZoom then mnLuaUseZoom = false end if mnLuaScriptoldOnKeyUp then return mnLuaScriptoldOnKeyUp(sender, key) end return key end local mnLuaOutputoldOnMouseWheelDown = mnLuaOutput.OnMouseWheelDown mnLuaOutput.OnMouseWheelDown = function(sender, x, y) if mnLuaUseZoom and isKeyPressed(VK_CONTROL) then if sender.Font.Size > 1 then sender.Font.Size = sender.Font.Size - 1 end end if mnLuaOutputoldOnMouseWheelDown then mnLuaOutputoldOnMouseWheelDown(sender, x, y) end end local mnLuaScriptoldOnMouseWheelDown = mnLuaScript.OnMouseWheelDown mnLuaScript.OnMouseWheelDown = function(sender, x, y) if mnLuaUseZoom and isKeyPressed(VK_CONTROL) then if sender.Font.Size > 1 then sender.Font.Size = sender.Font.Size - 1 end end if mnLuaScriptoldOnMouseWheelDown then mnLuaScriptoldOnMouseWheelDown(sender, x, y) end end local mnLuaOutputoldOnMouseWheelUp = mnLuaOutput.OnMouseWheelUp mnLuaOutput.OnMouseWheelUp = function(sender, x, y) if mnLuaUseZoom and isKeyPressed(VK_CONTROL) then if sender.Font.Size < 50 then sender.Font.Size = sender.Font.Size + 1 end end if mnLuaOutputoldOnMouseWheelUp then mnLuaOutputoldOnMouseWheelUp(sender, x, y) end end local mnLuaScriptoldOnMouseWheelUp = mnLuaScript.OnMouseWheelUp mnLuaScript.OnMouseWheelUp = function(sender, x, y) if mnLuaUseZoom and isKeyPressed(VK_CONTROL) then if sender.Font.Size < 50 then sender.Font.Size = sender.Font.Size + 1 end end if mnLuaScriptoldOnMouseWheelUp then mnLuaScriptoldOnMouseWheelUp(sender, x, y) end end local oldNewWindow = frmluaEngine.ComponentByName['MenuItem11'].OnClick frmluaEngine.ComponentByName['MenuItem11'].OnClick = function(...) if oldNewWindow then oldNewWindow(...) end local timer2 = createTimer(nil, false) timer2.Interval = 1000 timer2.OnTimer = function(timer2) timer2.Enabled = false timer2.destroy() local frm0 for i = 0, getFormCount() - 1 do frm0 = getForm(i) if frm0.ClassName == 'TfrmLuaEngine' and frm0.isForegroundWindow(frm0) then break end end frm0 = frm0.ClassName == 'TfrmLuaEngine' and frm0 or getLuaEngine() if frm0 then mnLuaEngineUseZoom(frm0) end end timer2.Enabled = true end end local function mnAutoInjectUseZoom(frmAutoInject) if not frmAutoInject then return end local mnLuaUseZoom = false local mnAssemblescreen = frmAutoInject.ComponentByName['Assemblescreen'] if not mnAssemblescreen then return end local oldAssemblescreenOnKeyPress = mnAssemblescreen.OnKeyPress mnAssemblescreen.OnKeyPress = function(sender, key) if key == '' then -- VK_Q & VK_CONTROL local cPtrStart = '%-%-%[=*%[' local cPtrEnd = '%]=*%]%-*%-*' if mnAssemblescreen.SelText ~= '' then if isKeyPressed(VK_SHIFT) then -- VK_Q & VK_CONTROL & VK_SHIFT if mnAssemblescreen.SelText:find( '^(.*)' .. cPtrStart .. '.*' .. cPtrEnd .. '(.*)$') then local insideComment = mnAssemblescreen.SelText:match( '%-%-%[(=*)%[(.*)%]=*%]%-*%-*') mnAssemblescreen.SelText = mnAssemblescreen.SelText:gsub('^(.*)%-%-%[' .. insideComment .. '%[(.*)%s*%]' .. insideComment .. '%]%-*%-*(.*)$', '%1%2%3') end else if mnAssemblescreen.SelText:find( '^(%s*)' .. cPtrStart .. '(.*)' .. cPtrEnd .. '(%s*)$') then mnAssemblescreen.SelText = mnAssemblescreen.SelText:gsub('^(%s*)' .. cPtrStart .. '(.*)%s*' .. cPtrEnd .. '(%s*)$', '%1%2%3') elseif mnAssemblescreen.SelText:find( cPtrStart .. '.*' .. cPtrEnd) then local insideComment = mnAssemblescreen.SelText:match( '%-%-%[(=*)%[(.*)%](=*)%]%-*%-*') mnAssemblescreen.SelText = mnAssemblescreen.SelText:gsub('^(.*)$', '--[' .. insideComment .. '=[%1 ]' .. insideComment .. '=]--') else mnAssemblescreen.SelText = ('--[[%s ]]--'):format(mnAssemblescreen.SelText) end end else if isKeyPressed(VK_SHIFT) then return end mnAssemblescreen.SelText = '--[[]]--' end return end local useSelectBack = false if tostring(key):find("[([{'" .. '"]') then local newText = '(%s)' if tostring(key) == '(' then newText = '(%s)' elseif tostring(key) == '[' then newText = '[%s]' --useSelectBack = true elseif tostring(key) == '{' then newText = '{%s}' elseif tostring(key) == '"' then newText = '"%s"' elseif tostring(key) == "'" then newText = "'%s'" end if mnAssemblescreen.SelText == '' then mnAssemblescreen.SelText = newText:format( mnAssemblescreen.SelText) mnAssemblescreen.SelStart = mnAssemblescreen.SelStart - 1 else local SelStart = mnAssemblescreen.SelStart local SelEnd = mnAssemblescreen.SelEnd local oldSelStart = mnAssemblescreen.SelStart mnAssemblescreen.SelText = newText:format( mnAssemblescreen.SelText) if useSelectBack then mnAssemblescreen.SelEnd = oldSelStart end end else return oldAssemblescreenOnKeyPress and oldAssemblescreenOnKeyPress(sender, key) or key end end local mnAssemblescreenoldOnKeyDown = mnAssemblescreen.OnKeyDown mnAssemblescreen.OnKeyDown = function(sender, key) if key == VK_CONTROL and not UseZoom then if isKeyPressed(VK_CONTROL) and not mnLuaUseZoom then mnLuaUseZoom = true end end if mnAssemblescreenoldOnKeyDown then mnAssemblescreenoldOnKeyDown(sender, key) end end local mnAssemblescreenoldOnKeyUp = mnAssemblescreen.OnKeyUp mnAssemblescreen.OnKeyUp = function(sender, key) if isKeyPressed(VK_CONTROL) and mnLuaUseZoom then mnLuaUseZoom = false end if mnAssemblescreenoldOnKeyUp then mnAssemblescreenoldOnKeyUp(sender, key) end end local mnAssemblescreenoldOnMouseWheelDown = mnAssemblescreen.OnMouseWheelDown mnAssemblescreen.OnMouseWheelDown = function(sender, x, y) if mnLuaUseZoom and isKeyPressed(VK_CONTROL) then if sender.Font.Size > 1 then sender.Font.Size = sender.Font.Size - 1 end end if mnAssemblescreenoldOnMouseWheelDown then mnAssemblescreenoldOnMouseWheelDown(sender, x, y) end end local mnAssemblescreenoldOnMouseWheelUp = mnAssemblescreen.OnMouseWheelUp mnAssemblescreen.OnMouseWheelUp = function(sender, x, y) if mnLuaUseZoom and isKeyPressed(VK_CONTROL) then if sender.Font.Size < 50 then sender.Font.Size = sender.Font.Size + 1 end end if mnAssemblescreenoldOnMouseWheelUp then mnAssemblescreenoldOnMouseWheelUp(sender, x, y) end end local oldNewWindow = frmAutoInject.miNewWindow.OnClick frmAutoInject.miNewWindow.OnClick = function(...) if oldNewWindow then oldNewWindow(...) end local timer2 = createTimer(nil, false) timer2.Interval = 1000 timer2.OnTimer = function(timer2) timer2.Enabled = false timer2.destroy() local frm2 for i = 0, getFormCount() - 1 do frm2 = getForm(i) if frm2.ClassName == 'TfrmAutoInject' and frm2.isForegroundWindow(frm2) then break end end if frm2 then mnAutoInjectUseZoom(frm2) end end timer2.Enabled = true end end oldAddressListOnDblClick = AddressList.List.OnDblClick AddressList.List.OnDblClick = function(...) if oldAddressListOnDblClick then oldAddressListOnDblClick(...) end if not AddressList.SelectedRecord then return end if AddressList.SelectedRecord.Type == vtAutoAssembler then local timer2 = createTimer(nil, false) timer2.Interval = 1000 timer2.OnTimer = function(timer2) timer2.Enabled = false timer2.destroy() local frm2 for i = 0, getFormCount() - 1 do frm2 = getForm(i) if frm2.ClassName == 'TfrmAutoInject' and frm2.isForegroundWindow(frm2) then break end end if frm2 then mnAutoInjectUseZoom(frm2) end end timer2.Enabled = true end end oldAddressListOnKeyDown = AddressList.List.OnKeyDown AddressList.List.OnKeyDown = function(sender, key) if AddressList.SelectedRecord then if AddressList.SelectedRecord.Type == vtAutoAssembler and key == VK_RETURN then local timer2 = createTimer(nil, false) timer2.Interval = 1000 timer2.OnTimer = function(timer2) timer2.Enabled = false timer2.destroy() local frm2 for i = 0, getFormCount() - 1 do frm2 = getForm(i) if frm2.ClassName == 'TfrmAutoInject' and frm2.isForegroundWindow(frm2) then break end end if frm2 then mnAutoInjectUseZoom(frm2) end end timer2.Enabled = true end end if oldAddressListOnKeyDown then return oldAddressListOnKeyDown(sender, key) end return key end oldAutoInject1OnClick = getMemoryViewForm().AutoInject1.OnClick getMemoryViewForm().AutoInject1.OnClick = function(sender) if oldAutoInject1OnClick then oldAutoInject1OnClick(sender) end local timer2 = createTimer(nil, false) timer2.Interval = 1000 timer2.OnTimer = function(timer2) timer2.Enabled = false timer2.destroy() local frm2 for i = 0, getFormCount() - 1 do frm2 = getForm(i) if frm2.ClassName == 'TfrmAutoInject' and frm2.isForegroundWindow(frm2) then break end end if frm2 then mnAutoInjectUseZoom(frm2) end end timer2.Enabled = true end getCEForms() mnLuaEngineUseZoom(frmCE.frmfrmLuaEngine) mnAutoInjectUseZoom(frmCE.frmfrmAutoInject) end timer.Enabled = true