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 


Trainer picks always the wrong process

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

Joined: 25 Feb 2016
Posts: 20

PostPosted: Sun Jul 10, 2016 3:14 am    Post subject: Trainer picks always the wrong process Reply with quote

Hi, im working on a trainer for Street Fighter V. This game shows three processes on cheat engine, the first one is the only one that works.
I always pay attention to pick this one but for some reason everytime i save as .exe or .ct or .cetrainer, i open the trainer and i see that it always picks the third process instead of the first one and of course, nothing works because of this. Im attaching a screenshot.
Is there any way to force CE to always work with the first process?
Please i need help!

Thanks in advance.

EDIT: Found a thread called "Multiple processes of the same name" and used that script but it keeps opening the third process Crying or Very sad . Anyone got a script to force ce to work with the first one? I guess its related to "function openRightProcess()"? mgr.inz.Player save me!



process1.png
 Description:
 Filesize:  20.93 KB
 Viewed:  10541 Time(s)

process1.png


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

Joined: 25 Feb 2016
Posts: 20

PostPosted: Mon Jul 11, 2016 1:16 am    Post subject: Reply with quote

Anyone?
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Mon Jul 11, 2016 1:47 am    Post subject: Reply with quote

Link the thread!
Back to top
View user's profile Send private message
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Mon Jul 11, 2016 3:45 am    Post subject: Reply with quote

Probably some Lua is needed for that because the process with the most threads is the one you want to attach the trainer to ...
Back to top
View user's profile Send private message
sfvisfun
Newbie cheater
Reputation: 0

Joined: 25 Feb 2016
Posts: 20

PostPosted: Mon Jul 11, 2016 3:50 am    Post subject: Reply with quote

cooleko wrote:
Link the thread!

http://www.cheatengine.org/forum/viewtopic.php?p=5450434&sid=a53f783a8d9451a7ee08bb40575d8070

I couldnt before because im a newbie :p.
hhhuut wrote:
Probably some Lua is needed for that because the process with the most threads is the one you want to attach the trainer to ...

Yes! I bet it could be fixed with a Lua script but i dont know exactly which one should i use:(
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Mon Jul 11, 2016 6:24 am    Post subject: Reply with quote

Code:
getProcesslist(): Returns a table with the processlist  (pid - name )

getWindowlist(): Returns a table with the windowlist (pid - window caption )

getThreadlist(List): fills a List object with the threadlist of the currently opened process. Format: %x

Couple that with the forum post you found and the previous answers, and you can solve it

I'm betting, if you copy the window name, you can also just use the window list, so that is at least three solutions (Use the linked post but set count to 1, use the threadlist to check all process of same name, once three have been checked keep the largest one, or just find the pid of the window of your game, which will be the correct process)
Back to top
View user's profile Send private message
sfvisfun
Newbie cheater
Reputation: 0

Joined: 25 Feb 2016
Posts: 20

PostPosted: Mon Jul 11, 2016 7:49 am    Post subject: Reply with quote

Hi, thanks for the reply, really appreciate it!
So i tried with the script from the other thread and CE is still opening the third process. This is what i did:
Code:
processname = 'StreetFighterV.exe'

function openRightProcess()
  local processlist=createStringlist()
  local count=0
  local entry=nil
  local name=nil

  getProcesslist(processlist)

  for i=0,strings_getCount(processlist)-1 do
    entry = strings_getString(processlist,i)
    name = entry:sub(10)
    if name == processname then count = count + 1 end
  end
  object_destroy(processlist)

  if count==1 then
    timer_setEnabled(timer1,false)
    openProcess(processname)
  end

end

if timer1~=nil then object_destroy(timer1);timer1=nil;end --not needed in final release

timer1 = createTimer(nil,false)
timer_onTimer(timer1,openRightProcess)
timer_setInterval(timer1,1000)
timer_setEnabled(timer1,true)


Then i tried

Code:
getThreadlist(List)


And i get:

Code:
Error:getThreadlist: the provided List object is not valid

Crying or Very sad

This is the first time i try to do something with CE so please bear with me
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Mon Jul 11, 2016 6:08 pm    Post subject: Reply with quote

The list needs to be one you created


I think it is supposed to look like:
Code:

getProcesslist(processlist)
thumb through the list
  openProcess(processname)
  processname.getThreadlist(list)
  save the pid and the threadcount
end

pid is largest of the threadcounts
open the newly found process


or something similar, You can find the function in the main.lua (CE install folder) and it will tell you how to use it there (is it a method/function, etc)

I didnt look, just guessing,
Back to top
View user's profile Send private message
sfvisfun
Newbie cheater
Reputation: 0

Joined: 25 Feb 2016
Posts: 20

PostPosted: Mon Jul 11, 2016 11:35 pm    Post subject: Reply with quote

Thanks for the reply. However i get "undefined lua error" when i try.
Maybe this is just not possible to do? I found a lot of threads of people asking and explaining how to force CE to open some specific process, specially on chrome/flash but havent seen anyone trying to open the first one.
I will keep searching tho, thanks!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Tue Jul 12, 2016 3:08 am    Post subject: Reply with quote

your first script was close but instead of opening the processid, you open the processname

instead of count=count+1 just call openProcess there with the pid (as a number) and then just break out of the loop

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

Joined: 25 Feb 2016
Posts: 20

PostPosted: Tue Jul 12, 2016 7:05 am    Post subject: Reply with quote

Heya thanks for your reply! : )
So this is what i did but it doesn't work after i restart the game because the PID changes:


Code:
openProcess(tonumber(9840))

function openRightProcess()
  local processlist=createStringlist()
  local count=0
  local entry=nil
  local name=nil

  getProcesslist(processlist)

  for i=0,strings_getCount(processlist)-1 do
    entry = strings_getString(processlist,i)
    name = entry:sub(10)
    if name == processname then openProcess(tonumber(9840))
  end
  end

end
[/code]
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Tue Jul 12, 2016 7:30 am    Post subject: Reply with quote

edit: Woops, forgot to exit the loop.
Code:
function openRightProcess()
  local processlist = createStringlist()
  getProcesslist(processlist)
  local count = processlist.Count - 1
  for i = 0, count do
    local entry = processlist[i]
    local index = entry:find("-", 1, true)
    local name = entry:sub(index + 1)
    local id = entry:sub(1, index - 1)
    if name == processname then
      openProcess(tonumber(id))
      return
    end
  end
end


Last edited by Zanzer on Tue Jul 12, 2016 9:53 am; edited 1 time in total
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

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

PostPosted: Tue Jul 12, 2016 9:21 am    Post subject: This post has 1 review(s) Reply with quote

@sfvisfun, that openRightProcess in other thread is not universal. It was designed to wait for two processes and then open the last one (openProcess(name) opens last one)


Try this one:
Code:
function openRightProcess(processname,howmanyprocesses,whichprocess)

  local processlist=createStringlist()

  local timer = createTimer(nil)
  timer.Interval = 1000
  timer.OnTimer =
  function (t)
    local tmp={}
    getProcesslist(processlist)
    for i=0,processlist.Count-1 do
      if processlist[i]:sub(10):lower() == processname:lower()
        then tmp[1+#tmp]=tonumber(processlist[i]:sub(1,8),16) end
    end

    if #tmp>=howmanyprocesses then
      processlist.destroy()
      t.destroy()
      openProcess(tmp[whichprocess])
    end
  end

end


-- openRightProcess(string processname, integer howmanyprocesses, integer whichprocess)
-- howmanyprocesses = 3 means it will wait for 3 processes with the same name
-- whichprocess = 1 means first one, whichprocess = 2 means second one

openRightProcess('StreetFighterV.exe',3,1)

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

Joined: 25 Feb 2016
Posts: 20

PostPosted: Tue Jul 12, 2016 1:44 pm    Post subject: Reply with quote

Thanks a lot for the replies guys, working excellent now! You guys rock!
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 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