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 


Hotkey on key press?

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

Joined: 17 Apr 2021
Posts: 1

PostPosted: Sat Apr 17, 2021 9:51 am    Post subject: Hotkey on key press? Reply with quote

Hotkeys created with createHotkey() run over and over on an interval as long as the associated key is held.

I know I can change that interval but that's not good enough for me, what I need is a hotkey that will run exactly once for every single distinct press of the key, and I haven't been able to find how to achieve that.

Here's something hacky I've tried that kinda works, but I'd like a proper solution.
Code:
HotkeyDict = {}
function CustomHotkey(func, hotkey)
    local timer = createTimer(MainForm, false)
    timer.Interval = 20
    timer.OnTimer = function(t)
        if not isKeyPressed(hotkey) then
            t.Enabled = false
        end
    end

    HotkeyDict[hotkey] = timer

    createHotkey(function()
        if not HotkeyDict[hotkey].Enabled then
            HotkeyDict[hotkey].Enabled = true
            func()
        end
    end, hotkey)
end
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat Apr 17, 2021 10:27 am    Post subject: Reply with quote

Try @mgr.inz.Player script, https://forum.cheatengine.org/viewtopic.php?p=5679193#5679193

In case that it feels a bit 'slow', you can reduce the TC delta to ~130 (from 200), and delay between activation to 1 (from 10), https://forum.cheatengine.org/viewtopic.php?p=5767813#5767813l.

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Sat Apr 17, 2021 11:01 am    Post subject: Reply with quote

next version (7.3) retriggers a hotkey if you release the hotkey before DelayBetweenActivate is reached and then pressed again. So if you set it to a very high interval it will act the way you wish
_________________
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