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 


Passing parameters to .CT

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

Joined: 17 Sep 2023
Posts: 1

PostPosted: Sun Sep 17, 2023 6:05 am    Post subject: Passing parameters to .CT Reply with quote

Hi guys! Very Happy

I'm trying to pass parameters to my .CT file, executed by autoit.

That's the file:

Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="45">
  <Files>
    <asd.CT Encoding="Ascii85">Long string here</asd.CT>
  </Files>
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>pid = argv[1]
  print(pid)
openProcess(pid)
local dllPath = "MyDLL.dll"
injectDLL(dllPath)
closeCE()
</LuaScript>
</CheatTable>



And then i call it via AutoIt with this:
Code:
$pid = WinGetProcess("MyProcess")
$filePath = @ScriptDir & "MyCT.CT"
   ShellExecute($filePath,$pid)



An error occurs:
Error executing this table's lua script: [string "pid = argv[1]
..."]:1: attempt to index a nil value (global 'argv')


Can someone tell me the correct way to do that?

Thank you!
-Rain
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 27

Joined: 16 Feb 2017
Posts: 1124

PostPosted: Sun Sep 17, 2023 2:36 pm    Post subject: Reply with quote

First define "argv".
I think it's a table and you should put something like this at the beginning of the script:

Code:
argv = {"chrome.exe", "opera.exe", "game.exe", "etc.exe"}
pid = argv[1]
pid2 = argv[2]

print(pid, pid2)

> chrome.exe
> opera.exe

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ParkourPenguin
I post too much
Reputation: 127

Joined: 06 Jul 2014
Posts: 3922

PostPosted: Sun Sep 17, 2023 3:23 pm    Post subject: Reply with quote

OP is talking about command line arguments. i.e. argc / argv in C

I don't know of any good way to get those. You might need to go through the windows API. See GetCommandLineW, CommandLineToArgvW, LocalFree, and maybe WideCharToMultiByte.

Can you do what you want entirely in CE?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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