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 


Possible to Autorun Lua Script?

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

Joined: 25 Apr 2014
Posts: 6

PostPosted: Sat Apr 26, 2014 1:47 pm    Post subject: Possible to Autorun Lua Script? Reply with quote

Hi

Is it possible to run a Lua Script automatically when i attach a Process with Cheat Engine without clicking the "Execute script" Button?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Apr 26, 2014 2:09 pm    Post subject: Reply with quote

yes, place the lua scriopt in the autorun folder and in there hook (redefine)
Code:

function onOpenProcess(processid)

in there you can do specific things to the newly opened process.
in 6.3 I recommend creating a timer, which executes a new function on process open. That way the code will run in the main thread. (which is required for gui access)

_________________
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
Tom837
How do I cheat?
Reputation: 0

Joined: 25 Apr 2014
Posts: 6

PostPosted: Sat Apr 26, 2014 3:20 pm    Post subject: Reply with quote

Dark Byte wrote:
yes, place the lua scriopt in the autorun folder and in there hook (redefine)
Code:

function onOpenProcess(processid)

in there you can do specific things to the newly opened process.
in 6.3 I recommend creating a timer, which executes a new function on process open. That way the code will run in the main thread. (which is required for gui access)


Thank you for the fast replay.

I tryed this Method:
Code:
function onOpenProcess(processid)
   debugProcess(2)
end


I wanna attach the Debugger at openprocess but Cheat Engine is crashing.
Like you said i have probably to add a Timer for that but unfortunately i dont rly know how exactly i should do this.

I would apprecciate a Code Sample.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sat Apr 26, 2014 3:55 pm    Post subject: Reply with quote

something like this:
Code:

function dostuff(sender)
  sender.destroy()
  debugProcess(2)
end

originalOnOpenProcess=onOpenProcess;

function onOpenProcess(processid)
  t=createTimer(nil)
  t.OnTimer=dostuff
  t.Interval=1
  t.Enabled=true

  if originalOnOpenProcess~=nil then
    originalOnOpenProcess(processid)
  end
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
Tom837
How do I cheat?
Reputation: 0

Joined: 25 Apr 2014
Posts: 6

PostPosted: Sat Apr 26, 2014 5:32 pm    Post subject: Reply with quote

Thank you very much Dark Byte, your sample works perfect.
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