View previous topic :: View next topic |
Author |
Message |
octvber How do I cheat? Reputation: 0
Joined: 15 Jan 2023 Posts: 1
|
Posted: Sun Jan 15, 2023 11:49 pm Post subject: How do I add a while holding key to activate this script? |
|
|
{$Lua}
if syntaxcheck then return end
[ENABLE]
superLuaAutoClickForTriggerbot_thread = createNativeThread(function (thread)
thread.freeOnTerminate(false)
thread.Name = 'superLuaAutoClickForTriggerbot_thread'
local crshair
while not thread.Terminated do
local crshair = readInteger('2130B3B4888')
if crshair == 1 then
mouse_event(MOUSEEVENTF_LEFTDOWN)
sleep(10)
mouse_event(MOUSEEVENTF_LEFTUP)
end
sleep(10)
end
end)
[DISABLE]
if superLuaAutoClickForTriggerbot_thread then -- kill thread
superLuaAutoClickForTriggerbot_thread.terminate()
superLuaAutoClickForTriggerbot_thread.waitfor()
superLuaAutoClickForTriggerbot_thread.destroy()
superLuaAutoClickForTriggerbot_thread=nil
end
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 140
Joined: 06 Jul 2014 Posts: 4289
|
Posted: Mon Jan 16, 2023 1:37 am Post subject: |
|
|
You only want that code running while a key is being held down?
Set a hotkey to enable the script (not toggle, only enable). In the thread, check to see if the key is still being pressed. If not, disable the script. There's a `memrec` variable defined by CE similar to the `syntaxcheck` variable. You probably need to disable it from the main thread, so use synchronize(...)
It might be simpler to forego an AA script entirely. Create the thread once in the main Lua script. If the particular key is being held down, run the existing code for the thread; if it's not held down, sleep a little longer (hotkey poll interval).
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Frouk Master Cheater Reputation: 5
Joined: 22 Jun 2021 Posts: 489 Location: mov dword ptr [Ukraine]
|
Posted: Mon Jan 16, 2023 2:24 am Post subject: |
|
|
maybe better use timer than while in thread, while true may cause bigger CPU usage, or just set sleep function to 20 or 50, so it won't take any performance
_________________
void(__cdecl *Haxing)(HWND hGameWindow) |
|
Back to top |
|
|
Chuck1982 How do I cheat? Reputation: 0
Joined: 23 Jan 2023 Posts: 8
|
Posted: Fri Jan 27, 2023 8:51 am Post subject: |
|
|
Frouk wrote: | maybe better use timer than while in thread, while true may cause bigger CPU usage, or just set sleep function to 20 or 50, so it won't take any performance |
Use the while loop for the key event being down, but inside that loop set a sleep so the CPU doesn't get hammered, maybe?
|
|
Back to top |
|
|
++METHOS I post too much Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Fri Jan 27, 2023 10:43 am Post subject: |
|
|
CE now supports 'while pressed' functionality for hotkeys.
|
|
Back to top |
|
|
|