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 


Making hotkey that reverts to initial value when not pressed

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

Joined: 08 May 2017
Posts: 7
Location: I don't exist... Unfortunately

PostPosted: Wed May 10, 2017 7:41 am    Post subject: Making hotkey that reverts to initial value when not pressed Reply with quote

Essentially, I want a simple CE hotkey to change a value ( let's say gravity) to 15 then revert it to -40 once the key is no longer held down. Do I need to script this, or is there a way to do it in the CE settings. PS: I know this should be obvious but my brain is not working.
_________________
Um... Hello... Thanks for taking the time to read my pointless signature Smile
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 10

Joined: 09 Aug 2013
Posts: 326

PostPosted: Wed May 10, 2017 8:20 am    Post subject: Reply with quote

Hm.... not sure of anyway to do it without a script but the script itself is simple enough. There are of course different ways to do it but here's one using 2 hotkeys so that only the functionality is coded in the script and the actual action/values are in the hotkeys (note: the one you want to hold down should be first and the second, the one that reverts the value, doesn't need any keys set since it'll be activated by code when you release the first key of the hotkey combo)

Code:
-- code to find the hotkeys
al = getAddressList()
mr = al.getMemoryRecordByDescription("Name of record with hotkeys")
-- get hotkeys, based on position in list aka index not ID (at least fairly sure it's index)
hk = mr.Hotkey[0]

-- set a function to run the second hotkey after the first has run
-- and the first key has been released
hk.onPostHotKey = function(sender)
  timer = createTimer()
  timer.Interval = 100 -- check every 100 milliseconds
  timer.OnTimer = function(timer)
    if not isKeyPressed(hk.keys[1]) then
      sender.Owner.Hotkey[1].doHotkey()
      timer.destroy()
    end
  end
end
Back to top
View user's profile Send private message
SadrienHatesU
How do I cheat?
Reputation: 0

Joined: 08 May 2017
Posts: 7
Location: I don't exist... Unfortunately

PostPosted: Wed May 10, 2017 5:35 pm    Post subject: Reply with quote

Thanks, works perfectly XD.
_________________
Um... Hello... Thanks for taking the time to read my pointless signature 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 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