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 


How do I get 'specificProcess.exe' List?(Include Pid)

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

Joined: 30 Jan 2017
Posts: 13

PostPosted: Thu Feb 02, 2017 1:52 pm    Post subject: How do I get 'specificProcess.exe' List?(Include Pid) Reply with quote

I read Daspamer`s get Process List code and it`s work well
but I wish I could get specific process list
(I mean if I press "get Process" button, only "specific.exe" processes should
be on the list)

forum.cheatengine viewtopic.php?t=565851
(I can`t tag Url. I don`t know why sorry. It`s Daspamer`s code. Not mine)
Code:

f = createForm()
control_setSize(f, 400,400)
control_setCaption(f, "Process List")
setProperty(f , "BiDiMode", "bdLeftToRight")

list = createListBox(f)
x,y = control_getSize(f)
control_setSize(list, x-10, y-30)
control_setPosition(list, 5,5)

button1 = createButton(f)
button2 = createButton(f)
button3 = createButton(f)
control_setSize(button1, 80, 20)
control_setSize(button2, 80, 20)
control_setSize(button3, 80, 20)
control_setCaption(button1, "Get Processes")
control_setCaption(button2, "Clear")
control_setCaption(button3, "Attach")

control_setPosition(button1, 50,y-22)
control_setPosition(button2, 150,y-22)
control_setPosition(button3, 250,y-22)

Items = listbox_getItems(list)

TempTable = {}
function GetTheProcessList()
   local SL=createStringlist()
   getProcesslist(SL)
   for i=0,strings_getCount(SL)-1 do
      local entry = strings_getString(SL,i)
      local processname = entry:sub(10,255)
      local PID = tonumber('0x'..entry:sub(1,8))
     TempTable[i] = {PID, processname}
  end
  return TempTable
end

function AddTheProcessList()
   GetTheProcessList()
   index = 0
   for y in pairs (TempTable) do
      index = index+1
   end
   for i=0, index-1 do
      if TempTable[i]~='' and TempTable[i]~= nil then
         local TempText = "Process ID : "..TempTable[i][1].."   Process Name : "..TempTable[i][2]
         strings_add(Items, TempText)
      end
   end
end
function GetAndAddProcess()
   TempTable = {}
   strings_clear(Items)
   AddTheProcessList()
end

function Clear()
   TempTable = {}
   strings_clear(Items)
end

function AttachToTheSelectedProcess()
   local ProcessID = listbox_getItemIndex(list)
   if ProcessID~=-1 then
      if TempTable[ProcessID][1]~=nil then
         openProcess(TempTable[ProcessID][1])
      else
         return showMessage("Failed to open the select process")
      end
   else
      return showMessage("Please choose a process from the list")
   end
end

control_onClick(button1,GetAndAddProcess)
control_onClick(button2,Clear)
control_onClick(button3,AttachToTheSelectedProcess)


I tried to modified code but I couldn`t..
It`s so hard to me..
Please help


Last edited by rayshoo92 on Thu Feb 02, 2017 10:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Feb 02, 2017 6:03 pm    Post subject: Reply with quote

http://forum.cheatengine.org/viewtopic.php?t=600993&sid=492c1dbb652c2636affc67a9405d7c32

and this :

http://forum.cheatengine.org/viewtopic.php?t=602851
Back to top
View user's profile Send private message
rayshoo92
Newbie cheater
Reputation: 0

Joined: 30 Jan 2017
Posts: 13

PostPosted: Thu Feb 02, 2017 9:53 pm    Post subject: Reply with quote

Umm.. It`s so difficult to me..
maybe I have to read it very slowly..
I`m not sure I can made it.(In fact I`m not in the English-speaking country)
anyway I appreciate it. Thx!

p.s

Oh maybe there was a mistake on my word
I wish I get the specific Process "List"..
I have to fix Title on my post.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Feb 03, 2017 3:41 am    Post subject: Reply with quote

try this ct file, maybe this is like you wish if I am not misunderstood.
When trainer open, click "Open Attach" button, it will show you a "LIST" for all processes running on your computer memory.
To open one of them, just select one using your mouse and "double click" on the process name you selected and wish to open.

And i guess you not read all post from the link given above.



Attach_Browser_04_All_Process_CE6.6.CT
 Description:

Download
 Filename:  Attach_Browser_04_All_Process_CE6.6.CT
 Filesize:  2.79 KB
 Downloaded:  772 Time(s)

Back to top
View user's profile Send private message
rayshoo92
Newbie cheater
Reputation: 0

Joined: 30 Jan 2017
Posts: 13

PostPosted: Fri Feb 03, 2017 7:49 am    Post subject: Reply with quote

Thanks to post a reply
I`m sorry to bother you..
I guess my poor English makes hard to communicate. sorry..

I saw post but I couldn`t understand all yet.
(In fact I`m just lua beginner but I`m trying to understand those even now Crying or Very sad)

what I`m trying is, at your ct file, if I click "Open Attach" button,
it has to appear only "Mygame.exe" processes. Not all processess..

Hard to explain, but I have to run more than two "Mygame.exe" processes
and I wish I can control more than two processes with one trainer, depends on the situation.

Of course I can choose "Mygame.exe" on the list but I want to select that more easy
(If I can load only "Mygame.exe" list. It will much more easy to select them in the situation.)
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Feb 03, 2017 6:43 pm    Post subject: Reply with quote

If you only need a specific process name to open (e.q : game.exe) then you don't need a process list to show.

Here is code to open specific process name (+ PID). Note, the specific process name must be state inside the script.

Code:
UDF1.show()

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


game_check_list = createStringlist()

function game_check()
getProcesslist(game_check_list)
local count = 0
for i=0,game_check_list.count-1 do
if game_check_list[i]:find("firefox") then  --- change firefox to your game name
count = count + 1
end
end
if count > 1 then
UDF1.CELabel1.Caption = "Game not detected"
UDF1.CELabel1.Font.Color = 0x0000FF
beep()
else
openProcess("firefox.exe")   -- Specific Process Name input here
local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
UDF1.CELabel1.Caption = "Opened : " ..name.. " - PID : "..id
UDF1.CELabel1.Font.Color = 0x009900
end
game_check_list.clear()
end

--fl_check_t=createTimer(nil)
--timer_onTimer(fl_check_t, cecheck)
--timer_setInterval(fl_check_t, 200)
--timer_setEnabled(fl_check_t, true)


UDF1.CEButton1.onClick = game_check



TestSpecificAttach.CT
 Description:

Download
 Filename:  TestSpecificAttach.CT
 Filesize:  1.68 KB
 Downloaded:  842 Time(s)

Back to top
View user's profile Send private message
rayshoo92
Newbie cheater
Reputation: 0

Joined: 30 Jan 2017
Posts: 13

PostPosted: Sat Feb 04, 2017 12:01 am    Post subject: Reply with quote

Awesome!
I apperciate it. Thanks Corroder!
Have a nice day and Happy new year Very Happy
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Feb 07, 2017 7:53 am    Post subject: Reply with quote

Still find problem

Code:
UDF1.show()

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


game_check_list = createStringlist()

function game_check()
getProcesslist(game_check_list)
local count = 0
for i=0,game_check_list.count-1 do
if game_check_list[i]:find("firefox") then  --- change firefox to your game name
count = count + 1
end
end
if count > 1 then
UDF1.CELabel1.Caption = "Game not detected"
UDF1.CELabel1.Font.Color = 0x0000FF
beep()
else
openProcess("firefox.exe")   -- Specific Process Name input here
local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
UDF1.CELabel1.Caption = "Opened : " ..name.. " - PID : "..id
UDF1.CELabel1.Font.Color = 0x009900
end
game_check_list.clear()
end

--fl_check_t=createTimer(nil)
--timer_onTimer(fl_check_t, cecheck)
--timer_setInterval(fl_check_t, 200)
--timer_setEnabled(fl_check_t, true)


UDF1.CEButton1.onClick = game_check


Problem :
if opening "firefox.exe", the script work properly. But if :

Code:
if game_check_list[i]:find("Kingdom rush V 1.13-full") then
//..
//..
else
openProcess("Kingdom rush V 1.13-full.exe")
local id = getOpenedProcessID()
local name = getProcessNameFromID(id)
UDF1.CELabel1.Caption = "Opened : " ..name.. " - PID : "..id
//..
end


It's give error ... error to concatenate nil value "name"...
Mean "name" not identified by CE script.
What is wrong ?. Because the exe file name ?

Thanks

Note :
When try seeking manually on process list, Kingdom rush V 1.13-full.exe is exist.
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