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 


Detect when process closes

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Foxculated
Newbie cheater
Reputation: 0

Joined: 26 Mar 2020
Posts: 11

PostPosted: Sat Apr 04, 2020 4:46 am    Post subject: Detect when process closes Reply with quote

Hey there, i just wondered is there any simple way to detect whenever a process is closed, and then automatically closeCE()?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Sat Apr 04, 2020 6:28 am    Post subject: Reply with quote

in a timer
Code:

if readInteger(process)==nil then closeCE() end

of course only run the timer after opening a process

_________________
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
Foxculated
Newbie cheater
Reputation: 0

Joined: 26 Mar 2020
Posts: 11

PostPosted: Sat Apr 04, 2020 6:40 am    Post subject: Reply with quote

Dark Byte wrote:
in a timer
Code:

if readInteger(process)==nil then closeCE() end

of course only run the timer after opening a process


A timer is lagging the form, is there any other ways?
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

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

PostPosted: Sat Apr 04, 2020 6:58 am    Post subject: Reply with quote

Foxculated wrote:
Dark Byte wrote:
in a timer
Code:

if readInteger(process)==nil then closeCE() end

of course only run the timer after opening a process


A timer is lagging the form, is there any other ways?

What interval are you using. 2000ms should be enough.


If you have animations (or other moving stuff) in the form and you do not like micro-freezes every 2000ms, you can use a thread.

_________________
Back to top
View user's profile Send private message MSN Messenger
Foxculated
Newbie cheater
Reputation: 0

Joined: 26 Mar 2020
Posts: 11

PostPosted: Sat Apr 04, 2020 7:31 am    Post subject: Reply with quote

[quote="Foxculated"]
Dark Byte wrote:
in a timer
Code:

if readInteger(process)==nil then closeCE() end

of course only run the timer after opening a process


Im a bit newbie in cheat engine , so i will ask for help again, will the code look something like this?

EDIT: got it to work.

Code:

if getProcessIDFromProcessName("cheatengine.exe") ~= nil then
    object_destroy(timer)
    readInteger(process)==nil then closeCE() end
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

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

PostPosted: Sat Apr 04, 2020 8:42 am    Post subject: Reply with quote

Foxculated wrote:
EDIT: got it to work.

Code:

if getProcessIDFromProcessName("cheatengine.exe") ~= nil then
    object_destroy(timer)
    readInteger(process)==nil then closeCE() end

Do not know how this is working for you.

For automatic CE close when attached process no longer exists, you have to use timer or thread. here example with timer object:

Code:
function detectProcessClosedTimerFunc(timer)
  local result = readInteger(process)
  if result==nil then closeCE() end
end


--define OnProcessOpened function. It gets called after process is opened
MainForm.OnProcessOpened = function (processID,processhandle,processHexID_processName)

  if detectProcessClosedTimer==nil then -- create only one timer object (just in case user opens process again)
    detectProcessClosedTimer = createTimer(MainForm)
    detectProcessClosedTimer.Interval = 500
    detectProcessClosedTimer.OnTimer = detectProcessClosedTimerFunc
  end

end

_________________
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 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