| View previous topic :: View next topic |
| Author |
Message |
kucingkembar Advanced Cheater
Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Fri Nov 27, 2020 1:21 am Post subject: Hotkey 1 Action Only |
|
|
sorry for the title, i dont know how to describe it,
i have this code:
| Code: |
TheValue = 1
createHotkey(
function()
TheValue = TheValue + 1
print(TheValue)
end,
VK_NUMPAD0
)
|
I like when I press "Hotkey 0", TheValue will increase by 1, but the longer I press it TheValue keeps increasing, how to stopping this?,
thank you, have a nice day
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
|
| Back to top |
|
 |
kucingkembar Advanced Cheater
Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Fri Nov 27, 2020 2:46 am Post subject: |
|
|
| thanks for the reply, I studied for 30 minutes and do not do any progress, sorry for my stupidity, can you write the working code as an example?
|
|
| Back to top |
|
 |
Corroder Grandmaster Cheater Supreme
Reputation: 75
Joined: 10 Apr 2015 Posts: 1668
|
Posted: Fri Nov 27, 2020 3:43 am Post subject: |
|
|
| kucingkembar wrote: | | thanks for the reply, I studied for 30 minutes and do not do any progress, sorry for my stupidity, can you write the working code as an example? |
Alternative, use key down event.
| Code: | if f then f.destroy() end
f=createForm()
local TheValue = 1
function Form_KeyDown(sender,Key)
f.setFocus()
if Key==VK_NUMPAD0 then
TheValue=TheValue+1
print(TheValue)
end
end
f.OnKeyDown=Form_KeyDown |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
| Back to top |
|
 |
ByTransient Expert Cheater
Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Fri Nov 27, 2020 4:01 am Post subject: |
|
|
This is another example that is no different.
| Code: | setGlobalDelayBetweenHotkeyActivation(400)
TheValue = 1
createHotkey(
function()
TheValue = TheValue + 1
print(TheValue)
end,
VK_NUMPAD0
) |
|
|
| Back to top |
|
 |
kucingkembar Advanced Cheater
Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Fri Nov 27, 2020 4:47 am Post subject: |
|
|
sorry for the late reply, I just tried both codes
@DaSpamer
your code is good, but if I press faster than 400 ms, the hotkey will not be triggered, but it gives me some ideas of my other codes, thank you very much.
@Corroder your code is working as I intended, somehow I don't like when it pressed quite long it will repeat the "task", but this is the best (easiest) solution for me, thank you very much
Edit: I tried the code @Corroder, it not a hotkey, the form must activate while pressing the code
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Nov 27, 2020 8:41 am Post subject: |
|
|
How fast are you pressing?
| Code: | function createNonRepHotkey(func, ...)
local getTickCount=getTickCount
local lastTickCount=0
local function changedBehaviour (sender)
--call orig func when elap is bigger than 130ms
if (getTickCount() - lastTickCount)>130 then func(sender) end
lastTickCount = getTickCount()
end
local hk = createHotkey(changedBehaviour, ...)
hk.DelayBetweenActivate = 1
return hk
end
-- modify only this part;
function hotkey1func()
print('hotkey1')
end
hotkey1 = createNonRepHotkey(hotkey1func, VK_F2) |
If the above does not fit your needs, then this script (using threads) will for sure fit
https://forum.cheatengine.org/viewtopic.php?p=5524713#5524713
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
kucingkembar Advanced Cheater
Reputation: 0
Joined: 08 Oct 2020 Posts: 71
|
Posted: Fri Nov 27, 2020 8:53 am Post subject: |
|
|
thank you @DaSpamer, your code is working,
answer about how fast I press the button?, now I create some kind of slide. from page 1 to 20, sometimes I like to go from 1 to 12 by repeatedly press the button 11 times, or similar to that
|
|
| Back to top |
|
 |
|