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 


Some issues with creating Hotkey

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

Joined: 13 Sep 2018
Posts: 197

PostPosted: Sat Mar 08, 2025 2:31 am    Post subject: Some issues with creating Hotkey Reply with quote

Is there no opposite release function for creating Hotkey
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 467

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

PostPosted: Sat Mar 08, 2025 4:58 am    Post subject: Reply with quote

destroy the 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
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 197

PostPosted: Thu Mar 13, 2025 1:27 am    Post subject: Reply with quote

Dark Byte wrote:
destroy the hotkey
Indeed, I have already tried. But I always feel that this hotkey seems a bit delayed, even if DelayBetweenActivate=0, it feels slow, and if I keep holding down the hotkey, it will keep triggering. Is there a type that only listens and presses without popping up?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 467

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

PostPosted: Thu Mar 13, 2025 3:42 am    Post subject: Reply with quote

call setGlobalKeyPollInterval with a value like 10

and DelayBetweenActivate=0 means it takes the default repeat delay interval , which you can set with setGlobalDelayBetweenHotkeyActivation

_________________
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
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1465

PostPosted: Thu Mar 13, 2025 8:41 am    Post subject: Reply with quote

Make all the shortcut key functions the same in your code (do not use Delay or sleep()), add the following code to your script and only write the keys you want to control in the "keys" table.

Test the code with its current state, press "F4, F8, F9" keys, hold them down and release them.
This way you will understand the main idea of ​​the code.

(Edit this table in the code and replace it with your own keys that you use in the script.
keys = {VK_F4, VK_F8, VK_F9} )

Code:
local keys = {VK_F4, VK_F8, VK_F9} -- List of keys to monitor
local key_states = {} -- Table to track the states of the keys
for _, key in ipairs(keys) do
    key_states[key] = 1 -- Initially set all keys to state 1 (up)
end

function timer_func()
    for _, key in ipairs(keys) do
        if key_states[key] == 1 then
            if isKeyPressed(key) then
                key_states[key] = 2
                print("Key pressed: " .. key)
            end
        elseif key_states[key] == 2 then
            if not isKeyPressed(key) then
                key_states[key] = 1
                print("Key released: " .. key)
            end
        end
    end

    -- Trigger garbage collection to manage memory usage
    collectgarbage("step")
end

-- Start the timer
if timer then timer.destroy() timer = nil end
timer = createTimer(nil, false) -- Create the timer
timer.setInterval(50)           -- Execute every 50 milliseconds
timer.onTimer = timer_func      -- Assign the timer function
timer.enabled = true            -- Enable the timer

_________________
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
.lua
Expert Cheater
Reputation: 1

Joined: 13 Sep 2018
Posts: 197

PostPosted: Thu Mar 13, 2025 11:07 am    Post subject: Reply with quote

AylinCE wrote:
Make all the shortcut key functions the same in your code (do not use Delay or sleep()), add the following code to your script and only write the keys you want to control in the "keys" table.

Test the code with its current state, press "F4, F8, F9" keys, hold them down and release them.
This way you will understand the main idea of ​​the code.
The code you provided is very useful, thank you very much, but it seems that F9 or F10 is not ideal
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 34

Joined: 16 Feb 2017
Posts: 1465

PostPosted: Thu Mar 13, 2025 2:20 pm    Post subject: Reply with quote

.lua wrote:
The code you provided is very useful, thank you very much, but it seems that F9 or F10 is not ideal


Smile Very Happy You type the key you want there to test it.

As a result, you need to replace the keys in the script and update the keypad with your own keys.

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