Notes about spell names and ranks
The /cast command is pretty picky when it comes to your spell name. In order for it to sucessfully cast a spell you must use correct spelling, punctuation, spacing, etc. The best way to guarantee you enter the right name is to open your spell book while writing the macro, place your cursor in the macro where the spell should be, and shift-click the spell in your spell book. This will enter the exact name of the spell including its rank like the following:
/cast Shadow Word: Pain(Rank 5)You can safely remove the (Rank 5) from the macro and it will automatically pick the highest rank--assuming you want to, of course; there are many situations where it is advantageous to use a particular rank (like specific timing on a Warlock's banish). Beware, though... Some spells with parentheses in their name may need some coddling. For example, using shift-click on a Druid's feral Faerie Fire spell produces the following macro:
/cast Faerie Fire (Feral)(Rank 2)If you remove the entire (Rank 2), the internal code that translates the spell name gets confused by (Feral) thinking it is a rank and the spell doesn't cast. You will have to change it to the following in order for it to work as expected:
/cast Faerie Fire (Feral)()The empty parentheses are seen as the rank since they're at the end. Because they're empty, the parser picks your highest rank and casts the spell. You can also use empty parentheses for other spells, but with the 255 character limit, space is definitely an issue.
How do I use an item/trinket
Simple answer: the same way you cast a spell. The command for using an item is (you guessed it) /use. Like /cast, its simplest form takes the name of the item you want to use:
/use Green MechanostriderThere are also a couple other forms of the /use command:
/use <inventory slot>
This form of use allows you to use an item in the specified slot. See http://www.wowwiki.com/InventorySlotId for a list of the slot numbers. Example:
/use 13Uses whatever is in your top trinket slot.
/use <bag> <slot>
You can also use an item in a specific bag location. Lets say you always keep the food you want to feed your pet in the first slot of your backpack. You can easily write a macro to feed your pet as follows:
/cast Feed Pet
/use 0 1Bags are numbered 0-4 from right to left (0 is always the backpack) and the slots are numbered starting at 1 going left to right, top to bottom (like reading):
1 2 3 4
5 6 7 8
3 4 5 6
7 8 9 10
...Trading risk of confusion for completeness, I'll let you know that /cast and /use function exactly the same way. /cast can use items and /use can cast spells. This isn't very useful for simple macros like you've seen so far. However, when you start dealing with macro options and sequences you'll be happy to know that you can intermingle items and spells in the same command.
Multiple actions with one click
In general, you cannot cast more than one spell with a single click of a macro. Most spells and some items trigger the global cooldown (GCD) which keeps you from taking too many actions at once. Even if a spell fails to cast, if it would trigger the GCD, it prevents subsequent /casts in the macro from running. This was not the case prior to patch 2.0 which is why you may still come across macros like the following:
/cast Mortal Strike
/cast Sunder ArmorMacros like this do not work anymore. As soon as Overpower fails to cast, the game will block all the other spells from casting as well, even though the GCD is not actually triggered.
There is a bit of good news, though. Certain spells can actually be cast at the same time in a single macro. Any spell that is instant and does not trigger the GCD can be followed by another cast ("Next Melee" abilities like Heroic Strike fall under this category too). The spell's tooltip will tell you if it's instant, but you have to use the spell (or check a spell database site like thottbot.com) to know if it triggers the GCD.
Until patch 2.3 you must to place a /stopcasting command after the instant, non-GCD spells (but not items). The game engine assumes that after the first /cast is attempted, a spell is now in progress. /stopcasting removes this assumption and prevents the "Another action is in progress" error. Since the spell is instant, /stopcasting does not actually cancel the cast. Example:
/use Talisman of Ephemeral Power
/cast Arcane Power
/cast Presence of Mind
Targeting is another common task in macros. This is accomplished either by using dedicated targeting slash commands which actually change your target or by using the [target=] macro option on commands that accept them. When you use the macro option, you are actually casting the spell or using the item directly on the unit without changing targets. Macro options will be covered in great detail in Part II. For now, I'll show you how to use the targeting commands.
The most basic targeting command (unsurprisingly) is /target. Its use is as simple as
/target Cogwheel/target does a closest match which means if you do /target Cog and I'm standing near you (and no one named Cog is) it will target me. This is a plus or a minus depending on your situation. Unfortunately, it will also target irrelevant units (like corpses). This makes macros like the following much less useful than they might first appear.
/target Blackwing Mage
/cast Curse of AgonyIf no Blackwing Mages are around, this might target someone in your raid who happens to have the letters B and L in their name. While they're safe from the wrath of your curse, it's still a bit disconcerting. Another problem is that it may target something 100 yards behind you that you don't really care about. (Patch 2.3 will add a /targetexact command to eliminate part of the problem.)
In addition to specifying the name of someone you would like to target, you can also provide a unit ID. Unit IDs are a way to identify a particular character, mob, NPC, etc. For instance, your current target can always be accessed by the "target" unit ID (obviously not the most useful for the command we're discussing at the moment :P). You yourself are accessed by the "player" ID, and if you have a pet it would be referenced by "pet." You can also append "target" to the end of any valid unit ID to arrive at that unit's target. There is a joke about Kevin Bacon involving a macro like:
/target targettargettargettargettargettargethttp://www.wowwiki.com/UnitId has a full list of allowed IDs.
Other targeting commands
Here is a brief overview of the other targeting commands:
By itself, assist targets your target's target (e.g. if you are targeting me, and I'm targeting Iriel, /assist would make you target Iriel). You can also provide a name or unit to /assist and you will assist the specified entity:
/assist Cogwheel There is an interface option which will automatically start you attacking if you end up with a hostile target.
Leaves you with no target
As the name suggests, this will target your previous target. If you previously had no target, this command will do nothing.
These commands cycle through the specified type of unit. /targetenemy is like pressing TAB, and /targetfriend is like pressing CTRL-TAB (in the default key bindings). You can also add a parameter of 1 which reverses the direction of the cycle (/targetenemy 1 is like pressing SHIFT-TAB).
Note: You can only use these commands once per macro.
Cycles through your nearest party or raid members. Like /targetenemy, you can add a 1 to reverse the direction.
How do I control my pet
As mentioned in the spell casting section, you can use /cast to cast your pet's abilities by name. In fact, Blizzard had to change the name of the Mage elemental's Frost Nova to Freeze because there was no way to use it in a macro. :P But as everyone with a pet is aware, that's nowhere near the end of the line for pet control. Luckily the Burning Crusade patches brought us a host of new pet commands.
/petattack, /petfollow, /petstay, /petpassive, /petdefensive, and /petaggressive all correspond to the basic control commands on your pet bar. Additionally we have /petautocaston <spell> and /petautocastoff <spell> which activate or deactivate, respectively, your pet's auto cast for the named spell. There is no command to toggle auto-cast, but see "Simulating button clicks" below for a workaround (patch 2.3 will add /petautocasttoggle).
Controlling button feedback and the question mark ( ) icon with #show
By default, WoW uses the first spell or item that appears in a macro to show cooldown, range, and availability feedback on the button, and to pick which icon to display when you use the question mark icon. Take our multi-spell macro from earlier as an example:
/use Talisman of Ephemeral Power
/cast Arcane Power
/cast Presence of Mind
With this macro, WoW chooses Arcane Power for the feedback. However, this is probably not what you really want. The main point of this spell is to cast Pyroblast. The first few lines merely exist as support spells to make the Pyroblast more effective. You can make the button behave as if Pyroblast were the first spell by adding the following line to the top of the macro:
#show PyroblastIf you used the question mark icon for the macro, the button will even have the icon of Pyroblast without any extra effort on your part. The parameter to #show (in this case Pyroblast) works the same way as the /cast and /use commands. You can use a spell name, item name, item id (item:12345), inventory slot, or bag and slot numbers.
Similar to #show is #showtooltip. Normally when you mouse over a macro on an action bar, your tooltip displays the name of the macro. This is not incredibly useful most of the time (especially if you use an addon like TheoryCraft to give you detailed spell information in tooltips). However, the #showtooltip command allows you to specify a spell to use in the tooltip the same way as #show. If you use #showtooltip, you do not need to use #show.
If you're happy with the spell that WoW is choosing for the feedback, you can use #showtooltip without a spell to save space in your macro. WoW will still use whichever spell it was choosing before, but it will now show the tooltip info for that spell/item.
Please Note: unlike slash commands, #show and #showtooltip must be written in lower case letters.
Other slash commands
Now that you have a solid foundation I'd like to briefly cover some of the other slash commands at your disposal. Some of these commands may seem a bit pointless at first glance, but when you combine them with the macro options from Part II, they can perform some neat tricks.
There are two commands for equipping items: /equip and /equipslot. /equip simply takes an item name and will equip it to the default slot as if you had right-clicked it in one of your bags (i.e., a one-handed weapon will be equipped to your main hand). /equipslot takes an inventory slot id (see http://www.wowwiki.com/InventorySlotId) and an item name, and equips the item to the specified slot. Examples:
Equip a weapon to default slot:
/equip Honed VoidaxeEquip a trinket to the lower trinket slot:
/equipslot 14 Carrot on a StickNote: Addons are allowed to use the equipping functions directly, even during combat. By the same mechanism, you can use the equipping slash commands with addons like AfterCast or Chronos. You might have some trouble if the addon first checks whether the command is secure; the equipping commands are in the secure command list, though they aren't inherently secure.
Sequencing spells and items
Many times you will find yourself casting a series of spells or use certain items in the same order on pretty much any mob you fight. To make this job a bit easier, we have the /castsequence command. /castsequence takes a list of spells and/or items separated by commas. These follow the same rules as /cast and /use. This means you can interchange spell names, item names, item IDs, inventory slots, and bag slot combinations. Each time you run the macro, it activates the current spell/item. If the spell or item is used successfully, the sequence will move to the next entry. You must repeatedly activate the macro to use all the spells in the sequence. Once you use the last entry in the list, it will reset to the beginning. Example:
/castsequence Immolate, Corruption, Curse of Agony, Siphon LifeThis might be something you would use for a Warlock's opening attack. Note, however, that if Immolate fails to cast for some reason (out of mana, not in range, silenced, etc.), the sequence will remain at that point. Because of this, you cannot use a /castsequence to make a spammable macro like:
/castsequence Overpower, Execute, Mortal StrikeBefore the spell list, you can also specify reset conditions to start the sequence over before it reaches the end. The basic syntax for reset conditions is:
reset=n/target/combat/shift/alt/ctrlWhere n is a number of seconds. You can specify any number of these conditions separated by slashes as shown. Seconds are used as a timeout for the command. Each time the sequence runs, it resets the timer. If you don't use the macro within the number of seconds specified, the sequence will start over. This is a very important distinction because it means you cannot use a reset timer to account for cooldown. target resets the sequence when you change targets; combat when you leave combat; shift, alt, and ctrl when you activate the macro with one of those keys depressed. Example:
/castsequence reset=10/shift Spell 1, Other Spell, Some Item
If you used the question mark icon, WoW will automatically update the icon to the current element of the sequence. If you have other /casts or /uses before the /castsequence, though, they will interfere and there is no way currently to tell WoW to pay attention to the sequence instead.
Random spells and items
One of the most common requests on this forum is for a macro to use a random mount. This is extremely trivial thanks to the addition of /castrandom and /userandom. Like /castsequence, /castrandom and /userandom takes a list of spells and/or items separated by commas and picks one at random when you run the command. Example:
/castrandom Swift Green Mechanostrider, Black Battlestrider, Summon Dreadsteed Attacking
The simplest attack command is /attack. This functions identically to the attack skill or key binding and will toggle your attack. If you'd rather have an "always start" or "always stop" attack, you can use /startattack or /stopattack, respectively. Both /attack and /startattack can take a name or unit ID to specify who to attack. Example:
/attack Cogwheel Action bar manipulation
There are two commands that allow you to change action bar pages: /changeactionbar and /swapactionbar. /changeactionbar takes a single number and will always switch to that page. One use of this is for hunters to emulate stances by having a pair of macros like:
/cast Aspect of the Hawk
/cast Aspect of the Monkey
/changeactionbar 2/swapactionbar takes two page numbers and will swap between them each time it runs. If you're on a page other than one of the two specified, it will be change to the first of the two.
/swapactionbar 1 2Removing buffs
The /cancelaura command allows you to remove unwanted buffs. For example, a tank could remove an unwanted buff in a macro with the following command:
/cancelaura Blessing of Salvation Leaving a form
With the exception of Warriors, any class with stances (Druids, Priests with Shadowform, etc.) can use /cancelform to leave their current form. See the stance section of Part II for an example.
Stopping a cast
/stopcasting has been touched on briefly in other contexts but its main use, as you might guess, is to stop another spell cast that's in progress. This is useful for making "panic buttons" that interrupt whatever you're doing at the moment in favor of something more important. On my Warlock, for instance, I use the following macro:
/cast ShadowburnHalting a macro early
/stopmacro is one of those commands that doesn't really come into its own unless you use it with macro options. Its main use is to implement "fall-through" logic to prevent you from continuing a macro if certain conditions are true. See "Using Focus " for an example.
Simulating button clicks
The /click command takes the name of a frame and virtually clicks the frame with your mouse. By default, it behaves like a left-click, but you can specify other mouse buttons in the command. To determine the name of the frame you're interested in, you can use an addon like MoveAnything, look through the UI code for the frame, or activate the following macro by a key binding with your mouse over the frame in question:
/run local f = GetMouseFocus(); if f then DEFAULT_CHAT_FRAME:AddMessage(f:GetName()) end/click can be used for many different purposes. You can chain macros together by ending each with a /click command that activates the next macro in the sequence. You can also do things you wouldn't normally be able to do with macros. For instance, there is no command to toggle your pet's auto-cast abilities (until patch 2.3). However, you can use /click to reproduce a right-click on the given button (the fifth one in this example):
/click PetActionButton5 RightButtonAdvanced Scripting
What scripts can't do
Scripts are very powerful tools that can make complex decisions based on a number of criteria. Because of this power, Blizzard has limited the types of things we're allowed to do with them in order to keep macros and addons from taking actions that should be controlled by the player. I'm starting this section with what you can't do because I don't want you to get your hopes up. While scripts do remain useful for quite a few purposes, you cannot use them to cast spells, use items, change your action bar page or affect your target in any way. You are limited to using the "secure" commands already shown for those tasks.