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 


How to remove a hotkey in lua?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Tue Jan 24, 2017 6:22 pm    Post subject: Reply with quote

ner0 wrote:
mgr.inz.Player wrote:
I think you can keep the switch. It won't break anything.

Ok, yeah it shouldn't be a problem.
Although this doesn't seem to be as consistent as expected... if I spam the hot key several times and stop, then the next time I press the hotkey it'll execute the function 3 times in a row. I have the hotkey delay set at 500ms and yet this will happen nonetheless. Not if I don't spam the hotkey though, weird...

EDIT: Nevermind, it's cheat engine that behaves weirdly after a few... closing CE and reopening goes away with the weirdness.


If you execute this line few times:
Code:
myHotkey = createHotkey(runMe, VK_END)

It will create few hotkeys.





If you are debugging your code and you click "execute" few times, this will prevent creating new ones.
Code:
if myHotkey==nil then myHotkey = createHotkey(runMe, VK_END) end
myHotkey.OnHotkey = runMe
myHotkey.setKeys(VK_END)

_________________
Back to top
View user's profile Send private message MSN Messenger
ner0
Cheater
Reputation: 0

Joined: 10 Dec 2011
Posts: 32

PostPosted: Tue Jan 24, 2017 6:30 pm    Post subject: Reply with quote

mgr.inz.Player wrote:

If you execute this line few times:
Code:
myHotkey = createHotkey(runMe, VK_END)

It will create few hotkeys.

If you are debugging your code and you click "execute" few times, this will prevent creating new ones.
Code:
if myHotkey==nil then myHotkey = createHotkey(runMe, VK_END) end
myHotkey.OnHotkey = runMe
myHotkey.setKeys(VK_END)


The createHotkey is outside any function, which I would think would only run once at runtime, beside the problem only seems to appear if I spam the function more than 4 or 5 times in a row.

In any case, thanks for the hint, I'll make sure that it does not spawn more than one hotkey from the same line. By the way, do you think that this approach would work as well as your suggestion:

Code:
if not myHotkey then myHotkey = createHotkey(runMe, VK_END) end


Thanks again for all the help!
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 Lua Scripting All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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