RunMacroText

From Warcraft Wiki
Jump to navigation Jump to search
Flavors
Links
Info
Added in 2.0.1 / 1.13.2

Executes a string as if it was a macro.

RunMacroText(macro)

Arguments

macro
string - the string is interpreted as a macro and then executed

Example

This creates an invisible button in the middle of the screen, that prints Hello World! every time it is clicked with the left button.

-- Create the macro to use
local myMacro = [=[
/run print("Hello")
/run print("World!")
]=]

-- Create the secure frame to activate the macro
local frame = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate");
frame:SetPoint("CENTER")
frame:SetSize(100, 100);
frame:SetAttribute("type", "macro") 
frame:SetAttribute("macrotext", myMacro);
frame:RegisterForClicks("LeftButtonUp");

Details

  • Macros are executed via the client repeatedly firing the EXECUTE_CHAT_LINE event.
  • The maximum macro length via this method is 1023 characters

Patch changes

Bc icon.gif Patch 2.0.1 (2006-12-05): Protected.