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
AylinCE
Grandmaster Cheater Supreme
Reputation: 35
Joined: 16 Feb 2017
Posts: 1476

PostPosted: Sat Apr 30, 2022 11:10 am    Post subject:

An example of user editing based on the original topic;

1) Notepad and Notepad++ added. (You can add more editors)
2) Added to the popup menu by right-clicking instead of double-clicking on the script.
3) A hotkey is assigned. (Default is Ctrl+E, edit it to your liking)
4) Added an annoying Input query. (Option menu for those using multiple editing programs)
5) In order to process (Save) the edit, the final version should be saved and the editing program should be closed before exiting the editing program. Otherwise, CE script will not be able to receive commands for content change.


Code:
local result1=1
al = getAddressList()
pathOrg=getCheatEngineDir()
local pathtbl={pathOrg.."editing-ceaascripts"}

local progtbl={{[[notepad.exe]],[[notepad.exe]]},
               {[[C:\Program Files\Notepad++\notepad++.exe]],[[notepad++.exe]]}
}

local pthText=[[Just type the number of titles and confirm:
1) Notepad.exe
2) Notopad++.exe]]

function editPath(ePath,editName)
  local path = ePath
  lfs.mkdir(path) --assume it works, or it already exists
  path=path.."\\"..editName..".tmp"
    return path
end

function LaunchCommandAndWait(command)
 local proc=getProcessList()[tonumber(command)]
 --print(proc)
  if proc==nil then
   result1=0
   else
   result1=1
  end
  return result1
end

function EditPad()
local mr=AddressList.getSelectedRecord()
  --print(mr.Script)
local sl=createStringList()
sl.Text=mr.Script
  --print(mr.Script)
local path1=pathtbl[1]
path=editPath(path1,mr.Description)
--print(path)
--printf("initial path=%s", path)
 if path then
  sl.saveToFile(path)
  progIdx=inputQuery('Select Edit Program', pthText, progIdx)
  progIdx=tonumber(progIdx)
  if progIdx==nil then showMessage("Just type the number!")
   else
   if progIdx>0 and progIdx<=#progtbl then
   if progIdx==1 then
    shellExecute(path)
    else
    prg1=progtbl[progIdx][1]
    shellExecute(prg1,shellExecute(path))
    --print(progtbl[progIdx][1])
   end
   sleep(200)
   prog1=getForegroundProcess() or getProcessIDFromProcessName(progtbl[progIdx][2])
   --print(1,prog1)
    if Thread1 then Thread1.Destroy() Thread1=nil end
     Thread1=createTimer() Thread1.Interval=1100
     Thread1.Enabled=true
     Thread1.OnTimer=function()
     aa=LaunchCommandAndWait(prog1)

      if aa==0 then
       sl.loadFromFile(path)
       mr.Script=sl.Text
       sl.destroy()
       --print(mr.Script)
       os.remove(path)
       Thread1.Enabled=false
       return true
      end
     end
     end
    end
  end
end

local mm = al.Parent.PopupMenu
if nm==nil then
  nm = createMenuItem(mm)
  nm.Caption = "Edit Notepad++"
  menuItem_setShortcut(nm, "Ctrl+E")
  nm.OnClick = EditPad

  mm.Items.insert(15,nm)
end

if oldOnPopup==nil then
  oldOnPopup=mm.OnPopup

  mm.OnPopup=function(sender)
               nm.Visible=al.SelCount>0
               oldOnPopup(sender)
             end
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
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 Visit poster's website MSN Messenger
Post reviews:   Approve 1
Author Review
LeFiXER
Review: Approve
Post reference:
ReviewPosted: Sun May 01, 2022 8:33 am

Excellent work!
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