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 


MemoryRecord.beginUpdate

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Csimbi
I post too much
Reputation: 92

Joined: 14 Jul 2007
Posts: 3102

PostPosted: Mon Oct 03, 2022 7:41 am    Post subject: MemoryRecord.beginUpdate Reply with quote

Hi all,
The MemoryRecord class does not appear to have a beginUpdate method.
I wonder how to add 100s of MemoryRecords (having a few child memrecs) and prevent UI updates while the LUA script is running (to prevent updating the address list while working on it).

Any ideas/workarounds?

Thank you!
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Mon Oct 03, 2022 12:07 pm    Post subject: Reply with quote

You could try calling beginUpdate on the backing treeview, but I'm not sure how reentrency comes into play if CE calls that as well.

Maybe instead of creating and destroying memrecs all the time, you could create them once and hide / show them as needed.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 92

Joined: 14 Jul 2007
Posts: 3102

PostPosted: Tue Oct 04, 2022 3:51 am    Post subject: Reply with quote

Thank you for the response!

How would I find the underlying treeview object (of the memoryrecord)?

The second it a good idea, but the list is dynamic - could be 100, 200, 500,1000 entries. I want to build it to exactly as long as it needs to be.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Tue Oct 04, 2022 10:37 am    Post subject: Reply with quote

Code:
local control

for i = 0, AddressList.ControlCount - 1 do
  local c = AddressList.Control[i]
  if c.ClassName == 'TTreeviewWithScroll' then
    control = c
    break
  end
end

assert(control, 'AddressList treeview not found')

Another alternative would be to have a script in the address list simply show / hide a form that you control as you see fit. This would be more complicated to code but might look better.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Oct 04, 2022 11:40 am    Post subject: Reply with quote

AddressList.List might work as well
_________________
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
Csimbi
I post too much
Reputation: 92

Joined: 14 Jul 2007
Posts: 3102

PostPosted: Tue Oct 04, 2022 12:27 pm    Post subject: Reply with quote

I copy-pasted your code and added the begin and endUpdate calls:
Code:
local control

for i = 0, AddressList.ControlCount - 1 do
  local c = AddressList.Control[i]
  if c.ClassName == 'TTreeviewWithScroll' then
    control = c
    break
  end
end

--assert(control, 'AddressList treeview not found'); not needed, we can still run.

if control and control~=nil then
   control.beginUpdate()
end

...

if control and control~=nil then
   control.endUpdate()
end


Well, wow, just wow.
The list was usually built in 5-7 seconds.
With this change, it's done in half a sec!

Thank you, much appreciated!

Note to self: code yields access violation when executed asych
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Tue Oct 04, 2022 1:38 pm    Post subject: Reply with quote

Dark Byte wrote:
AddressList.List might work as well
I thought I checked that before, but it seems I forgot. This works for me.

Csimbi wrote:
Note to self: code yields access violation when executed asych
Any access to the GUI must be done through the main thread.
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Oct 04, 2022 1:41 pm    Post subject: Reply with quote

you can use
Code:

local somelocalthreadvars

synchronize(function()
  --gui code that can access somelocalthreadvars and other upvalues
end)

Just keep in mind that the code inside synchronize runs inside the main thread, so do not enter infinite/long loops
Best way of using this is build a list of data, and then synchronize it.
Perhaps not all at once, but in small blocks so the GUI keeps responsive

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

Joined: 14 Jul 2007
Posts: 3102

PostPosted: Wed Oct 05, 2022 1:12 am    Post subject: Reply with quote

Thank you, both!
I'll toy with these ideas.

DB,
I am not sure what you mean by using AddressList.List - the AddressList control does not seem to have a beginUpdate method.
Do you mean that AddressList.List is actually the TreeView object?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Wed Oct 05, 2022 10:27 am    Post subject: Reply with quote

`AddressList.List` is the treeview the address list uses to display information. It basically replaces the few lines of code I wrote to find the treeview. i.e.:
Code:
AddressList.List.beginUpdate()

...

AddressList.List.endUpdate()

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 92

Joined: 14 Jul 2007
Posts: 3102

PostPosted: Wed Oct 05, 2022 10:42 am    Post subject: Reply with quote

Neat, 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