Macro conditionals

This page lists macro conditionals, keywords used with macro commands, the RestrictedEnvironment and the SecureStateDriver API to allow limited logic for player convenience without trivializing the game.
Refer to secure command options for syntax and making a macro for a tutorial.
== Temporary targeting ==
 /cast [@focus] Counterspell
The following keywords temporarily assign a target that the macro command will act on. This only applies to a single action; it does not change the player's selected target.
; @unitId : Replace with any valid unitId (@player, @target, @focus, @mouseover, etc.)
; @cursor : Immediately targets the ground under the cursor.
; @none : Interupts auto self-cast and requires a targeting cursor.
target= is also an alias for @. However, despite the name, this still only affects a single macro command without changing the player's target.
== Boolean conditions ==
 /cast [dead] Resurrection; Heal
All other conditionals evaluate as either true to execute the macro command, or false to skip it. The no prefix reverses this (ie, nodead means alive).
The following tables categorize each boolean condition by whether it evaluates the state of any target, only the player, or the user interface.
 Evaluated against the temporary target (default: @target)
Macro Conditional	Similar API	Description
exists 	 	The unit exists
help, harm 	and 	The unit exists and can be targeted by helpful/harmful spells
dead 	 	The unit exists and is dead
party, raid 	and 	The unit exists and is in your party/raid (party excludes self)
unithasvehicleui 	 	The unit exists and is in a vehicle
 Evaluated against the player only (always @player)
Macro Conditional 	Similar API	Description
advflyable 	 	Player is located in an area that supports advanced flying (ie, Dragonriding)
canexitvehicle 	 	In a vehicle and able to exit
channeling, channeling:spellName	and 	Channeling any spell, or a certain spell
combat 	or 	In combat
equipped:type, worn:type 	 	Refer to itemType for possible types (ie, weapon) and subtypes (ie, sword)
flyable 	 	Unreliable in Wintergrasp
flying 	 	Mounted or flight form, and in the air
form:n, stance:n 	 	Refer to for possible values
group, group:party, group:raid 	and 	Self-explanatory
indoors, outdoors 	and 	Self-explanatory
known:name, known:spellID 	or 	Also works with #showtooltip
mounted 	 	Self-explanatory
pet:name, pet:family 	 	Using a hunter pet by or
petbattle 	 	In a pet battle
pvpcombat 	 	PvP talents are usable
resting 	 	In a rested zone
spec:n, spec:n1/n2 	 	Activated the n'th (or any of n1, n2) spec
stealth 	 	Self-explanatory
swimming 	 	Self-explanatory
Evaluated against the user interface (action bars, keyboard, mouse)
Macro Conditional 	Similar API	Description
actionbar:n, bar:n, or bar:n1/n2/... 	 	The n'th (or any of n1, n2, ...) action bar page appears
bonusbar, bonusbar:n 	 	The bonus action bar is visible; see
button:n, btn:n1/n2/..., btn:<virtual click>	 	The mouse button used as left (1), right (2), middle (3), extra (4, 5, ...) or
cursor 	 	Dragging an action button (item, spell, macro, etc.)
extrabar 	 	An extra action bar/button is visible
modifier, mod, mod:key, mod:action 	or 	Accepts shift, ctrl, alt, lshift, rshift, ..., and any action title
overridebar 	 	The override bar is replacing the main action bar
possessbar 	 	The possess bar is visible
shapeshift 	 	The temporary shapeshift action bar is replacing the main action bar
vehicleui 	 	The vehicle UI is active
==Patch changes==
*
*
*
*
*
*
*
*
==References==
Category:Macros 
Category:UI technical details