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 


Close Lua Engine window automatically [Solved]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Tue Jun 16, 2020 12:20 pm    Post subject: Close Lua Engine window automatically [Solved] Reply with quote

Is it possible to close this window automatically? ( = window opened via MemViewer ~ Tools]
Reason I ask: I would like to show ('print') progress information so user knows/sees something is happening/working, while the script is doing its "thing"...
I have assumed that ShowMessage does not allow me to do that...? And just to be clear: it does not have to be the Lua Engine Window; just some [Status Window] showing - among other details - an updating counter.

ps: i already use 'GetLuaEngine().MenuItem5.doClick()' (something I found here). And actually downloaded the source to see if I could find other methods/properties... Unfortunately, not experienced enough to find more then the 'MenuItems' (and some), related to this class. I was rather looking for a 'close() ~ exit()' method...

-EDIT-
since then learned a bit (...) more about CE's gui components. I'm still using the Lua window, but now remove some elements from it (~cleaned version: hiding topMenu & bottom_lua_editor/splitter)


Last edited by paul44 on Sun Nov 29, 2020 2:03 am; edited 2 times in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

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

PostPosted: Mon Jun 22, 2020 4:53 am    Post subject: Reply with quote

Quote:
progress information so user knows/sees something is happening/working, while the script is doing its "thing"

Lua script?

_________________
Back to top
View user's profile Send private message MSN Messenger
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Mon Jun 22, 2020 11:39 am    Post subject: Show progress status... Reply with quote

^not sure if you are asking whether I could use a Lua script... or if I'm using a Lua script? Well, definitely using a Lua script.

In the mean time, I've been able to change the script in such a way that I can just use the Lua window (not so "userfriendly", but it does the job)...
Still: if anyone can point me in the right direction (winAPI perhaps/surely), I'll do the proper digging myself... F.e. can the context_text - in a Showmessage - dynamically be updated? Meaning: same popup window, with text being updated appropriately.


Tip: if your script runs a 'MemScan', which can take some considerable time (in my case between 5~15s), you can use the Lua window (w/ print()) to inform the gamer. Add following at the start of your script:

[code]
-- clears the lua window
GetLuaEngine().MenuItem5.doClick()
-- need for loop to get info print-ed...
print('\n One moment, please... processing...')
for i=0,1 do print(' ') end

print()
[/code]

(took me some experimenting to get this right...)
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

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

PostPosted: Mon Jun 22, 2020 3:46 pm    Post subject: Reply with quote

You can create form and place infos there.

Edit:
example:

Code:
function createProgressInfoWindow(title, text)
  local progressInfoWindow = createForm(false)
  progressInfoWindow.OnClose = function (sender)
                       progressInfoWindow.progress = function()end
                       progressInfoWindow.close = function()end
                       return caFree
                      end
  progressInfoWindow.setPosition(MainForm.Left+50,MainForm.Top+50)
  progressInfoWindow.Width = MainForm.Width // 2
  progressInfoWindow.Height = progressInfoWindow.Width // 2
  progressInfoWindow.Caption = title
  progressInfoWindow.PopupMode = 'pmExplicit'
  local progressbar = createProgressBar(progressInfoWindow)
  progressbar.Name = 'progressbar'
  progressbar.Align = alBottom
  local label = createLabel(progressInfoWindow)
  label.Name = 'label'
  label.AnchorSideTop.Control = progressInfoWindow
  label.AnchorSideTop.Side = asrCenter
  label.AnchorSideLeft.Control = progressInfoWindow
  label.AnchorSideLeft.Side = asrCenter
  label.Caption = text
  progressInfoWindow.progress = function (a,b) progressbar.Position=a progressbar.Max=b processMessages() end
  return progressInfoWindow
end



function yourFunctionDoingTimeConsumingStuff()

  local progressInfoWindow = createProgressInfoWindow('Info:', 'Doing heavy stuff, please wait...')
  progressInfoWindow.show()

  --your main loop
  for i=0,10000 do
    progressInfoWindow.progress(i, 10000)
    ...
    ...
    ...
  end

  progressInfoWindow.close()
  progressInfoWindow = nil



end



from documentation:
createMemScan(progressbar OPTIONAL) : Returns a new MemScan class object


So you can use this:
Code:

  local progressInfoWindow = createProgressInfoWindow('Info:', 'Doing heavy stuff, please wait...')
  progressInfoWindow.show()

  local myMemScan = createMemScan(progressInfoWindow.progressbar)
  ...
  ...
  myMemScan.waitTillDone()
  myMemScan.destroy()
  progressInfoWindow.close()
  progressInfoWindow = nil

_________________
Back to top
View user's profile Send private message MSN Messenger
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Wed Jun 24, 2020 12:59 am    Post subject: return caFree... Reply with quote

fyi: just a heads up: i'm out of the country till end of the week; but will definitely test/feedback next weekend...

quick observation: caFree? this returns what then: 0 or nil ~ of no importance...? (careFree Smile)
Back to top
View user's profile Send private message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Sun Jun 28, 2020 11:50 am    Post subject: "progress window" Reply with quote

ok, tried out your function; and it is working... as I expected. Indeed a 'progress bar', but not quite what I wanted/meant. So made some printscreens to clarify: [ https://imgur.com/a/0vZlQ8o ].

(comes from my ACS table ~ FearlessRev)
pic1: using Lua Window (print statements) to report on some mapicon info. since it can seem that CE "hangs" during that process, I just show that info during that process...
pic2: same thing; reporting on the "killthread' script, until successful (btw: it can take between 5~15s before CE returns focus to user, hence this approach ~ gamers tend to 'keep clicking the script' as they feel it is "not working" Smile)
However: I've "edited" the Lua window to what I really would like to present: just a small window/form, with a [Close] button...
ps: I crosschecked your code with the Form class (wiki pages) and noticed some additional (?!) properties/methods you are using... What is your source for these?

pic3: for readers of this topic, wondering what the 'progress bar' code actually does?


I'm changing the status to 'On hold' for the moment... The current solution is fine; but got some other stuff in the pipeline right now. Would like to know though how one could get access to a(ny) class details...?
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 199

Joined: 25 Jan 2006
Posts: 8518
Location: 127.0.0.1

PostPosted: Sun Jun 28, 2020 6:09 pm    Post subject: Reply with quote

The 'caFree' tells CE how to handle the window close event. You have the options of:
- caNone (0) - Means the form is not allowed to close; will ignore the close attempt.
- caHide (1) - Means the form is not actually closed; instead it will just be hidden.
- caFree (2) - Means the form will be closed and all allocated memory will be freed.
- caMinimize (3) - Means the form will be minimized instead of closed.

Judging by your pictures, I assume you are looping to monitor for thread creation to deal with VMProtect's anti-injection features for bypassing an anti-cheat/anti-debug setup. Which I assume you are doing via and endless loop until either a timeout is hit or the work is done.

You are hanging more than likely due to that loop holding the event handler of CE from being allowed to process new messages/data. You can attempt to use the 'processMessages' call within your loop(s) to prevent the UI from locking up. Otherwise, I'd recommend you avoid using a single loop altogether and instead use a timer or Lua's built-in coroutines. Have your code 'pulse' each tick to do its work instead of just endlessly looping.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
atom0s
Moderator
Reputation: 199

Joined: 25 Jan 2006
Posts: 8518
Location: 127.0.0.1

PostPosted: Sun Jun 28, 2020 7:37 pm    Post subject: Reply with quote

Here is a simple/small example of what I meant with using a coroutine+timer:
https://forum.cheatengine.org/viewtopic.php?t=614686

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Mon Jun 29, 2020 12:25 pm    Post subject: antidebug script... Reply with quote

As mentioned earlier, primarily been concentrating on ACS table... since #Sunbeam posted following: [ https://fearlessrevolution.com/viewtopic.php?t=9605#post-92942 ].
However, since then, he worked out a script that scans/identifies the antidebug thread; and kills it. I'm using that script now in both ACU and ACS...
While the loops are not endless - on average 50 threads to evaluate - it can still take between 5~15s before the thread in question gets killed. And thus: trying to give gamers info about "current status"...

ps: I also just noticed that the "killthread" script is not posted in that topic. If you are interested, I'll chase it down for you (or you can download my tables from FearlessRev). And obviously, credits to #Sunbeam for some grant work here!

ps2: I will look into your info... on a later date. in particular your "use the 'processMessages' call within your loop(s) to prevent the UI from locking up" caught my attention...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions 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