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 


executeCodeLocalEx pointer to variable

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Sun May 31, 2020 1:18 pm    Post subject: executeCodeLocalEx pointer to variable Reply with quote

ok i tried using executeCodeLocalEx

but im stuck on pointer to variable in lua
ill just use GetWindowThreadProcessId as example

in c++
Code:

   HWND hwnd = FindWindowA(0, "Task Manager");
   DWORD pid;
   GetWindowThreadProcessId(hwnd, &pid);
   cout << pid;


c++ code works perfectly

but how in lua i tried this code and not work

Code:
local hwnd = executeCodeLocalEx("FindWindowA",0,"Task Manager")
local pid = 0
executeCodeLocalEx("GetWindowThreadProcessId",hwnd,pid)
print(pid)


how can i pointer to variable in lua?

i know i can use getWindowProcessID function but i want it on executeCodeLocalEx

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1247

PostPosted: Sun May 31, 2020 4:19 pm    Post subject: Reply with quote

FreeER wrote:
Presumably calling setMousePos(x,y) inside the OnTimer function would work.

Though if you're really worried about people messing with it then you'll probably need to worry about them pressing the power button to reset it once they realize they can't use the mouse, not sure how to handle that (especially holding down the power) but...also for older children they'll probably eventually figure out which key toggles it so you might want to use inputQuery to ask for a password and stringToMD5String to generate a hash from the input to compare to one saved in the script (that way they can't simply find the script and read the password, all they get is the hash).

Over time you may also need to worry about someone opening a command prompt or something that might let them cancel the script by killing CE, if you can open something on top of where the mouse is clicking then it'd keep the focus because the mouse is constantly clicking on it. Using the win api SetForegroundWindow may help with that, example usage

Code:
local hwnd = findWindow(nil, '... - VLC media player') -- I was watching a movie lol
if hwnd ~= 0 and getForegroundWindow() ~= hwnd then -- found window and not foreground
  local success = executeCodeLocal('SetForegroundWindow',hwnd) ~= 0
end


Ultimately it depends on just how far you want to go, it's possible that other programs already exist that might help, though I haven't done any google searches to find out Smile



local hwnd = findWindow(nil, 'Games_Code1') -- I was watching a movie lol
if hwnd ~= 0 and getForegroundWindow() ~= hwnd then -- found window and not foreground
local success = executeCodeLocal('SetForegroundWindow',hwnd) ~= 0
end



ForeG.PNG
 Description:
 Filesize:  26.26 KB
 Viewed:  1911 Time(s)

ForeG.PNG



_________________
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
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Jun 01, 2020 12:16 am    Post subject: Reply with quote

Use a memorystream and give the memory pointer to executecodelocalex
_________________
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
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Mon Jun 01, 2020 3:21 am    Post subject: Reply with quote

Dark Byte wrote:
Use a memorystream and give the memory pointer to executecodelocalex


i wonder how its work using memorystream, can you give me an example?

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Mon Jun 01, 2020 3:29 am    Post subject: Reply with quote

look at https://forum.cheatengine.org/viewtopic.php?t=614401

getDriverList() uses executecodelocalex with pointers

_________________
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
Lynxz Gaming
Expert Cheater
Reputation: 4

Joined: 01 Jul 2017
Posts: 208
Location: help

PostPosted: Mon Jun 01, 2020 7:45 am    Post subject: Reply with quote

Dark Byte wrote:
look at https://forum.cheatengine.org/viewtopic.php?t=614401

getDriverList() uses executecodelocalex with pointers

Thank you it worked perfectly

here is the finished code for somebody who needs

Code:
local hwnd = executeCodeLocalEx("FindWindowA",0,"Task Manager")
local pid = createMemoryStream()
pid.writeDword(0)
executeCodeLocalEx("GetWindowThreadProcessId",hwnd,pid.Memory)
print(readIntegerLocal(pid.Memory))

_________________
my english is bad
discord : rynx#9828
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon Jun 01, 2020 6:23 pm    Post subject: Reply with quote

Lynxz Gaming wrote:


here is the finished code for somebody who needs



Note:
This will return PID only when the window handle is active on the screen and the window caption/title have the correct syntax.

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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