Setting a Focus Target
A focus modifier in macros will not work unless you have set a focus target. Click on the player or creature you want to have as your focus target and press "Enter" to bring up your chat edit box. Type "/focus" and press "Enter" again. An additional unit frame will appear on your screen, displaying your chosen focus target.
Casting Spells on Your Focus Target
A basic macro that uses the focus modifier to direct spells and abilities at your focus no matter what your current target is takes the following form:
/cast [@focus] Counterspell
Replace "Counterspell" with the spell or ability you want to use. If you want to ensure that the spell or ability will be cast on your current target if you don't have a focus or your focus is dead, alter the macro to the following form:
/cast [@focus, exists, nodead][] Counterspell
The addition of "exists" and "nodead" to the focus modifier check whether your focus exists and is alive; the additional pair of empty square brackets means "in all other cases" and will cause the spell or ability to be cast on your current target if your focus is dead or nonexistent.
Choosing a Target With Modifiers
Choose whether you use a spell or ability on your focus or your current target by inserting additional modifiers. For example, the following macro will cast Counterspell on your focus target if you press the "Shift" key together with the macro, and on your current target in all other cases.
/cast [nomodifier] Counterspell
/cast [mod:shift, @focus] Counterspell
Focus Changing Macro
Construct a macro that uses the focus modifier to determine the current state of your focus and decide whether to replace it with your current target. For example:
/focus [mod:shift]
/stopmacro [@focus, exists, nodead]
/focus [@focus, dead]
/focus [@focus, noexists]
The first line will cause the macro to set your current target as your focus when you press the "Shift" key even if you already have a focus. The second line stops the rest of the macro from executing if you already have a focus and it is not dead. The third line will replace your current focus with your target if your focus is dead. The fourth line will set your current target as your focus if you currently have no focus.
Warning
Always test your macros to ensure they have the intended effect or you may find yourself unable to use the spell you inserted in the macro effectively during combat. Test macros that involve spells and abilities that can only be cast on enemies using the target dummies found in every capital city; ask for the help of a few friends when testing macros that involve spells and abilities that are intended for use on friendly targets.