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 


[HELP] Creating a hotkey for toggling scripts

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
ZxPwds
Advanced Cheater
Reputation: 0

Joined: 27 Oct 2015
Posts: 59

PostPosted: Wed Jun 23, 2021 6:13 pm    Post subject: [HELP] Creating a hotkey for toggling scripts Reply with quote

Ok so I created a thread a while back where I had someone very kind enough to help me through a working hotkey
for my trainers, and for years I've been using it. But it has glitchy moments, Where It wont actually register the fact that
I am pushing ALT + [KEY] and just other things I'm not able to really explain. I was wondering if anybody had a better way
to create a hotkey and to toggle on and off an AA script.


Code:


toggleGunLock = false
function toggleGunLock()
  toggleGunLock = not toggleGunLock
  if toggleGunLock then
          playSound(findTableFile('Activate'))
          AddressList.getMemoryRecordByDescription("#GunLock").Active = true
          Form1.cheatGunLock.Font.Color=0x00ff00
  else
          AddressList.getMemoryRecordByDescription("#GunLock").Active = false
          playSound(findTableFile('Deactivate'))
          Form1.cheatGunLock.Font.Color=0xffffff
  end
end
if kGunLock and kGunLock.destroy then
kGunLock.destroy()
end
kGunLock = nil
kGunLock = createHotkey(toggleGunLock,VK_LMENU, 0x47) -- ALT + G)
kGunLock.DelayBetweenActivate = 1000



Does anybody have a way to do what I'm doing but differently?
Back to top
View user's profile Send private message
TheyCallMeTim13
Wiki Contributor
Reputation: 50

Joined: 24 Feb 2017
Posts: 976
Location: Pluto

PostPosted: Wed Jun 23, 2021 6:49 pm    Post subject: Reply with quote

Look at the "celua.txt" file in the CE directory. Look up the MemoryRecordHotkey class and MemoryRecord class. Use the MemoryRecord classes "createHotkey" instead of the generic one. This way you don't have to create a seperate thread. And can just let CE handle it, this has the added benefit of whatever CE settings they have for hotkey intervals and what not will be used. And it has properties for the things you are doing manually, like with the sound file.

EDIT:
You can use "OnPostHotkey" to update the UI.

_________________
Back to top
View user's profile Send private message Visit poster's website
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Mon Jun 28, 2021 6:57 am    Post subject: Reply with quote

I would do like this;

Code:
toggleGunLock = 0 -- or false
function toggleGunLock()

  if toggleGunLock==0 then
          playSound(findTableFile('Activate'))
          AddressList.getMemoryRecordByDescription("#GunLock").Active = true
          Form1.cheatGunLock.Font.Color=0x00ff00
         toggleGunLock=1
  else
          AddressList.getMemoryRecordByDescription("#GunLock").Active = false
          playSound(findTableFile('Deactivate'))
          Form1.cheatGunLock.Font.Color=0xffffff
         toggleGunLock=0
  end
end

if kGunLock then kGunLock.destroy() kGunLock = nil end

kGunLock = createHotkey(toggleGunLock,VK_LMENU, 0x47) -- ALT + G)
kGunLock.DelayBetweenActivate = 1000
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
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