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 


macro repeat help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials
View previous topic :: View next topic  
Author Message
Aprendiz
How do I cheat?
Reputation: 0

Joined: 25 Nov 2016
Posts: 7

PostPosted: Sat Dec 23, 2017 10:01 am    Post subject: macro repeat help Reply with quote

can anyone teach me how to make a macro that keeps repeating the (space bar)
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Dec 23, 2017 11:44 am    Post subject: Reply with quote

off the top of my head I think something like
Code:
while true do doKeyPress(VK_SPACE) end
would work...probably impractical though lol

Something slightly more practical would be
Code:
{$lua}
[ENABLE]
-- for key codes see defines.lua and/or https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
local enableKey = VK_F5
local disableKey = VK_F6

local macroTimer
hk = createHotkey(function(sender)
  if macroTimer then return end -- don't create a new timer if one already exists
  macroTimer = createTimer()
  macroTimer.Interval = 100
  macroTimer.OnTimer = function()
    doKeyPress(VK_SPACE)
  end
end, enableKey)
hk2 = createHotkey(function(sender)
  if macroTimer then
    macroTimer.destroy()
    macroTimer = nil
  end
end, disableKey)
[DISABLE]
hk2.onHotkey() -- call disable timer code
-- destroy hotkeys so you can't enable the timer again until script is re-enabled
hk.destroy()
hk2.destroy()
which creates 2 hotkeys, the first creates a timer which just repeatedly calls doPressKey with the code for a space, the second destroys that timer which makes it stop. When the script is disabled it stops the timer and disables the hotkeys by destroying them.

Make sure that if you have other scripts they don't also use hk and hk2, or change the names to something unique (or put them in a single global table with a unique name etc.) so that they don't get overwritten.


Last edited by FreeER on Sat Dec 23, 2017 6:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
Aprendiz
How do I cheat?
Reputation: 0

Joined: 25 Nov 2016
Posts: 7

PostPosted: Sat Dec 23, 2017 1:45 pm    Post subject: Reply with quote

FreeER wrote:
off the top of my head I think something like
Code:
while true do doKeyPress(VK_SPACE) end
would work...probably impractical though lol

Something slightly more practical would be
Code:
{$lua}
[ENABLE]
local enableKey = VK_F5
local disableKey = VK_F6

local macroTimer
hk = createHotkey(function(sender)
  if macroTimer then return end -- don't create a new timer if one already exists
  macroTimer = createTimer()
  macroTimer.Interval = 100
  macroTimer.OnTimer = function()
    doKeyPress(VK_SPACE)
  end
end, enableKey)
hk2 = createHotkey(function(sender)
  if macroTimer then
    macroTimer.destroy()
    macroTimer = nil
  end
end, disableKey)
[DISABLE]
hk2.onHotkey() -- call disable timer code
-- destroy hotkeys so you can't enable the timer again until script is re-enabled
hk.destroy()
hk2.destroy()
which creates 2 hotkeys, the first creates a timer which just repeatedly calls doPressKey with the code for a space, the second destroys that timer which makes it stop. When the script is disabled it stops the timer and disables the hotkeys by destroying them.

Make sure that if you have other scripts they don't also use hk and hk2, or change the names to something unique (or put them in a single global table with a unique name etc.) so that they don't get overwritten.






Can you teach me how to do it from the start?
and I do not know how to do it
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sat Dec 23, 2017 2:09 pm    Post subject: Reply with quote

Open the memory viewer, go to tools->auto assemble, copy and paste the code, go to file->assign to current cheat table, close the editor and enable the script.

Beyond that google a lua course online like https://www.youtube.com/watch?v=iMacxZQMPXs and learn the basics of the language, then open the celua.txt file in cheat engine's install directory and start looking at what CE makes available to you and playing around with things to see how they work. CE also has a "Lua Engine" window (memory viewer, tools->Lua Engine) that's more like the interpreted environments you'll likely see in the videos where you type one statement and execute it.

If you have any specific questions about how something works or why it works then feel free to ask those...
Back to top
View user's profile Send private message
Aprendiz
How do I cheat?
Reputation: 0

Joined: 25 Nov 2016
Posts: 7

PostPosted: Sat Dec 23, 2017 6:18 pm    Post subject: Reply with quote

it works but when I connect it in the game it gives a click so the pair works
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 Tutorials 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