Originally Posted by Banknorris
For some commands you can
Code:
local editbox = ChatEdit_ChooseBoxForSend(DEFAULT_CHAT_FRAME)
ChatEdit_ActivateChat(editbox)
editbox:SetText("/readycheck") --not sure if this particular command requires a hardware click or not
ChatEdit_OnEnterPressed(editbox)
I do this when I want my addon to use a slash command of another addon.
|
This can only be done with insecure commands. Attempting to run this on a secure command will raise an action blocked error. As for the ready check, if you have a way to call the function directly, which I explained how previously, there's no need to waste CPU cycles processing string input into a command to eventually run the function anyway. Even so, this example is extremely harsh in which it hijacks a user control to do so.
If you can find no direct access to the function used by a slash command, you can access it by indexing the
SlashCmdList table. Note this is only for a
last resort.
Do NOT use this method if you have direct access to a function.
Code:
SlashCmdList["COMMAND_TOKEN"]("arguments");
Note you need to do some research into the UI or addon code to find out what the token for a command is. If you want to be lazy, you can access
hash_SlashCmdList with additional hacking, but this is guaranteed to work on all locales.
As a final notice, neither this nor any other code would allow running secure commands. There's just no way around that.