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 


Check if game is active

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
PurpleZ
How do I cheat?
Reputation: 0

Joined: 28 Nov 2022
Posts: 2

PostPosted: Mon Nov 28, 2022 6:16 am    Post subject: Check if game is active Reply with quote

Thanks for the great board it helps me many times Smile

I have wirte a Trainer for Titan Quest but if i write a code to check if the game.exe is active...

... the problem is that after open the Trainer is instantly ONLINE

With other Programs like calc.exe it works Sad only not with TQ.exe

Code:

getAutoAttachList().add("TQ.exe")
gPlaySoundOnAction=false
test.show()

local timer = createTimer(nil, false)
timer.OnTimer = function(timer)
  if OpenProcess("TQ.exe") then
    test.CELabel2.Caption = "ONLINE"
    test.CELabel2.Font.Color = clLime
  else
    test.CELabel2.Caption = "OFFLINE"
    test.CELabel2.Font.Color = clRed
  end
end
timer.Interval = 1000
timer.Enabled = true
Back to top
View user's profile Send private message
Frouk
Master Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 489
Location: mov dword ptr [Ukraine]

PostPosted: Mon Nov 28, 2022 8:22 am    Post subject: Re: Check if game is active Reply with quote

PurpleZ wrote:
Thanks for the great board it helps me many times Smile

I have wirte a Trainer for Titan Quest but if i write a code to check if the game.exe is active...

... the problem is that after open the Trainer is instantly ONLINE

With other Programs like calc.exe it works Sad only not with TQ.exe

Code:

getAutoAttachList().add("TQ.exe")
gPlaySoundOnAction=false
test.show()

local timer = createTimer(nil, false)
timer.OnTimer = function(timer)
  if OpenProcess("TQ.exe") then
    test.CELabel2.Caption = "ONLINE"
    test.CELabel2.Font.Color = clLime
  else
    test.CELabel2.Caption = "OFFLINE"
    test.CELabel2.Font.Color = clRed
  end
end
timer.Interval = 1000
timer.Enabled = true
Code:

function IsAttachedTo(procName)
  local stat = {
    ATTACH_PROCESS_NOT_DETECTED = 0,
    ATTACH_PROCESS_DETECTED = 1,
    ATTACH_PROCESS_ATTACHED = 2,
  }

  local status = GetProcessStatus(procName)

  return status == stat.ATTACH_PROCESS_ATTACHED
end

function IsAttached()
  return IsAttachedTo("GAME.exe")
end

function GetProcessStatus(procName)
  local stat = {
    ATTACH_PROCESS_NOT_DETECTED = 0,
    ATTACH_PROCESS_DETECTED = 1,
    ATTACH_PROCESS_ATTACHED = 2,
  }
  if getProcessIDFromProcessName(procName) == getOpenedProcessID() then
    return stat.ATTACH_PROCESS_ATTACHED
  elseif getProcessIDFromProcessName(procName) == 0 or getProcessIDFromProcessName(procName) == nil then
    return stat.ATTACH_PROCESS_NOT_DETECTED
  elseif getProcessIDFromProcessName(procName) ~= 0 then
    return stat.ATTACH_PROCESS_DETECTED
  end
end

function AttachTo(procName)
  local stat = {
    ATTACH_PROCESS_NOT_DETECTED = 0,
    ATTACH_PROCESS_DETECTED = 1,
    ATTACH_PROCESS_ATTACHED = 2,
  }

  local status = GetProcessStatus(procName)

  if status == stat.ATTACH_PROCESS_NOT_DETECTED then
    return false
  elseif status == stat.ATTACH_PROCESS_ATTACHED then
    return true
  elseif status == stat.ATTACH_PROCESS_DETECTED then
    openProcess(procName)
    return true
  end
end

function Attach()
  return AttachTo('GAME.exe')
end

use those functions that i made and implement it in your code

_________________
void(__cdecl *Haxing)(HWND hGameWindow)
Back to top
View user's profile Send private message
PurpleZ
How do I cheat?
Reputation: 0

Joined: 28 Nov 2022
Posts: 2

PostPosted: Mon Nov 28, 2022 9:43 am    Post subject: Reply with quote

Thanks for your help. I found the issue!

the script is looking for a process called TQ.exe

The name of the trainer is "trainer_tq.exe" the script find a process with tq.exe in the name.

i renamed my trainer and now it works :p
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 Nov 29, 2022 5:16 am    Post subject: Reply with quote

Code:

if readInteger(process)==nil then showMessage('process is closed') end

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