Share via


Macros.Pause 메서드

현재 기록 중인 매크로에 코드를 쓸 수 없도록 매크로 레코더를 일시 중지합니다. 매크로 내에서는 이 메서드를 사용할 수 없습니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Sub Pause
void Pause()
void Pause()
abstract Pause : unit -> unit
function Pause()

설명

Pause는 작업을 수행하기 위해 특정 매크로 명령에서 다른 명령을 호출하지만 첫 번째 명령이 필요하지 않거나 두 번째 명령을 매크로에 기록하지 않으려는 경우 유용합니다. 이런 경우 첫 번째 명령은 전체 명령의 동작을 캡처하는 코드를 생성합니다.

매크로 기록을 일시 중지한 후 다시 시작하려면 Resume을 사용합니다. Pause은 추가 기능에서만 사용할 수 있습니다.

매크로 기록 모드가 아닌 경우 추가 기능에서 Pause를 호출하면 이 메서드는 아무 작업도 수행하지 않지만 오류가 발생하지 않습니다.

예제

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 보안

참고 항목

참조

Macros 인터페이스

EnvDTE 네임스페이스

기타 리소스

Automating Repetitive Actions by Using Macros