Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Add few new useful menu entries.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 156

Joined: 07 Nov 2008
Posts: 4226
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Mon Jul 15, 2013 11:20 am    Post subject: Add few new useful menu entries. Reply with quote

I often open main.lua (doc file) and defines.lua when I'm creating not so generic trainers. Script below adds two new entries inside Help submenu:

Code:
function addMenuItem(parent,caption)
  if parent==nil then return nil end

  local newItem = createMenuItem(parent); parent.add(newItem)
  newItem.Caption = caption

  return newItem
end
menuItem_help = getMainForm().findComponentByName('Help1')

--add two new useful entries
addMenuItem(menuItem_help,'-')

addMenuItem(menuItem_help,'main.lua').setOnClick(
       function ()
         shellExecute('main.lua','',getCheatEngineDir())
       end)
       
addMenuItem(menuItem_help,'defines.lua').setOnClick(
       function ()
         shellExecute('defines.lua','',getCheatEngineDir())
       end)
       
addMenuItem       = nil
menuItem_help     = nil



Of course, you have to associate .lua files with notepad or notepad++

_________________
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 156

Joined: 07 Nov 2008
Posts: 4226
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Jul 27, 2013 6:56 pm    Post subject: Reply with quote

Another version,
added new entry: "Switch to 32/64 bit" and

Code:
function addMenuItem(parent,caption)
  if parent==nil then return nil end

  local newItem = createMenuItem(parent); parent.add(newItem)
  newItem.Caption = caption

  return newItem
end

-- which CE ?
if cheatEngineIs64Bit() then
  getMainForm().Caption = getMainForm().Caption .. '   64bit'
else
  getMainForm().Caption = getMainForm().Caption .. '   32bit'
end

-- add few new useful entries
menuItem_help = getMainForm().Help1
addMenuItem(menuItem_help,'-')

addMenuItem(menuItem_help,'Open main.lua').setOnClick(
 function ()
    shellExecute('main.lua','',getCheatEngineDir())
 end)

addMenuItem(menuItem_help,'Open defines.lua').setOnClick(
 function ()
    shellExecute('defines.lua','',getCheatEngineDir())
 end)

opposite = cheatEngineIs64Bit() and '32bit' or '64bit'

addMenuItem(menuItem_help,'Switch to '..opposite..' CE').setOnClick(
  function ()
    local canNotSwitch = (cheatEngineIs64Bit()==false) and (os.getenv("PROCESSOR_ARCHITEW6432")==nil)
    if canNotSwitch then
      messageDialog('You can not switch to 64bit CE, you have Win32.',mtInformation,mbOK)
      return
    end

    oppositeBinary = cheatEngineIs64Bit() and 'cheatengine-i386.exe'
                                           or 'cheatengine-x86_64.exe'

    local mr=messageDialog('Are you sure?',mtConfirmation,mbYes,mbNo)
    if mr==mrNo then return end
    shellExecute(oppositeBinary,'',getCheatEngineDir())
    createTimer(nil,true).OnTimer = function() closeCE() end
  end)


addMenuItem       = nil
menuItem_help     = nil
opposite = nil

_________________
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 156

Joined: 07 Nov 2008
Posts: 4226
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Jan 10, 2014 10:29 pm    Post subject: Reply with quote

CE6.3+ have new Option entry for every parenting(has children) memoryrecord:
"manual expand/collapse"

it shows small square next to "active square". This square contains tiny "-" when memoryrecord is collapsed, and tiny "+" when expanded.



This code will set "manual expand/collapse" for all memoryrecords which have hidden children:
Code:
addMenuItem(menuItem_help,'Reveal expandable memory records...').setOnClick(
  function ()
    local al = getAddressList()
    for i=0,al.Count-1 do
      local mr = al.getMemoryRecord(i)
      if mr.Count>=1 and mr.Options:match("%[moHideChildren%]") then
         mr.Options = "[moHideChildren,moManualExpandCollapse]"
      end
    end
  end)


paste it before this line
addMenuItem = nil

_________________
Back to top
View user's profile Send private message MSN Messenger
Aylin
Expert Cheater
Reputation: 2

Joined: 16 Feb 2017
Posts: 194

PostPosted: Fri Nov 30, 2018 4:49 pm    Post subject: Reply with quote

hi master
Several blending code, I encrypting lua-script.
But for this I have to open 2 separate CE.

'cheatengine-i386.exe' for 32..
and
'cheatengine-x86_64.exe' for 64..

Can I get a 32 and 64 bit encryption result in a single CE?
By canceling Button2, is there a way to do both 64 and 32 bit encryption with Button1?
Thanks for your help and publications.


The example I use:

Code:
form = createForm(false)
form.Position = poDesktopCenter
form.Width = 539
form.Height = 294
form.BorderStyle = "bsNone"

memo1 = createMemo(form)
memo1.Top = 84
memo1.Left = 16
memo1.Width = 240
memo1.Height = 190
memo1.ScrollBars = "ssAutoBoth"

memo2 = createMemo(form)
memo2.Top = 84
memo2.Left = 285
memo2.Width = 240
memo2.Height = 190
memo2.ScrollBars = "ssAutoBoth"

button1 = createButton(form)
button1.Height = 26
button1.Left = 34
button1.Top = 44
button1.Width = 90
button1.Caption = "Encode64"

button2 = createButton(form)
button2.Height = 26
button2.Left = 147
button2.Top = 44
button2.Width = 90
button2.Caption = "Encode32"

button3 = createButton(form)
button3.Height = 26
button3.Left = 300
button3.Top = 44
button3.Width = 90
button3.Caption = "Sell Text"

button4 = createButton(form)
button4.Height = 26
button4.Left = 413
button4.Top = 44
button4.Width = 90
button4.Caption = "Reset"

button5 = createButton(form)
button5.Height = 30
button5.Left = 490
button5.Top = 10
button5.Width = 30
button5.Caption = "X"
button5.Font.size = 14
button5.Font.style = "fsBold"

label = createLabel(form)
label.Height = 31
label.Left = 17
label.Top = 9
label.Width = 424
label.AutoSize = false
label.Font.size = 13
label.Font.style = "fsBold"


-- 32/64 bits Opposite Code By mgr.inz.Player Thanks------

opposite = cheatEngineIs64Bit() and '32bit' or '64bit'
oppositeBinary = cheatEngineIs64Bit() and 'cheatengine-i386.exe'
                                           or 'cheatengine-x86_64.exe'

if cheatEngineIs64Bit() then
label.caption = "Encode Format 64bit"
form.color = "0x56ffff"
else
label.caption = "Encode Format 32bit"
form.color = "0x00ff00"
end



button1.OnClick = function()
-- Encode Script Creator By Filipe Pani CEF Form: https://forum.cheatengine.org/viewtopic.php?t=602049
   text_encode = "function code() "..memo1.Lines.Text.." end encode = encodeFunction(code)"
    script_encode = load(text_encode)()
    script_print = "opposite = cheatEngineIs64Bit() and '32bit' or '64bit'\noppositeBinary = cheatEngineIs64Bit() and 'cheatengine-i386.exe'\n                                           or 'cheatengine-x86_64.exe'\nif cheatEngineIs64Bit() then\nlocal my_function = decodeFunction(\'"..encode.."\')\nmy_function()\nelse\nlocal my_function = decodeFunction('c-oCu-E')\nmy_function()\nend"
    memo2.Lines.Text = script_print

end


button4.OnClick = function() --Reset
memo1.Lines.Text = ''
memo2.Lines.Text = ''
end

button2.OnClick = function() -- Encode2 Button sell

   text_encode = "function code() "..memo1.Lines.Text.." end encode = encodeFunction(code)"
    script_encode = load(text_encode)()
    script_print = "local my_function = decodeFunction(\'"..encode.."\')\nmy_function()"
    memo2.Lines.Text = script_print

end
label.OnMouseDown = function() form.DragNow() end

button3.OnClick = function() --sell
memo2.Lines.Text = ''
end

button5.OnClick = function() --Close
  closeCE()
  return caFree
end

form.Show()


I have a video for the example.

https://www.youtube.com/watch?v=SWO0J18xZKE&list=PL1yPHiegVpRoWx7jy6ecTqmbejos75O37&index=74

How do I get 32 and 64 bit Encode output with Single Button?
Rolling Eyes Sad Shocked

_________________
See Hitler ! This Trainer is for you!
http://forum.cheatengine.org/viewtopic.php?t=606786
Enthusiastic people: Always one step ahead!
Do not underestimate me Master: You were a beginner in the past!
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites