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 


CE Multi-Instance Helper [ver. 1.05]

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

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

PostPosted: Sun Feb 03, 2019 10:01 pm    Post subject: CE Multi-Instance Helper [ver. 1.05] This post has 1 review(s) Reply with quote

Movie worth a thousand words

Link



version 1.05

you can change colors at first line.

Code:
--version 1.05
local colorTable = {-1,0x008000,0xff8000,0x95004a,0x0000ff,0x0080c0,0x8000ff,0x0000a0}
local usedColors = {}

for pid,wndCaption in pairs(getWindowlist()) do
  for i=1,#wndCaption do
    if wndCaption[i]:match('Cheat Engine %d+%.[%.%d]+.*#%d+') then
      local colorID = tonumber(wndCaption[i]:match('#(%d+)')) or 'ignore'
      usedColors[colorID]=true
      break
    end
  end
end

if (usedColors[1]==true) then
  local color
  local colorID=2
  for i=2,#colorTable do --find unused color
    if not usedColors[i] then color = colorTable[i]; colorID=i; break; end
  end
  local function allowedTForms(formClassName)
    local someTForms = {
                        ['TAbout']=1,
                        ['TChangeOffset']=1,
                        ['TFindDialogForm']=1,
                        ['TFindWindow']=1,
                        ['TFormDesigner']=1,
                        ['TFormMemoryRegions']=1,
                        ['TFoundCodeDialog']=1,
                        ['TFrmMemoryRecordDropdownSettings']=1,
                        ['THotKeyForm']=1,
                        ['TInputboxTop']=1,
                        ['TMemoryBrowser']=1,
                        ['TObjectInspectorDlg']=1,
                        ['TProcessWindow']=1,
                        ['TReplaceDialogForm']=1,
                        ['TformAddressChange']=1,
                        ['TfrmAAEditPrefs']=1,
                        ['TfrmAccessedMemory']=1,
                        ['TfrmAssemblyScan']=1,
                        ['TfrmAutoInject']=1,
                        ['TfrmBreakpointlist']=1,
                        ['TfrmChangedAddresses']=1,
                        ['TfrmCodeFilter']=1,
                        ['TfrmCodecaveScanner']=1,
                        ['TfrmDissectCode']=1,
                        ['TfrmEnumerateDLLs']=1,
                        ['TfrmFillMemory']=1,
                        ['TfrmFindStatics']=1,
                        ['TfrmLuaEngine']=1,
                        ['TfrmMemoryAllocHandler']=1,
                        ['TfrmMemoryViewEx']=1,
                        ['TfrmMemviewPreferences']=1,
                        ['TfrmPEInfo']=1,
                        ['TfrmPointerScannerSettings']=1,
                        ['TfrmReferencedFunctions']=1,
                        ['TfrmReferencedStrings']=1,
                        ['TfrmRescanPointer']=1,
                        ['TfrmSetupPSNNode']=1,
                        ['TfrmStacktrace']=1,
                        ['TfrmStringMap']=1,
                        ['TfrmStringPointerScan']=1,
                        ['TfrmStructureCompare']=1,
                        ['TfrmStructures2']=1,
                        ['TfrmStructuresConfig']=1,
                        ['TfrmThreadlist']=1,
                        ['TfrmTrainerGenerator']=1,
                        ['TfrmUltimap']=1,
                        ['TfrmUltimap2']=1,
                        ['TfrmWatchlist']=1,
                        ['TfrmdissectWindow']=1,
                        ['Tfrmpointerscanner']=1,
                       }


    return someTForms[formClassName]~=nil
  end

  local function addNicePanels(form)
    local canvas
    local Panel1 = createPanel(form)
          Panel1.Visible = false
          --Panel1.Top = form.Height - 2
          --Panel1.Left = 0
          --Panel1.Height = 2
          --Panel1.Width = form.Width
          Panel1.Align = alBottom
          Panel1.Constraints.MinHeight = 2
          Panel1.Constraints.MaxHeight = 2
          Panel1.Anchors = '[akBottom, akLeft, akRight]'
          Panel1.bringToFront()
          Panel1.Caption = ''
          Panel1.Color = color
          Panel1.BevelOuter = 0

    local Panel2 = createPanel(form)
          Panel2.Visible = false
          Panel2.Top = 0
          Panel2.Left = 0
          Panel2.Height = 2
          Panel2.Width = form.Width
          Panel2.Anchors = '[akTop, akLeft, akRight]'
          Panel2.bringToFront()
          Panel2.Caption = ''
          Panel2.Color = color
          Panel2.BevelOuter = 0

    local Panel3 = createPanel(form)
          Panel3.Visible = false
          Panel3.Top = 0
          Panel3.Left = 0
          --Panel3.Height = form.Height
          Panel3.AnchorSideBottom.Control = Panel1
          Panel3.Width = 2
          Panel3.Anchors = '[akTop, akLeft, akBottom]'
          Panel3.bringToFront()
          Panel3.Caption = ''
          Panel3.Color = color
          Panel3.BevelOuter = 0

    local Panel4 = createPanel(form)
          Panel4.Visible = false
          Panel4.Top = 0
          Panel4.Left = form.Width - 2
          --Panel4.Height = form.Height
          Panel4.AnchorSideBottom.Control = Panel1
          Panel4.Width = 2
          Panel4.Anchors = '[akTop, akRight, akBottom]'
          Panel4.bringToFront()
          Panel4.Caption = ''
          Panel4.Color = color
          Panel4.BevelOuter = 0

    Panel1.Visible = true
    Panel2.Visible = true
    Panel3.Visible = true
    Panel4.Visible = true
  end

  --MainForm.Splitter1.Color = color
  addNicePanels(MainForm)
  addNicePanels(MainForm.frmAutoInject)
  addNicePanels(getMemoryViewForm())
  addNicePanels(getSettingsForm())
  addNicePanels(getLuaEngine())

  for i=0,getFormCount()-1 do
    local formClassName = getForm(i).ClassName
    if formClassName=='TAdvancedOptions' or formClassName=='TComments' or formClassName=='TTypeForm' then
      addNicePanels(getForm(i))
    end
  end

  local ap=getApplication()
  ap.Title = ap.Title..' #'..colorID

  registerFormAddNotification(function (form)
    --print(form.className)
    if not allowedTForms(form.className) then return end
    local t=createTimer()
    t.Interval = 1
    t.OnTimer = function (timer)
      timer.destroy()
      addNicePanels(form)
    end
  end)
else
  local ap=getApplication()
  ap.Title = ap.Title..' #1'
end

_________________


Last edited by mgr.inz.Player on Sat Dec 07, 2019 2:35 pm; edited 9 times in total
Back to top
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Sun Feb 17, 2019 8:05 am    Post subject: Reply with quote

A little detail: But, ultimately, it works fine.
First of all, thanks for all your labor.
Here's a detail:
1. CE open, 2.CE green border and clear.
1. CE closed. Once again CE:
2 green border CE happening in my hand.

Sometimes I open three trainer and look at the code differences.
With the color difference, which the Trainer is original, I understand. Wink
Thanks again.


_________________
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
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sun Feb 17, 2019 10:46 pm    Post subject: Reply with quote

A cheap fix would be perhaps add an instance id (1,2,3..) to the window title, and then based that apply the different colors.
_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Mon Feb 18, 2019 2:12 am    Post subject: Reply with quote

DaSpamer wrote:
A cheap fix would be perhaps add an instance id (1,2,3..) to the window title, and then based that apply the different colors.


I guess the numbering won't be the solution.
1. CE open = Colorless
2. CE open = Green border.
1. If CE is closed and opened again, 2. CE becomes
and again we have 2 green borders.
An idea for the solution:
It is possible to compare "if" and "elseif" to the opened CE margins.

Code:
if count>1 then
  local colorTable = {0x008000,0xff8000,0x95004a,0x0000ff,0x0080c0,0x8000ff,0x0000a0}
  local color = colorTable[count-1] or 0


.. Wink

_________________
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
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Mon Feb 18, 2019 7:40 am    Post subject: This post has 1 review(s) Reply with quote

Oh I think I understood,
If for example we have a primary CE window open.
and then we open another (secondary) window, it should have green borders.
But if we close now primary CE window, and then re-open again CE, we'll have 2 windows with both green.

if we open third window, and close any of the first two, and re-open again, then the new window will have the very same color of the third...
Basically duplicate of colors.

Solution:
Replace this code:
Code:
local processList = createStringlist()
getProcesslist(processList)

local count=0
for i=0,processList.Count-1 do
  if (processList[i]:match('cheatengine%-i386.exe')) or
     (processList[i]:match('cheatengine%-x86_64.exe')) then
    count=count+1
  end
end

processList.destroy()


with this code:
(it uses application class, and getWindowList fetches the title of application class as a title, so we use that title as a tag).
Code:
local app,it,count = getApplication(),{},1; -- it is instanceTable, a temporary table where I store used ID's.
function inTable(t,V)
   for k,v in pairs(t or{})do
      if(v==V)then return true;end;
   end;return false;
end
for pid,uselessTab in pairs(getWindowlist()) do
   if (uselessTab[0]:match("(Cheat Engine [%d%.]+)")) then -- try to match Cheat Engine X.X.X....
      local isInstance = tonumber(uselessTab[0]:match("%*(%d+)$")); -- tryna fetch given id for that window
      if (isInstance) then
         table.insert(it,isInstance);
         while (inTable(it,count)) do
            count = count + 1;
         end
      end
   end
end
app.Title = table.concat({app.Title," - *", count},"") -- generates new application title, based on available id;

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Mon Feb 18, 2019 12:51 pm    Post subject: Reply with quote

DaSpamer wrote:
Oh I think I understood,
If for example we have a primary CE window open.
and then we open another (secondary) window, it should have green borders.
But if we close now primary CE window, and then re-open again CE, we'll have 2 windows with both green.

if we open third window, and close any of the first two, and re-open again, then the new window will have the very same color of the third...
Basically duplicate of colors.

Solution:
Replace this code:
Code:
local processList = createStringlist()
getProcesslist(processList)

local count=0
for i=0,processList.Count-1 do
  if (processList[i]:match('cheatengine%-i386.exe')) or
     (processList[i]:match('cheatengine%-x86_64.exe')) then
    count=count+1
  end
end

processList.destroy()


with this code:
(it uses application class, and getWindowList fetches the title of application class as a title, so we use that title as a tag).
Code:
local app,it,count = getApplication(),{},1; -- it is instanceTable, a temporary table where I store used ID's.
function inTable(t,V)
   for k,v in pairs(t or{})do
      if(v==V)then return true;end;
   end;return false;
end
for pid,uselessTab in pairs(getWindowlist()) do
   if (uselessTab[0]:match("(Cheat Engine [%d%.]+)")) then -- try to match Cheat Engine X.X.X....
      local isInstance = tonumber(uselessTab[0]:match("%*(%d+)$")); -- tryna fetch given id for that window
      if (isInstance) then
         table.insert(it,isInstance);
         while (inTable(it,count)) do
            count = count + 1;
         end
      end
   end
end
app.Title = table.concat({app.Title," - *", count},"") -- generates new application title, based on available id;



And the solution works perfectly. Thanks @DaSpamer
Main nicer ones: While the designer is not on duty,
Another designer takes over the task.
This is a great team work.
This team is never destroyed.
Thanks again. @mgr.inz.Player, @DaSpamer

_________________
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
mgr.inz.Player
I post too much
Reputation: 217

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

PostPosted: Sat Feb 23, 2019 6:14 am    Post subject: Reply with quote

Aylin wrote:
1. CE open, 2.CE green border and clear.
1. CE closed. Once again CE:
2 green border CE happening in my hand.

I didn't take such use case into account.

Sometimes, I'm using two or three CE instances at once. I'm also testing few CE versions (or CE built with different Lazarus/FPC versions) that way.
This is why I wrote this extension.


Anyway, I added "getApplication().Title and getWindowlist()" modifications to the first post.

_________________
Back to top
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Sat Feb 23, 2019 11:51 am    Post subject: Reply with quote

mgr.inz.Player wrote:

Anyway, I added "getApplication().Title and getWindowlist()" modifications to the first post.


Code correction is working fine. Thanks.
My guess: They will search for the difference below in the code above. Smile

PicUrl: http://tinypic.com/r/2uzw3dd/9
https://hizliresim.com/nQ96a1


_________________
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
mgr.inz.Player
I post too much
Reputation: 217

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

PostPosted: Mon Aug 26, 2019 3:38 pm    Post subject: Reply with quote

should be:
Code:
for pid,wndCaption in pairs(getWindowlist()) do
  for i=1,#wndCaption do
    if wndCaption[i]:match('Cheat Engine %d%.[%.%d]* #%d+') then
      local colorID = tonumber(wndCaption[i]:match('#(%d+)')) or 'ignore'
      usedColors[colorID]=true
      break
    end
  end
end

_________________
Back to top
View user's profile Send private message MSN Messenger
Csimbi
I post too much
Reputation: 91

Joined: 14 Jul 2007
Posts: 3093

PostPosted: Mon Aug 26, 2019 4:20 pm    Post subject: Reply with quote

Thank you!
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Tue Nov 19, 2019 8:45 am    Post subject: Reply with quote

Could Panel4 be different for 7.0?
With the "-23" deviation, I could see it in the form.

Code:
Panel4.Top = form.Height - 23

_________________
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
mgr.inz.Player
I post too much
Reputation: 217

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

PostPosted: Sat Dec 07, 2019 2:08 pm    Post subject: Reply with quote

Fifth update.

Aylin wrote:
Could Panel4 be different for 7.0

Now I'm using AnchorSideBottom.Control. Try it.

_________________
Back to top
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1227

PostPosted: Sat Dec 07, 2019 7:08 pm    Post subject: Reply with quote

mgr.inz.Player wrote:
Fifth update.

Now I'm using AnchorSideBottom.Control. Try it.


Thanks for the update.
The line is not now on the "Execute Script". (Panel4.Top = form.Height - 23) Smile

_________________
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
maskelihileci
Cheater
Reputation: 0

Joined: 08 Oct 2016
Posts: 43

PostPosted: Tue Feb 11, 2020 1:08 am    Post subject: Reply with quote

I use random windows name, can you optimize it accordingly
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 217

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

PostPosted: Sun Feb 16, 2020 3:59 am    Post subject: Reply with quote

@maskelihileci, Do you randomize other Cheat Engine windows?
_________________
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 Extensions 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 can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites