Useful macros ( 1 . 0 ) " ' NOTE : This page is archived . The material herein was valid in pre - B . C . WoW ; but most , if not all , has been discontinued , changed , or protected . For valid macro information , refer to Making a macro , Useful macros , or UI beginner ' s guide . = Spells = Casting spells no longer requires the ( Rank x ) . So you can now have a macro that says : codice _ 1 , and it ' ll cast your highest rank of Holy Light . This macro will always cast the highest rank spell , and you will not be able to cast it on lower - level targets . Self Cast Any Spell ( without losing your target ) . / script CastSpellByName ( ' Holy Light ' , 1 ) Casting Buffs . Adapted from the above code , this is designed to cast buffs . If an enemy is selected , you will cast the buff on yourself , if nothing is selected , you will cast the buff on yourself , if you are selected , you will cast the buff on yourself but if your ally is selected they will be buffed . Example This macro will cast buffs on you unless an ally is selected ( Mark of the Wild ) : Forgot the " ; " before " else " command : so script doesn ' t work . I added one that fixed it with " Blessing of Might " , so just replace spell to change buff . Cast a spell based on target ' s class . You ' ll need to target the person you want to buff first . Here ' s an example for a paladin to use ; note that it should all be on one line : Cast a spell based on target ' s level . You ' ll need to target the person you want to buff first . Here ' s an example for a priest to use on an English language server . You have to alter the spell name according to the spell you want to cast and change i = 6 by the number of ranks you currently have for that spell ; note that it should all be on one line : Cast a healing spell on nearby friends . This will target all your nearby friendly player characters in turn and cast a heal on the first one it comes to with a health level that is below a certain percentage of maximum ( in this example 70 % ) . Repeated calls to the macro will step through all nearby friends needing heals until it targets you . The macro checks the health of up to 40 nearby friendly player characters . If a call to this macro casts no heal then neither nearby friendly player characters nor yourself have a health level below the threshold of 70 % of maximum . Announcing spells and targets to your party . Good for healing and crowd control spells . Example with a healing spell ( Party member must be targeted first to make the party announcement work ) : Cast a spell on party member based on his location in party . This will target the " first " member of your party , cast a healing spell on him , then return you to your previous target . To use on 2nd member of party change " party1 " to " party2 " . Cast multiple buffs with smart buff recognition . This script checks whether the target has a buff , if not you cast it , if so you cast a different buff . Modify the spell names to change the buff . Cast even more buffs with smart buff recognition . A lightweight " smart buff " script allowing auto casting of 3 buffs based on your target ' s buffs - Buff 3 is cast if you have no target . Requires knowledge of buff names and spell numbers ( see Find Buff Name and Search For Spell Number ) . Find Buff Name . Smart buff recognition requires knowledge of the " icon " name of the appropriate buff , which may differ from the spell name significantly . The script below lists all buffs currently affecting your target , and these names can be used to modify a smart buffing script for better flexibility . Alternatively , this script taken from the Queriable buff effects page also lists debuffs present on your target . Find Spell Number . Sometimes using the CastSpellByName function causes the script to exceed the 255 character limit . In such cases , it may be useful to reference the spell number as found within your spellbook and abilities . This script allows you to poke around looking for the spell number associated with a given spell . Spells are numbered beginning with all pages found in your general abilities , followed by all pages of your first talent tree then all pages of the second talent tree etc . If you learn new spells and have referenced spells by their number in a script , you may need to revisit this script to ensure you are casting the correct spell and rank . Line breaks ( carriage returns or < Enter > ) have been added for legibility only . When copied into WoW , make sure the script is one line only . Once you have the spell number , use CastSpell ( spellnumber , 0 ) to cast it . For example if Inner Fire was spell number 17 in your spellbook ( as determined using the script above ) , you could use / script CastSpell ( 17 , 0 ) to cast it . If you want to ensure that it casts only on yourself , use / script CastSpell ( 17 , 0 , 1 ) . Search For Spell Number . This modified version of the above script searches for spell numbers that contain a substring defined by the variable f . Immediate Cast non - global cooldown Spell . Some spells , such as Amplify Curse and Divine Favor , don ' t activate the global cooldown , so it ' s possible to immediately follow them with another spell . However , the user interface waits for confirmation of the spellcasting action before allowing you to cast a second spell , which can result in a pause if your connection has some lag . This macro avoids the need for a confirmation by following up with SpellStopCasting , so you can cast a second spell immediately , regardless of lag . Note that if you don ' t have the listed spell ( Divine Favor , in this example ) in your spellbook , running this script will hang your client . The reason for the first line is so that the icon will show the current cooldown state for the spell correctly . This macro can be easily modified to allow following it with another spell - append ; CastSpellByName ( name _ of _ spell ) , and change the starting CastSpellByName to match so you get the cooldown and in - range information for the final spell . = Inventory / Items = Equip an item . / script PickupContainerItem ( bag , slot ) ; bag goes from 0 to 4 , and slot from 1 to 20 ( depending on bag size ) . For more information , go to Item equipping to see how to use items from backpacks , etc . , and information on how to prevent accidental vendoring of items due to macros . Change your boots to Goblin Rocket Boots ( by Gk - s2 - ) . A really simple script made by myself who changes your boots anyboot you are using to Goblin Rocket Boots . Note : Change the MainHandBag and MainBagSlot to where your item are located Note : This macro should be on one line . Quick Self - Bandage ( by Domandred ) . Post - Patch 2 . 0 Consult Use a Bandage . Pre - Patch 2 . 0 Use : Really nice macro for duels or 1v1 pvp . You can stun / fear your enemy , press this and it ' ll automatically bandage you without losing your target . Problem with macro above is losing combo points for rogues . This one will do the same thing without making you lose your combo points Another quick self - bandage from me , Kingoomie . Remember , one line . Checks for an item in the slot , opens the bag if there isn ' t one , uses the item ( bandage , in this case ) on you , targets your last target , or targets nothing if you either didn ' t have a target or were targeting yourself . Quick Self - Bandage ( by sjefen6 ) . Post - Patch 2 . 0 Consult Use a Bandage . Pre - Patch 2 . 0 For the ActionID , check out the table on the bottom of this chapter . In Basic this does the same as " Quick Self - Bandage by Domandred " , but finds the player automatically and uses ActionID instead of ContainerItem . Use a Bandage . Post - Patch 2 . 0 It is no longer necessary to reference consumables directly from bag and bag slot numbers . All that is required is for you to provide the name of the item by either manually typing it or linking it ( Shift + Click ) . Pre - Patch 2 . 0 Bandage must be placed in the action bar at the slot given by ActionID . ActionID is a number from 1 to 120 . Slot1 - ActionBar1 is ActionID1 , Slot12 is ActionID12 , Slot1 - ActionBar2 is ActionID13 and so on up to Slot12 of ActionBar10 . This will bandage your target , or yourself if your current target is not a friendly target . Here ' s a different version courtesy of post by Sarf on the forums . This one will always self - bandage , even if you have a friendly player targeted . It will also re - target your original target . Note that this must all be on one line , its just split up for readability : Following is another example of self bandaging that does not use scripting . THIS WILL WORK FOR COSMOS USERS ONLY . Shift - clicking on the bandage ( or other item in inventory ) while editing your macro will insert its name into your macro . Placing the " target " command after the " use " command maintains your primary target and also maintains your combo points for that target if you ' re a Rogue . " Note : As of WoW UI version 1300 , when you use the / target command use player not " player " to target yourself . Script command / target does NOT require Cosmos mod , but the / use command does . " You may experience problems with the script above , because it uses non - standard commands . If you place your Heavy bandage in the second ActionBar slot 5 you can use this small macro to use the bandage on your self . This works regardless of whether Cosmos ( or any other mod ) is installed . You have to use 17 , because it is 2nd Actionbar and 5th slot ( ( 2 - 1 ) * 12 + 5 = 17 ) . Reference ActionID ' s : Use a Trinket / Item . / script UseInventoryItem ( 13 ) Use : Pops the trinket you have equipped in the first trinket slot . This way if you have several " on use " trinkets you can control any of them with a single button instead of creating multiple buttons for each trinket , as long as the trinket is in the appropriate slot . Sharpen / Apply Poison to Weapon ( by Arag ) . / script UseContainerItem ( # , # ) ; Use : Simply press a button and use a Sharpening or Weight stone , or apply a poison . Example : Press a button , sharpen your weapon . Change the 16 or 17 to do it for a secondary weapon . For the # ' s on the first line , please refer to " Understanding Location " in section 6 . Sell all the poor items in your bags ( by Haw ) . This macro will sell your poor items , when used at a vendor . Rember to put it in one line . Clean bags of poor items ( by Flowers ) . This will delete all poor quality items from your bags . There will be no confirmation dialog - the items will simply vanish . Note that it needs to be on one line , as usual . ( / run is a synonym for / script . ) Strip all gear with durability ( by Flowers ) . For those times when you ' re not in combat , but about to die anyway ( like falling a long distance ) , this will at least protect your gear ( or as much of it as there ' s room for in your bags ( your backpack will not be used ) ) . Also useful at the right sort of parties . Optimizers can rearrange the slot list to put the most expensive to repair items first . As usual , it needs to be one ( really long ) line - be careful entering it , as it ' s exactly 255 characters long . = Interface = Switching Hotbars . / script CURRENT _ ACTIONBAR _ PAGE = X ; Where X is the Hotbar number Example . / script CURRENT _ ACTIONBAR _ PAGE = 1 ; Set Video World Environment Variables . Sometimes when you are in a high - traffic area ( Ironforge or Orgrimmar in particular ) , RAM and processors get bogged down . One way to help your computer is to adjust the video settings to improve performance . You can put these macros into hot bars and bind to keys for easy switching , e . g . Shift - \ , \ , and Ctrl - \ for High , Medium , and Low Res . These don ' t change the actual resolution of the screen , only the level of detail . low res is very good for the Auction House / Bank areas . Also , if your UI needs reset ( the rendering isn ' t working ) , just switch from one to another . Full - screen to windowed mode . I found this handy for working on macros / scripts while having reference material next to me ( ie these web pages and others ; ) . This will switch your game between full - screen , full - colour , and a smaller windowed mode . There are some assumptions , you need to replace the index numbers for your own setting - for me , I run WoW in 1600x1200 32bit full anti - aliasing when full - screen , 1024x768 16bit 1xanti - aliasing when in window . The index numbers can be calculated by going to video options and counting the items on the drop - down . Note : The bit between " / script " and " / console " must all be on one line ( ie there should be a line starting " / script " and a line starting " / console " and that ' s it ) , it ' s broken up for readability . Replace the " 15 " in SetScreenResolution with your selected high - res index , the " 16 " in SetMultisampleFormat with your selected colour depth / anti - aliasing , and the " 3 " in Set / GetScreenResolution with your preferred windowed res . To finish this one off , drop it into a popup button and go to key bindings , link in " alt - enter " . That way , alt - enter will alternate between windowed and full - screen . You can also work in any of the above Farclip etc calls to further alter the settings between windowed and full - screen , depending on how your machine behaves - experiment and see . Note also , I ' m using GetCurrentResolution . I ' d rather use GetCVar ( " gxWindow " ) , but I got very unreliable results from that - not sure why . Toggle Name Display . I like to shut off player names when I take screen shots , so here is what I use : And for shutting off the NPC names I use this : Global Tell Variable . If you have multiple scripts that send tells ( " Sheeping Lynk " , " Heal Lynk " , etc . ) it may be useful to have each script reference a global variable that is changed by a single script . Kind of a " click once , change em all " scenario . This script sets a global variable PR ( Party / Raid ) to an appropriate channel based on raid , party or solo membership . Line breaks ( carriage returns or < Enter > ) have been added for legibility only . When copied into WoW , make sure the script is one line only . In your scripts , transpose " Say " , " Raid " , " Party " for PR . " Lynk - Gilneas " = Combat = Select and Auto - attack nearest enemy . This macro is useful for all melee classes . Useful for selecting and auto attacking nearest target , equivalent of pressing Tab , then T by default key bindings with just one key stroke . Hit it multiple times to switch between engaged enemies . It ' s useful enough to rebind Tab or Space bar to it . Help Tank Character . If you are in a group and fighting a larger group of enemies , and your group tank character is already fighting an enemy , you may not want to attack one which did not have Aggro yet . Select your group tank via key [ F ] and execute the following macro . If you ' re a beginning macro user the above is ok , Better to skip the ' F ' key and type in the player name in the above . Not sure the AttackTarget ( ) ; is safe . But that ' s getting into Tactics , so see the Instance Grouping Guide Main Assist page . A more advanced method of this is to pre - select a player as the " main assist " and have your macro assist that player throughout the duration of the party . The simple method is to replace % t with the name of that player and edit your macro when needed . Main assist also works for everyday group play , but editing a macro and typing in a player ' s name may not be possible in all situations . If you are willing to sacrifice two macros and action bar slots , you can automate things with the following two macros : Use the " Set " macro when you have your main assist player selected and want to switch your assist macro to use that player . If no player is selected and you are in a party , the first other party member will be selected . If you are not in a party and not target is selected , you will assist yourself , which is somewhat redundant , but harmless . To save macro and action bar space , you can combine the two macros in the following script . To set the main assist player , hold down the control key while activating this macro . The version that fits into a 255 character macro is given below and it is somewhat obfuscated : " / script p = PAsi or " " u = UnitName ; t = " target " c = IsControlKeyDown ( ) if ( c ) then p = u ( t ) or u ( " party1 " ) or " " else AssistByName ( p ) end ; DEFAULT _ CHAT _ FRAME : AddMessage ( " # # # # # # # # " . . ( c and ( " Set assist : " . . p ) or ( " Assisting " . . p . . " with " . . ( u ( t ) or " NO TARGET " ) ) ) ) PAsi = p Here ' s the same script with extra spacing and punctuation added for clarity : Assist Main Tank / Main Assist . Pre - Patch 2 . 0 This script sets your Main Tank or Main Assist for assists and assists the MT / MA all - in - one . " Lynk - Gilneas " Post - Patch 2 . 0 " Lynk - Gilneas " Target Memory . Pre - Patch 2 . 0 The following macro memorizes players and mobs by name . Remembering mobs by name can be a problem if there are several with the exact same name in the area ( you will often target the wrong mob ) . Because of this , this macro should only be used in PvP and when you are fighting a unique boss mob with unique sidekicks . To have multiple memorized targets , edit the Tg1 variable name in the three places where it is mentioned . Note that the short version below uses " ChatFrame1 " instead of " DEFAULT _ CHAT _ FRAME " to save a few characters to allow for longer spell and skill names than Polymorph . The human - readable version is given below the compact / obfuscated version . " / script t = Tg1 or " " c = IsControlKeyDown ( ) if ( c ) then t = UnitName ( " target " ) or " " else TargetByName ( t ) if ( IsShiftKeyDown ( ) ) then CastSpellByName ( ' Polymorph ' ) end end ChatFrame1 : AddMessage ( " # # # # # # # # " . . ( c and ( " Tg1 set to : " . . t ) or ( " Targeting : " . . t ) ) ) Tg1 = t Post - Patch 2 . 0 This was tested on players and a pair of level 65 Ironforge Guards . There did not appear to be any confusion as to which target had been defined as the point of focus . Consistency of this macro varied between using the keyboard exclusively and keyboard mouse combinations dealing specifically with default bindings ( e . g . ActionBar 1 , Slot 4 using SHIFT + 4 would switch you to ActionBar 4 and not execute the macro ) . Adjust the use of Control ( CTRL ) , Alternate ( ALT ) and Shift ( SHIFT ) keys ( not case sensitive ) for your environment . Kill totems . This can be used to destroy any totem , and is obviously designed for druid s . Naturally you can change the last line to codice _ 2 which is especially good for someone with a wand . Whether it will fit in the same macro or not , I ' m not certain , but you might also want to add lines to target Dark Iron Dwarf mines as well . I can ' t think of anything else like it . The following is from Talashandy , cited by Alex . Here is a bit more programmy way of doing the same thing . Remember to remove the lines breaks . Timer . Simple script to track the time elapsed from a set point in time . If you click the script without holding the Alt key first , you will receive an interface error . If you log off for whatever reason , your timer will be erased . Change " Say " to whatever channel you want " Party " , " Raid " , " Guild " , etc . About script variables : = Pets = Pet Attack . / script PetAttack ( ) ; A useful extension of this is to have your pet begin assisting your main tank with one button . You could also add a fourth line that casts one of your spells so that you begin fighting too . Attack with Dash : Pet Passive . / script PetPassiveMode ( ) ; This is really useful in a Scatter Shot macro : If you use above macro when 5 mobs are attacking your pet at the same time , you pet just comes running to you , so all the mobs will be out of gun / bow range . If you use the following macro , your pet will start attacking the first mob that attacks him ( not the scattershotted one ) and he should stay virtually in place . Summary of Commands . / script PetAggressiveMode ( ) ; and with X being a number on the pet ' s action bar ( 1 , 2 , 3 . . . ) = Miscellaneous = Local Server time . / script hour , min = GetGameTime ( ) Location . / script px , py = GetPlayerMapPosition ( " player " ) " Value will be between 0 , 0 ( Top Left corner of current map ) and 1 , 1 ( Bottom Right ) " A variant that gives a value between 0 and 100 , and reduces it to 1 decimal place : Change Action Bar Page . / script CURRENT _ ACTIONBAR _ PAGE = X ; Use : Replace " X " with the action bar page number , and by pressing this , it ' ll automatically change . Example : You have two of these , both set on the " = " on page 1 and 2 , and have page 1 ' s set to change to page 2 , and vice versa . Whenever you press " = " , it ' ll toggle between page 1 and 2 . The below macro one does the same thing as the one above , but without the need for two separate macros . It will just switch back and forth between action bar 1 and action bar 4 . I just made these two , using the above macro as a base , in order to let myself switch between three action bar pages with two macros . You can get to any of the pages from any of the three pages . This will bring you to page 1 if you are on page 2 , and to page 2 if you are 1 or 3 . This will bring you to page 1 if you are on page 2 or 3 , and to page 3 if you are on page 1 . Say Quest Objectives . / script i = GetNumQuestLeaderBoards ( ) ; for j = 1 , i , 1 do a1 , a2 , a3 = GetQuestLogLeaderBoard ( j ) ; SendChatMessage ( a1 , " PARTY " ) ; end ; Use : Sends your current quest objectives to your party . This way , you don ' t have to constantly type to party members how many of each creature you need to complete a quest . Turn In Quest Items . / script SelectGossipAvailableQuest ( 1 ) ; CompleteQuest ( ) ; GetQuestReward ( ) ; Use : This is usable at almost any quest giver with a blue question mark . It ' s especially useful for doing Dark Iron Residue turn ins for Thorium Brotherhood faction . Some of these quest givers offer multiple quests . To have the macro select a quest besides the first one , simply change the number in the parentheses . Go to Macros Go to Interface Customization