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 


Copy all Class names and first-level Field names

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
etioplmld
Advanced Cheater
Reputation: 0

Joined: 09 Feb 2021
Posts: 86

PostPosted: Tue Sep 01, 2026 6:45 pm    Post subject: Copy all Class names and first-level Field names Reply with quote

Improve the "net info" function and export these so that AI can search for valuable data.Code generated by AI
add to dotnetinfo.lua
Code:

-- ============================================================
-- Copy all Class names + first-level Field names to TXT
-- ============================================================

frmDotNetInfo.btnCopyAllFields=createButton(frmDotNetInfo.gbClasses)
frmDotNetInfo.btnCopyAllFields.Caption='复制所有地址名'
frmDotNetInfo.btnCopyAllFields.Width=230
frmDotNetInfo.btnCopyAllFields.Height=25

-- 与“复制当前显示 Classes”按钮并排
frmDotNetInfo.btnCopyAllFields.AnchorSideLeft.Control=frmDotNetInfo.btnCopyClasses
frmDotNetInfo.btnCopyAllFields.AnchorSideLeft.Side=asrRight
frmDotNetInfo.btnCopyAllFields.AnchorSideTop.Control=frmDotNetInfo.btnCopyClasses
frmDotNetInfo.btnCopyAllFields.AnchorSideTop.Side=asrTop
frmDotNetInfo.btnCopyAllFields.BorderSpacing.Left=8


frmDotNetInfo.btnCopyAllFields.OnClick=function(sender)

  -- ==========================================================
  -- 获取当前显示的 Classes
  -- ==========================================================

  local classes={}

  if frmDotNetInfo.FilteredClassList then

    -- 有过滤条件:使用当前过滤后的 Classes
    for i=1,#frmDotNetInfo.FilteredClassList do

      local Class=frmDotNetInfo.FilteredClassList[i]

      if Class then
        table.insert(classes,Class)
      end

    end

  else

    -- 没有过滤条件:使用当前 Assembly 的全部 Classes
    local Domain=
      DataSource.Domains[
        frmDotNetInfo.lbDomains.ItemIndex+1
      ]

    if not Domain then
      showMessage('没有选择 Domain')
      return
    end

    local Image=
      Domain.Images[
        frmDotNetInfo.lbImages.ItemIndex+1
      ]

    if not Image then
      showMessage('没有选择 Assembly')
      return
    end

    if not Image.Classes then
      showMessage('当前 Assembly 的 Classes 尚未加载完成')
      return
    end

    for i=1,#Image.Classes do

      local Class=Image.Classes[i]

      if Class then
        table.insert(classes,Class)
      end

    end

  end


  if #classes==0 then
    showMessage('没有找到 Classes')
    return
  end


  -- ==========================================================
  -- 创建进度窗口
  -- ==========================================================

  local progressForm=createForm(false)

  progressForm.Caption='正在读取 Classes 和地址名'
  progressForm.Width=500
  progressForm.Height=150
  progressForm.Position='poScreenCenter'
  progressForm.BorderStyle='bsDialog'

  local progressLabel=createLabel(progressForm)
  progressLabel.Left=20
  progressLabel.Top=20
  progressLabel.Width=450
  progressLabel.Caption='准备开始...'

  local progressBar=createProgressBar(progressForm)
  progressBar.Left=20
  progressBar.Top=55
  progressBar.Width=450
  progressBar.Height=25
  progressBar.Min=0
  progressBar.Max=#classes
  progressBar.Position=0

  local countLabel=createLabel(progressForm)
  countLabel.Left=20
  countLabel.Top=90
  countLabel.Width=450
  countLabel.Caption='0 / '..#classes

  progressForm.Show()


  -- ==========================================================
  -- 结果缓存
  -- ==========================================================

  local result={}

  local currentIndex=1

  local timer=createTimer(nil)

  -- 每次处理多少个 Class
  -- 数值越大速度越快,但窗口响应越差
  local batchSize=10


  timer.Interval=10


  timer.OnTimer=function(timer)

    local batchEnd=
      math.min(
        currentIndex+batchSize-1,
        #classes
      )


    for i=currentIndex,batchEnd do

      local Class=classes[i]

      if Class and Class.FullName then

        -- ------------------------------------------------------
        -- Class 名称
        -- ------------------------------------------------------

        table.insert(
          result,
          Class.FullName
        )


        -- ------------------------------------------------------
        -- 获取这个 Class 的一级 Fields
        --
        -- 直接使用 CE 现有的 getClassFields()
        -- 不递归展开 Field 对象
        -- ------------------------------------------------------

        local fields=nil

        local ok,ret=
          pcall(
            function()
              return getClassFields(Class)
            end
          )

        if ok then
          fields=ret
        end


        if fields then

          for j=1,#fields do

            local Field=fields[j]

            if Field and Field.Name then

              -- 两个空格
              table.insert(
                result,
                '  '..Field.Name
              )

            end

          end

        end

      end


      -- Class 之间空一行
      table.insert(result,'')

    end


    currentIndex=batchEnd+1

    progressBar.Position=batchEnd

    countLabel.Caption=
      tostring(batchEnd)..' / '..tostring(#classes)

    if classes[batchEnd] and classes[batchEnd].FullName then
      progressLabel.Caption=
        '正在读取: '..classes[batchEnd].FullName
    end


    -- ========================================================
    -- 全部完成
    -- ========================================================

    if currentIndex>#classes then

      timer.destroy()
      progressForm.close()


      -- ------------------------------------------------------
      -- 创建保存对话框
      -- ------------------------------------------------------

      local saveDialog=createSaveDialog()

      saveDialog.Title='保存 Classes 和地址名'
      saveDialog.Filter=
        '文本文件 (*.txt)|*.txt|所有文件 (*.*)|*.*'

      saveDialog.DefaultExt='txt'
      saveDialog.FileName='Assembly-CSharp_Classes_Fields.txt'


      if saveDialog.Execute() then

        local filename=saveDialog.FileName

        local f,err=
          io.open(filename,'w')

        if not f then

          showMessage(
            '无法保存文件:\n\n'..
            tostring(err)
          )

          saveDialog.destroy()
          return

        end


        -- Windows TXT 使用 CRLF
        f:write(
          table.concat(result,'\r\n')
        )

        f:close()


        showMessage(
          '保存完成!\n\n'..
          'Classes: '..#classes..'\n'..
          '输出行数: '..#result..'\n\n'..
          '文件:\n'..
          filename
        )

      end


      saveDialog.destroy()

    end

  end

end
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 6

Joined: 22 Jun 2021
Posts: 529

PostPosted: Wed Sep 02, 2026 12:44 am    Post subject: Reply with quote

"created by A.I. for A.I."
of course, not to be rude here or anything, but why in the world I would want A.I. to search for something that average CE user can do with enough imagination(implying making AA scripts)?
Though I shouldn't be surprised for people to use A.I. because companies always push A.I. like hot wings, yet furthermore people often overuse A.I. which results in them not being able to handle simple tasks like calculus
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 39

Joined: 16 Feb 2017
Posts: 1590

PostPosted: Wed Sep 02, 2026 3:13 am    Post subject: Reply with quote

Why don't you view AI as just another pot you use in the kitchen?
You put in all the ingredients and spices (all the possibilities and limitations), including ideas, and you simply give it the task of cooking.
You constantly check to ensure it cooks properly and doesn't burn the food.

Using AI should be perceived as using a "Calculator" sometimes, a "Cooking Pot" sometimes, or a "Car" sometimes.
If it provides time, information, and experience, using it should be seen as a normal, daily ritual.

That's my opinion.

_________________
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
Csimbi
I post too much
Reputation: 98

Joined: 14 Jul 2007
Posts: 3426

PostPosted: Wed Sep 02, 2026 11:42 am    Post subject: Reply with quote

I've been thinking about creating something like this - not for a dumb AI though.
I intended to do a full export of all information available for a smart person that knows what to do with it.

Assuming the script above works: thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting 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