Share via


Macros.IsRecording 屬性

傳回巨集錄製器目前是否正在錄製動作 這個方法不應從巨集內使用。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
ReadOnly Property IsRecording As Boolean
    Get
bool IsRecording { get; }
property bool IsRecording {
    bool get ();
}
abstract IsRecording : bool
function get IsRecording () : boolean

屬性值

型別:System.Boolean
布林值為 true 表示巨集錄製器目前正在錄製動作,false 則表示巨集錄製器未進行錄製動作。

備註

IsRecording 只應從增益集而不應從巨集內使用。

範例

public void CodeExample(DTE2 dte, AddIn addin)
{
    // INSTRUCTIONS: Run this code, open a solution, start
    // recording a macro, then connect the addin containing this code.
    try
    {
        Macros mac = dte.Macros;
        if (mac.IsRecording)
        {
            mac.Pause();
            if (!mac.IsRecording)
                mac.Resume();
            mac.EmitMacroCode("rem Code added by the EmitMacroCode method");
            // Demonstrate these two properties return the same reference.
            bool test = mac.DTE.Equals(mac.Parent);
            if (test) MessageBox.Show("The DTE and Parent property refer to the same object.");
            else MessageBox.Show("The DTE and Parent property do not refer to the same object.");
        }
        else MessageBox.Show("Start a macro recording session and reconnect addin");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework 安全性

請參閱

參考

Macros 介面

EnvDTE 命名空間

其他資源

使用巨集自動執行重複的動作