1. Ok I have a problem. My script that I run on my WoWLua is not working. I've tried to work with SecureActionTemplate to run the cast with one click. The script is:

     local button = CreateFrame("Button", "MyCastButton", handler, "SecureActionButtonTemplate")
     local start, duration, enabled = GetSpellCooldown("Shield block");
     if enabled == 0 then
        DEFAULT_CHAT_FRAME:AddMessage("Shield block is currently active, use it and wait " .. duration .. " seconds for the next one.");
     elseif ( start > 0 and duration > 0) then
        DEFAULT_CHAT_FRAME:AddMessage("Shield block is cooling down, wait " .. (start + duration - GetTime()) .. " seconds for the next one.");
        DEFAULT_CHAT_FRAME:AddMessage("Shield block is ready.");
        button:SetAttribute("type", "spell");
        button:SetAttribute("spell", "Shield block");

    Busically what it have to do is Casting spell when cooldown is ready and writing messages when the cooldown will be ready everytime click the macroed button with "/click MyCastRandButton" on my action bar.

    How can I do it correctly? Thank you!

    It's not quite that simple. You could break it up into a few different phases:

    1. Create a button that will cast the spell that you want, with the icon you want, etc.
    2. Set up the event handlers so that when the spell is cast, a message is displayed indicating how long you should wait to cast it again, or when the cooldown comes up, saying you can cast it again.

    You're trying to couple the button to the cooldown stuff, and that doesn't really work. You can't change the behaviour of the button depending on cooldown, but you can change the display of it. It's not entirely clear what you're trying to do!

    That's for 1-button cast. For example when I press the button and warrior Mortal strike is ready - Mortal strike casts, when it's not ready cast Slams until MS is ready again. That's a basic example.

    But we still can get spell cooldown with "GetSpellCooldown()" and cast it with Button:SetAttribute("spell","Spellname") through Lua, why can't we make this work then? I only don't know how to describe the conditions to make it work.

    Oh, no. There is absolutely NO way to cast spell A if its off cooldown, else spell B. Intentionally.