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 


send key inputs at specific pointer value

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

Joined: 15 Nov 2018
Posts: 3

PostPosted: Thu Nov 15, 2018 9:01 pm    Post subject: send key inputs at specific pointer value Reply with quote

I'm trying to write a script that presses two keys at the same time when my pointer has a certain value.

For example,
If the value in pointer is 1000, send inputs a and b.

I have little scripting experience and I'm looking for the best way to do this. Lua, ahk, or another method?

The key presses need to be able to be detected by the active game window.

Any info helps
Back to top
View user's profile Send private message  
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Fri Nov 16, 2018 2:29 am    Post subject: Reply with quote

Create a timer or thread (createTimer/createThread)
in there poll the value of the pointer (AddressList.getMemoryRecordByDescription('xxx').Value)
Then if the value matches make the keys go down (keyDown(virtualkeycode) for each key)
Wait a bit for the game to pick that up (sleep for 100 ms or so)
and then release the key (keyUp(virtualkeycode))

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

Joined: 15 Nov 2018
Posts: 3

PostPosted: Fri Nov 16, 2018 11:04 am    Post subject: Reply with quote

So I have basically no experience with lua or any scripting for that matter, so this attempt probably looks silly, but this is what I manged to scrape together looking at the lua wiki.

local timer = createTimer(getMainForm())
timer.Interval = 100
timer.OnTimer = function(timer)
AddressList.getMemoryRecordByDescription('MyActiveFrames').Value)
if Value == 1000
keyDown(0x41)(0x42)
Sleep 100
keyUp (0x41)(0x42)
end

I'm sure there's things wrong with syntax, how I define the 'value' I want read, etc. Absolute beginner here Very Happy
Back to top
View user's profile Send private message  
Dark Byte
Site Admin
Reputation: 468

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

PostPosted: Sat Nov 17, 2018 5:56 am    Post subject: Reply with quote

you get the value in Value by doing
Code:

Value=tonumber(AddressList.getMemoryRecordByDescription('MyActiveFrames').Value)


to press down two keys, call keyDown twice.
so:
Code:

keyDown(0x41)
keyDown(0x42)


and same for keyUp

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

Joined: 15 Nov 2018
Posts: 3

PostPosted: Thu Nov 29, 2018 5:13 pm    Post subject: Reply with quote

Got it working, appreciate your help! Smile
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