Bagikan melalui


Macros.Pause Method

Pauses the macro recorder so that no code is written to the macro currently being recorded. This method should not be used from within a macro.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Sub Pause
'Usage
Dim instance As Macros

instance.Pause()
void Pause()
void Pause()
function Pause()

Remarks

Pause can be useful when one macro command invokes another to perform its task, but the first command does not require or want the second command to be recorded in the macro. In this case, the first command emits code that captures the entire command's behavior.

To resume macro recording after pausing, use Resume. Pause should be used only from within add-ins.

If you invoke Pause in an Add-in while not in macro recording mode, the method does nothing, but no error occurs.

Examples

public void CodeExample(DTE2 dte, AddIn addin)
{
    // INSTRUCTIONS: Run this code, open a solution, start
    // recording a macro, then connect the add-in 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 Security

See Also

Reference

Macros Interface

Macros Members

EnvDTE Namespace

Other Resources

Automating Repetitive Actions by Using Macros