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 


Cheat Engine Forum Index
PostGo back to topic
Dark Byte
Site Admin
Reputation: 460
Joined: 09 May 2003
Posts: 25362
Location: The netherlands

PostPosted: Fri Apr 29, 2022 9:44 am    Post subject: Using notepad as your memoryrecord AA editor

I'm sure everyone wishes they could edit their addresslist memoryrecord AA scripts using notepad instead of ce's built-in editor

you can do that with this script

Just doubleclick on the script part and instead of opening the CE AA editor, notepad will pop up with the curent script.

Do not forget to save the script before closing notepad

Code:

function LaunchCommandAndWait(command)
  local lpStartupInfo=createMemoryStream()
  local lpProcessInfo=createMemoryStream()
  local sisize
  local pisize
  local r

  local result

  if cheatEngineIs64Bit() then
    sisize=104
    pisize=24
  else
    sisize=68
    pisize=16
  end
  lpStartupInfo.writeDword(sisize)
  lpStartupInfo.Size=sisize
  lpProcessInfo.Size=pisize

  r=executeCodeLocalEx('CreateProcessA',0,command,0,0,0,0,0,0,lpStartupInfo.Memory,lpProcessInfo.Memory);

  if r~=0 then
    lpProcessInfo.Position=0
    local hProcess
    local hThread
    if cheatEngineIs64Bit() then
      hProcess=lpProcessInfo.readQword()
      hThread=lpProcessInfo.readQword()
    else
      hProcess=lpProcessInfo.readDword()
      hThread=lpProcessInfo.readDword()
    end

    r=executeCodeLocalEx('WaitForSingleObject', hProcess, 0xffffffff)
    local ExitCode=createMemoryStream()
    ExitCode.Size=4
    if executeCodeLocalEx('GetExitCodeProcess', hProcess, ExitCode.Memory)~=0 then
      result=ExitCode.readDword()
    end
    ExitCode.destroy()

    --cleanup handles
    executeCodeLocalEx('CloseHandle', hProcess)
    executeCodeLocalEx('CloseHandle', hThread)
  end

  lpProcessInfo.destroy()
  lpStartupInfo.destroy()

  return result
end

local counter=0

local active={}

AddressList.OnAutoAssemblerEdit=function(al,mr)
 -- print("editing aa script")
  if active[mr.ID] then return true end --already editing

  mr.beginEdit()
 -- print("memrec has been marked as editing")
  local sl=createStringList()
  sl.Text=mr.Script

  local path
  if getTempFolder then
    path=getTempFolder()
  else
    path=getCheatEngineDir()
  end
  lfs.mkdir(path.."editing-ceaascripts") --assume it works, or it already exists
  path=path.."editing-ceaascripts\\"

  --printf("initial path=%s", path)

  local ms=createMemoryStream()
  ms.size=260
  if executeCodeLocalEx("GetTempFileNameA", path,"CEA",0,ms.Memory) ~=0 then
    path=readStringLocal(ms.Memory,260)
    --printf("final path=%s", path)

    ms.destroy()

    --printf("saving script to %s", path)
    sl.saveToFile(path)
    active[mr.ID]=true

    createThread(function(t)
      --print("AA editorthread: Launching notepad and wait")
      LaunchCommandAndWait('notepad.exe '..path)

      --print("AA editorthread: Finished waiting")
      sl.loadFromFile(path)
      mr.Script=sl.Text
      mr.endEdit()
      sl.destroy()

      active[mr.ID]=nil
     -- print("done editing")
    end)
    return true
  else
    print("GetTempFileNameA failed")
    sl.destroy()
    ms.destroy()
    return false
  end
end

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Post reviews:   Approve 1
Author Review
++METHOS
Review: Approve
Post reference:
ReviewPosted: Fri Apr 29, 2022 12:43 pm


Back to top
View user's profile Send private message
Display:  
Cheat Engine Forum Index


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites