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 


Find table entry by value

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

Joined: 16 Dec 2018
Posts: 41

PostPosted: Sat Mar 30, 2019 1:40 pm    Post subject: Find table entry by value Reply with quote

Is there a way to find cheat table entries by their value? I was hoping ctrl-F would pop up a "Find" dialogue, but no such luck.

More specifically, I have a ton of entries in my cheat table that update from a struct via script, so it includes a name (text) entry that would be useful to search on.

Trying another approach, I went back to the structure dissector and thought I was in luck when ctrl-F did indeed pop up a "Find" dialogue, but I'm not sure what it does, because it doesn't search within the "Value" field, and doesn't provide any option for doing so.
Back to top
View user's profile Send private message
ymiu
Cheater
Reputation: 0

Joined: 16 Dec 2018
Posts: 41

PostPosted: Sun Mar 31, 2019 1:58 pm    Post subject: Reply with quote

I made a function in LUA to do this, but I really wanted to bind it to a hotkey and have it pop-up a small window to enter my search-text and then click "Find Next". I tried working off of some CE LUA examples of simple forms, but they're too different from what I'm trying to do, and rather cryptic.

Find-Next function below. Each execution searches forward from the currently selected record, if any:

Code:
local function selectMemoryRecordByValue(str)
      local al = getAddressList()
      local cmr = al.SelectedRecord
      local midstart = false

      if cmr == nil then
         start = 0
      else
          midstart = true
          start = cmr.Index+1
      end
      --print("Total: ", al.Count-1)
      local i = start
      while i < al.Count do
            --print("i=", i, " ", tostring(midstart))
            if string.match(string.lower(al.MemoryRecord[i].Value), string.lower(str)) == string.lower(str) then
               al.setSelectedRecord(al.MemoryRecord[i])
               break
            end
            if i == al.Count-1 and midstart then
               --print("end of list!")
               midstart = false
               i = 0
               --print("i=", i, " ", tostring(midstart))
            else
                i = i+1
            end
      end
end

local fstr = 'strange'

selectMemoryRecordByValue(fstr)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Sun Mar 31, 2019 2:17 pm    Post subject: Reply with quote

I've added some code to add it to the contextmenu and added it as a shortcut under Ctrl+F

You can add this to your autorun folder in CE as a .lua file and it'll be there
Code:

local function selectMemoryRecordByValue(str)
      local al = getAddressList()
      local cmr = al.SelectedRecord
      local midstart = false

      if cmr == nil then
         start = 0
      else
          midstart = true
          start = cmr.Index+1
      end
      --print("Total: ", al.Count-1)
      local i = start
      while i < al.Count do
            --print("i=", i, " ", tostring(midstart))
            if string.match(string.lower(al.MemoryRecord[i].Value), string.lower(str)) == string.lower(str) then
               al.setSelectedRecord(al.MemoryRecord[i])
               break
            end
            if i == al.Count-1 and midstart then
               --print("end of list!")
               midstart = false
               i = 0
               --print("i=", i, " ", tostring(midstart))
            else
                i = i+1
            end
      end
end

local laststr=''
local mi=createMenuItem(AddressList.PopupMenu)

mi.Caption='Find Value'
mi.Shortcut='Ctrl+F'
mi.OnClick=function(s)
  local str=inputQuery('Search Value','Enter the value to search', laststr)
  if str then
    selectMemoryRecordByValue(str)
    laststr=str
  end
end

AddressList.PopupMenu.Items.insert(0,mi)

You can probably also add a second menuitem with 'Search Next' and F3 as hotkey, and then do the same but just skip the inputquery

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

Joined: 16 Dec 2018
Posts: 41

PostPosted: Sun Mar 31, 2019 7:28 pm    Post subject: Reply with quote

Very cool =) Rather than using a second menuitem, is there a way to keep the popup window open so that you can keep clicking and running the function? This becomes more intuitive if we can change the button text from "OK" to "Find Next".
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Mon Apr 01, 2019 12:17 am    Post subject: Reply with quote

use createForm and then build it yourself with an editbox and button
_________________
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
ymiu
Cheater
Reputation: 0

Joined: 16 Dec 2018
Posts: 41

PostPosted: Mon Apr 01, 2019 2:27 pm    Post subject: Reply with quote

Spent many many hours in there before I posted. Unfortunately I ended up with more questions than answers, and a very simple form that I didn't know how to instantiate via script. I was following along with the trainer form tutorial on the wiki, but a single dissimilar example will only get me so far...

I'm sure it's me, not CE. I felt the same when tackling Java GUIs a long time back-- the only diff is Java is supremely documented, so I was able to find enough examples to get by.
Back to top
View user's profile Send private message
ericbanaa19
How do I cheat?
Reputation: 0

Joined: 02 Apr 2019
Posts: 1
Location: Sydney

PostPosted: Tue Apr 02, 2019 4:27 am    Post subject: Reply with quote

Thank you for giving this information. I really satisfied with post.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25785
Location: The netherlands

PostPosted: Wed Apr 03, 2019 12:09 am    Post subject: Reply with quote

f=createForm()
edit=createEdit(f)
ok=createButton(f)
ok.Caption='Ok';
cancel=createButton(f)
cancel.Caption='Cancel'

--add some anchors here and there to define the actual layout (or use top,left positioning)
f.autosize=true


when I have time later i'll write a proper script

_________________
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
Kairax
How do I cheat?
Reputation: 0

Joined: 06 Jan 2025
Posts: 1

PostPosted: Mon Jan 06, 2025 5:34 pm    Post subject: Reply with quote

Dark Byte wrote:
I've added some code to add it to the contextmenu and added it as a shortcut under Ctrl+F


Hi, really sorry for kinda necroposting, but your explanation and example helped me, someone who never wrote scripts, to apply it to my version of table and successfully search through table.

THANK YOU SO MUCH.
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 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