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 


Filtering process name list

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Feb 03, 2017 8:05 pm    Post subject: Filtering process name list Reply with quote

Hi, from this topic : http://forum.cheatengine.org/viewtopic.php?p=5716275#5716275

I try to filtering process name list :

Code:
f = createForm()
control_setSize(f, 400,400)
list = createListBox(f)

Items = listbox_getItems(list)
local name = "svchost.exe"
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()
   name = "firefox.exe"
   GetTheProcessList()
   index = 0
   for y in pairs (TempTable) do
      index = index+1
   end
   for i=0, index-1 do
     if TempTable[i][2] == name
      local TempText = "Process ID : "..TempTable[i][1].."   Process Name : "..TempTable[i][2]
         strings_add(Items, TempText)
      else
    showMessage("Game not found")
    f.hide()
    return -- TempTable
--      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


But...

Code:
//..
   name = "firefox.exe"   --- or "svchost.exe (try to listing not only one process name with same name)
   
    if TempTable[i][2] == name
      local TempText = "Process ID : "..TempTable[i][1].."   Process Name : "..TempTable[i][2]
         strings_add(Items, TempText)
      else
    showMessage("Game not found")
    f.hide()
//..
----- this nothing show as result.

-- but if
 if TempTable[i][2] ~= name
  ..
  ..

----- It's show all results except "svchost.exe"



Is there something wrong and how to fix it ?

Thanks
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Sat Feb 04, 2017 3:40 am    Post subject: Reply with quote

I might have went to far with this and this might not even be what your asking for? But still wrote it up after trying to execute the code you posted.


Select & Sort.CT
 Description:

Download
 Filename:  Select & Sort.CT
 Filesize:  1.92 KB
 Downloaded:  500 Time(s)


_________________
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Feb 04, 2017 5:13 am    Post subject: Reply with quote

Nah, akumakuja28
That is exactly what I want, with your CT file I just need add listbox Items with a specific process name I wish to open, or by your permission I can modifying your script with add a textbox to allow user manually input the specific process name wish to open and attach.

Example :
Code:
..
drop.Items.Add('svchost.exe')
..


Actually I've tried to filtering process names list for specific process name only to add to listbox before you post your CT file..


Code:
Items = listbox_getItems(list)
TempTable = {}
filterTable = {}

function GetTheProcessList()
   local SL=createStringlist()
   getProcesslist(SL)
   local filtername = "svchost.exe"
   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}
     if processname == filtername then
      filterTable[i] = {PID, processname}
      print(PID, processname); end     --- print result is good, process name has filtered
  end
   return TempTable
  --  return filterTable
end

function AddTheProcessList()   --- problem here, nothing add to listbox from filtered table
   GetTheProcessList()
   for i,v in ipairs(filterTable) do
   strings_add(Items, processname)
   end
end


That's the problem, nothing add to listbox from filtered process name table. Anyhow, I might try with reference to the existing logic in your script and try to implement it in my script.

Thanks and regard



Capture.JPG
 Description:
Output for filtered process name
 Filesize:  20.67 KB
 Viewed:  5510 Time(s)

Capture.JPG


Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Sat Feb 04, 2017 6:24 am    Post subject: Reply with quote

Go ahead and edit away thanks for asking tho. Hope it helped yah out.

Just know tht the script is far from perfect it can be simplified a bit more.

_________________
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Feb 04, 2017 6:33 am    Post subject: Reply with quote

No problem and thanks
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