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 


[HELP] Return Process name+PID LUA

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

Joined: 17 May 2016
Posts: 95
Location: orderandhacks

PostPosted: Mon Nov 21, 2016 9:03 pm    Post subject: [HELP] Return Process name+PID LUA Reply with quote

I'm wondering how I could return the process name and the current PID with my trainer i also would like to know how to make a text which says "Game Not Detected" then switching once connected to game to "Game Detected"

is there any way to change the color of the text so the color changes from white to red when connected?

_________________
Another Day, Another Hack.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Nov 21, 2016 9:33 pm    Post subject: Reply with quote

Code:
function getProcessNameFromID(processId)
  local processName = nil
  local list = createStringlist()
  getProcesslist(list)
  for i = 0, list.Count-1 do
    local id, name = list.String[i]:match("(.*)-(.*)")
    if processId == tonumber(id, 16) then
      processName = name
      break
    end
  end
  return processName
end
local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
print(name)

Code:
if readInteger("game.exe") == nil then
  UDF1.CELabel1.Caption = "Game Not Detected"
  UDF1.CELabel1.Font.Color = 0x0000FF
else
  UDF1.CELabel1.Caption = "Game Detected"
  UDF1.CELabel1.Font.Color = 0x009900
end

Code:
function onOpenProcess(processId)
  local name = getProcessNameFromID(processId)
  UDF1.CELabel1.Caption = "Detected " .. name
end
Back to top
View user's profile Send private message
johnkittz
Advanced Cheater
Reputation: 0

Joined: 17 May 2016
Posts: 95
Location: orderandhacks

PostPosted: Mon Nov 21, 2016 10:05 pm    Post subject: Reply with quote

Zanzer wrote:
Code:
function getProcessNameFromID(processId)
  local processName = nil
  local list = createStringlist()
  getProcesslist(list)
  for i = 0, list.Count-1 do
    local id, name = list.String[i]:match("(.*)-(.*)")
    if processId == tonumber(id, 16) then
      processName = name
      break
    end
  end
  return processName
end
local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
print(name)

Code:
if readInteger("game.exe") == nil then
  UDF1.CELabel1.Caption = "Game Not Detected"
  UDF1.CELabel1.Font.Color = 0x0000FF
else
  UDF1.CELabel1.Caption = "Game Detected"
  UDF1.CELabel1.Font.Color = 0x009900
end

Code:
function onOpenProcess(processId)
  local name = getProcessNameFromID(processId)
  UDF1.CELabel1.Caption = "Detected " .. name
end

Nice! It works! now im just wondering how to return the PID

_________________
Another Day, Another Hack.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Mon Nov 21, 2016 10:07 pm    Post subject: Reply with quote

Code:
local id = getOpenedProcessID()
Back to top
View user's profile Send private message
johnkittz
Advanced Cheater
Reputation: 0

Joined: 17 May 2016
Posts: 95
Location: orderandhacks

PostPosted: Tue Nov 22, 2016 2:11 am    Post subject: Reply with quote

Zanzer wrote:
Code:
local id = getOpenedProcessID()


Thanks so much for the code man! You'll definitely be credited in my trainer!

_________________
Another Day, Another Hack.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
johnkittz
Advanced Cheater
Reputation: 0

Joined: 17 May 2016
Posts: 95
Location: orderandhacks

PostPosted: Tue Nov 22, 2016 11:39 pm    Post subject: Reply with quote

this wont work inside a exe trainer it remains red and showing not detected even when attached
_________________
Another Day, Another Hack.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Wed Nov 23, 2016 5:03 am    Post subject: Reply with quote

did you rename the onOpenProcess function to something else?

Or did you remove the getAutoAttachList().add( ... line from your trainer ?

Also, this code works as well
Code:

name=getProcessList()[processId]

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

Joined: 17 May 2016
Posts: 95
Location: orderandhacks

PostPosted: Wed Nov 23, 2016 12:06 pm    Post subject: Reply with quote

No didn't remove ANY lines from my trainer should I remove the AutoAttach line? Or rename OnOpenProcess?
_________________
Another Day, Another Hack.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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