View previous topic :: View next topic |
Author |
Message |
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Mar 13, 2014 2:46 pm Post subject: [SCRIPT] Hotkeys (Actually hotkeys*). |
|
|
Well,
I'm pretty sure that many of the people who used the C.E hotkey (when it comes to scripting) ain't so great, because it repeats the function when user holds the key...
So I wrote a simple script that should allow you to have an actual hotkey.
This script only allows to insert 1 key*, if anyone needs more, you may feel free to make it .
Script :
Code: | local hotkeys = {Keys = {}; Status = {};};
hotkeys.AddHotKey = function (hotkey,func)
if (not hotkeys.Keys[hotkey]) then
hotkeys.Keys[hotkey] = {};
end
hotkeys.Keys[hotkey][#hotkeys.Keys[hotkey]+1] = {};
local Table = hotkeys.Keys[hotkey][#hotkeys.Keys[hotkey]]
Table.func = func
Table.enabled = true
Table.destroy = function () Table.enabled = nil; Table.func = nil; Table.destroy = nil; end;
return Table
end
createNativeThread( -- This might not be the best idea, but I do enjoy having an instant response, so this method works pretty great.
function (self)
while 1==1 do
for hotkey,tablehotkey in pairs(hotkeys.Keys) do
if ((not hotkeys.Status[hotkey]) and isKeyPressed(hotkey)) then
hotkeys.Status[hotkey] = true;
for k,tab in pairs(tablehotkey) do
if (tab.enabled and tab.func) then
tab.func();
end
end
elseif (not(isKeyPressed(hotkey))) then
hotkeys.Status[hotkey] = false;
end
end
end
end)
createHotkey = hotkeys.AddHotKey -- (First parameter is key, second parameter is function) |
Usage (Example):
Code: | Hotkey1 = createHotkey(VK_UP, function () print(2) end); -- When pressing VK_UP it'll call the function which will print 2.
Hotkey1.enabled = true; -- Prevents from executing the function but does destroy the hotkey.
Hotkey1.destroy(); -- Destroys hotkey (Sort of, to be accurate it just removes the key, the function and the destroy function.. basically nilling it, but Hotkey1 will remain as a 'table' |
Dark byte, it'll be awesome if you'll add it to the next C.E version (With multiply hotkeys options of course ).
Anyway guys, happy cheating!
_________________
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Thu Mar 13, 2014 7:33 pm Post subject: |
|
|
By default CE has "Delay between reactivating hotkeys" set to 100 milliseconds. I usually change that value to 200 or 300. You can change that in CE Settings: "Cheat Engine settings -> Hotkeys"
Or, you can use Lua function: setGlobalDelayBetweenHotkeyActivation
e.g.
Code: | setGlobalDelayBetweenHotkeyActivation(200) |
This override delay value we see in CE settings. This setting is not saved in the registry.
You can use it for trainers.
You can also change delay for every created hotkey individually. There is DelayBetweenActivate property.
e.g.
Code: | hk1 = createHotkey(enableCheat0, VK_F1)
hk1.DelayBetweenActivate = 400 |
That way we can prevent disabling cheat accidentally (when we wanted to just enable it).
Edit:
typo
_________________
Last edited by mgr.inz.Player on Sun Jun 26, 2016 2:11 pm; edited 1 time in total |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jun 26, 2016 2:11 pm Post subject: "non repeating" hotkeys |
|
|
"non repeating" hotkeys:
Code: | function createNonRepHotkey(func, ...)
local getTickCount=getTickCount
local lastTickCount=0
local function changedBehaviour (sender)
local TC = getTickCount()
--call orig func when elap is bigger than 200ms
if (TC - lastTickCount)>200 then func(sender) end
lastTickCount = TC
end
local hk = createHotkey(changedBehaviour, ...)
hk.DelayBetweenActivate = 10
return hk
end |
Usage is the same as normal hotkey:
Code: | function hotkey1func()
print('hotkey1')
end
hotkey1 = createNonRepHotkey(hotkey1func, VK_F2, VK_LCONTROL) |
_________________
|
|
Back to top |
|
|
Dsilencio How do I cheat? Reputation: 0
Joined: 26 Sep 2019 Posts: 6
|
Posted: Sat Sep 28, 2019 8:06 am Post subject: Programing |
|
|
I have a code AutoHotKey and I want to make it auto-assemble in Cheat Engine, how would it auto-assemble this code?
x::
loop {
send {1 DOWN}
sleep, 100
send {1 UP}
}
Return
I'm not interested in activating the script by pressing "X" I can enable and disable it by [ENABLE] //activated
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
|
Back to top |
|
|
|