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 


Creating a batch file that runs a game + Cheat Engine

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

Joined: 14 Jun 2022
Posts: 2

PostPosted: Tue Jun 14, 2022 5:13 pm    Post subject: Creating a batch file that runs a game + Cheat Engine Reply with quote

Hi, I'm trying to create a batch file that will run my game and 15 seconds later, open Cheat Engine (minimized if possible) along with a tweak/tweaks of my choices. I don't know where to begin but appreciate any help.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Jun 14, 2022 8:29 pm    Post subject: Reply with quote

I don't know if this is a right section to post this, anyhow this is an example as the topic said. at least it work.

Code:
echo off
start /b "" "C:\Windows\system32\notepad.exe"
timeout /t 15
start /min "" "C:\Program Files\Cheat Engine 7.4\Cheat Engine.exe"
exit


use notepad to write the script and save it as a batch file

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gibberishh
Cheater
Reputation: 1

Joined: 30 Aug 2021
Posts: 37

PostPosted: Wed Jun 15, 2022 4:30 am    Post subject: Reply with quote

Corroder wrote:
I don't know if this is a right section to post this, anyhow this is an example as the topic said. at least it work.

Code:
echo off
start /b "" "C:\Windows\system32\notepad.exe"
timeout /t 15
start /min "" "C:\Program Files\Cheat Engine 7.4\Cheat Engine.exe"
exit


use notepad to write the script and save it as a batch file

In the fourth line, you might be better off using this, depending on what you want to do:
Code:
start /min "" "C:\Games\My Game\Cheat Table.ct"

Use appropriate paths. This will open the cheat table instead of just opening CE.

Btw, I used to use batch files to open the game and associated cheat table. Now I simply edit the table Lua script to launch games.

Code:
local proc = "Game.exe"
function Launch()
  if not getProcessIDFromProcessName(proc) then
    if io.popen("if exist "..proc.." (echo 1)"):read() then -- looks for game exe in same folder
      shellExecute(proc) -- launches game
      sleep(1000)
    else
      messageDialog(proc.." is not available in this folder. Open the table from the same folder as the game or start the game first.",mtError,mbOK)
      return
    end
  end
  local ticks = 0
  local maxTicks = 5000 -- keeps waiting until the process is available or so many milliseconds have elapsed
  local tick = 100
  while process ~= proc and ticks < maxTicks do
    openProcess(proc)
    sleep(tick)
    ticks = ticks + tick
  end
  if process ~= proc then
    messageDialog(proc.." is not running. Game not attached.",mtError,mbOK)
    return
  else
    getAddressList().getMemoryRecord(0).Active = true -- not necessary, but this activates the first record in my table -- you can activate other records if you wish, or delete this line entirely
  end
end

Launch()

My Start Menu shortcut to the game points to the cheat table instead of the game exe.

_________________
It's not cheating. It's playing by my rules.
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Jun 15, 2022 5:16 am    Post subject: Reply with quote

gibberishh wrote:

...
My Start Menu shortcut to the game points to the cheat table instead of the game exe.


Yes, of course I will do the same thing if I am using Lua script. Btw, the first topic ask for a batch file not a Lua script or Lua function.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gibberishh
Cheater
Reputation: 1

Joined: 30 Aug 2021
Posts: 37

PostPosted: Wed Jun 15, 2022 10:06 am    Post subject: Reply with quote

Corroder wrote:

...
Yes, of course I will do the same thing if I am using Lua script. Btw, the first topic ask for a batch file not a Lua script or Lua function.

True, but they haven't specified why they want a batch script. The 15-second delay leads me to conclude (maybe incorrectly) that they are simply trying to open a game and cheat table in one click -- which was my own reason for using batch files once upon a time.

The first part of my reply does give a batch script. The Lua script is only presented as an alternative. The Lua script also addresses the following:
AJUniverse wrote:
along with a tweak/tweaks of my choices
which is much more difficult to achieve through a batch file.
_________________
It's not cheating. It's playing by my rules.
Back to top
View user's profile Send private message
AJUniverse
How do I cheat?
Reputation: 0

Joined: 14 Jun 2022
Posts: 2

PostPosted: Wed Jun 15, 2022 5:55 pm    Post subject: Reply with quote

gibberishh wrote:
Corroder wrote:

...
Yes, of course I will do the same thing if I am using Lua script. Btw, the first topic ask for a batch file not a Lua script or Lua function.

True, but they haven't specified why they want a batch script. The 15-second delay leads me to conclude (maybe incorrectly) that they are simply trying to open a game and cheat table in one click -- which was my own reason for using batch files once upon a time.

The first part of my reply does give a batch script. The Lua script is only presented as an alternative. The Lua script also addresses the following:
AJUniverse wrote:
along with a tweak/tweaks of my choices
which is much more difficult to achieve through a batch file.


Reason for the delay in cheat engine running is because the game has a 5 second splash screen before the .exe is running.

Can a Lua script be configured to open a game -> open cheat engine 13 seconds after with 3 different ct files active?
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Jun 15, 2022 11:04 pm    Post subject: Reply with quote

AJUniverse wrote:

Can a Lua script be configured to open a game -> open cheat engine 13 seconds after with 3 different ct files active?



Just an example:

Code:
app = "C:\\windows\\system32\\notepad.exe"
ct1 = "F:\\DrawArrow.CT"
ct2 = "F:\\MDIForm2.CT"
ct3 = "F:\\FloodFill_01.CT"

function launch()
 shellExecute(app)
 sleep(13000)  --- 13 seconds
 openProcess('notepad.exe')
 local pid = pid or GetOpenedProcessID()
 if pid and pid~=0 then
  shellExecute(ct1) -- open CT file 1
  sleep(1000)
  shellExecute(ct2) -- open T file 2
  sleep(1000)
  shellExecute(ct3) -- open CT file 3
  sleep(1000)
 end
end

launch()


I have no idea. anyhow if run manually, install 3 instances Cheat Engine in different folder. Something like : CE1, CE2, CE3 etc

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
gibberishh
Cheater
Reputation: 1

Joined: 30 Aug 2021
Posts: 37

PostPosted: Thu Jun 16, 2022 8:33 am    Post subject: Reply with quote

AJUniverse wrote:
Reason for the delay in cheat engine running is because the game has a 5 second splash screen before the .exe is running.

Can a Lua script be configured to open a game -> open cheat engine 13 seconds after with 3 different ct files active?

Your reasoning is correct, but conclusion is not.

You don't need to 'open' cheat engine after 13 seconds. You can open cheat engine (or table) BEFORE the game, but connect the table to the game AFTER 13 seconds.

The code I have given earlier will do exactly that. I already use this code to connect cheat tables to games with long splash screens and loading videos.

Combine it with Corroder's code to launch ct files along with the game exe.

The code should work with most tables. Some tweaks might be required for some rare tables, but I doubt it. Read through the comments in the code, change the numbers and paths as required and see if it works for you. Otherwise you always have the batch file to fall back on. Smile

Also, you don't need to install multiple instances of CE. I have CE 7.2 and have no problems opening 5-7 tables at a time.

_________________
It's not cheating. It's playing by my rules.
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