I want to broadcast a message throughout several channels. When left click, broadcasting to all channels, when right click, just to channel 1. This is my original script, though it exceeds the character limits of a macro. How can I make it shorter?

/run s="a long long long long .... message ..."
/script SendChatMessage(s ,"CHANNEL" , "COMMON" ,"1");
/script if(GetMouseButtonClicked()=="LeftButton") then SendChatMessage(s ,"CHANNEL" , "COMMON" ,"4") end;
/script if(GetMouseButtonClicked()=="LeftButton") then SendChatMessage(s ,"CHANNEL" , "COMMON" ,"7") end;

I was looking for how to use "for each (4,7)" to replace the last 2 lines, but didn't find a "for each" syntax for WoW API.


For each exists, but only if you create an array first, which isn't helpful. I can't log in to check right now, but you can try something like this:

Make one macro that makes it act like you clicked on a button and reroutes to another based on right/left click:

/click [button:1] MultiBarLeftButton2; MultiBarLeftButton3

Then make two macros for each separate thing and put them on the proper button location. So, for the left click:

/csay 4 yourmessage
/csay 7 yourmessage

and right click:

/csay 1 yourmessage

If your message is too long to fit, you should be able to use semicolons to keep it all on one line:

/csay 4 yourmessage; 7 yourmessage

Or, you can do part of it, and put /click MultiBarLeftButton4 to chain it to another button with the rest of the message.

For reference, here's the different action bar names:

ActionButton#                Main Bar*
BonusActionButton#           Dynamic bar that switches actions based on Druid Forms, Warrior Stances, and Rogue Stealth*
MultiBarBottomLeftButton#    Bottom Left Bar
MultiBarBottomRightButton#   Bottom Right Bar
MultiBarRightButton#         Right Bar
MultiBarLeftButton#          Right Bar 2 (to the left of "Right Bar")
PetActionButton#             Pet Bar
ShapeshiftButton#            Druid Forms, Paladin Auras, Warrior Stances, Death Knight Presences, Rogue Stealth

Here's a quick reference on branching with /click.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.