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 


CE Lua call function when stopped pressing hotkey

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Kamd
Cheater
Reputation: 1

Joined: 02 May 2018
Posts: 28

PostPosted: Sun Apr 21, 2019 7:28 pm    Post subject: CE Lua call function when stopped pressing hotkey Reply with quote

I am using CE Lua to create a hotkey for changing an addresses value. How can I also change the addresses value when I have stopped pressing the hotkey?

Example (not working):
Code:

function enableThing()
    writeString(address, "enabled")
end

function disableThing()
    writeString(address, "disabled")
end


hk1 = createHotkey(enableThing, VK_Z)
--hk1.stoppedPressing = disableThing()


bonus question: is there a way to do this in normal CE interface (can do something when hotkey pressed, but how to do something when hotkey stopped being pressed?
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Tue Apr 23, 2019 3:10 am    Post subject: Reply with quote

Use timer, check if key pressed(checkAsyncKey function) if key is pressed do action and set a variable to true (key press was pressed), add another check if key is not pressed but variable was set to true (means user no longer holds down a key but it previously did), reset variable (to false) and fire your action after key press.
Note that the variable must be defined out the function or as global.
Hope this helps, if you need any exame let me know I,ll post one when I get home.

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Apr 23, 2019 3:21 am    Post subject: Reply with quote

are you sure it's not working?
Add print commands to your hotkey and check if they work or not

Is address valid?

and yes, you can do this in the ce interface. Just rightclick a memory record, and pick the set hotkey option
then create a set value hotkey

_________________
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
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