مشاركة عبر


كيفية القيام بما يلي: عنصر تحكم نافذة الأوامر

The CommandWindow كائن represents the الأمر نافذة في the Visual Studio automation model. You can استخدم the CommandWindow كائن إلى:

  • إدراج a الأمر في the الأمر نافذة و, optionally, ينفذ it بواسطة using the SendInput أسلوب.

  • إدراج informational نص في the الأمر نافذة بواسطة using the OutputString أسلوب.

  • مسح الجميع نص من the الأمر نافذة بواسطة using the Clear أسلوب.

في addition إلى controlling the المحتويات of the الأمر نافذة, you can also عنصر تحكم its characteristics, such كـ عرض و ارتفاع. لمزيد من المعلومات، راجع كيفية القيام بما يلي: الصفات المميزة لإطار تغيير.

ملاحظة

قد تختلف مربعات الحوار وأوامر القائمة التى تشاهدها الان عن تلك الموصوفة في التعليمات اعتماداً على الإعدادات النشطة أو الإصدار الخاص بك. تم تطوير هذه الإجراءات من خلال "إعدادات تطوير عام" النشط. To change your settings, choose Import and Export Settings on the Tools menu. لمزيد من المعلومات، راجع العمل مع إعدادات.

مثال

This مثال demonstrates how إلى مرجع و استخدم the متنوع الأعضاء of the الأمر نافذة automation model. For المزيد معلومات حول how إلى تشغيل the مثال, see كيفية القيام بما يلي: ترجمة و تشغيل أمثلة تعليمات برمجية طراز كائن للتنفيذ التلقائي.

Public Sub OnConnection(ByVal application As Object, ByVal _
  connectMode As ext_ConnectMode, ByVal addInInst As Object, _
  ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    ' Pass the applicationObject member variable to the code example.
    CommandWinExample(_applicationObject)
End Sub

Sub CommandWinExample(ByVal dte As DTE2)
    Try
        ' Get a reference to the Command window.
        Dim CW As CommandWindow = dte.ToolWindows.CommandWindow

        ' Insert informative text into the Command window.
        CW.OutputString("This takes you to the Microsoft Web site.")

        ' Add a command to the Command window and execute it.
        CW.SendInput("nav https://www.microsoft.com", True)

        ' Clear the contents of the Command window.
        MsgBox("Clearing the Command window...")
        CW.Clear()
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
public void OnConnection(object application, ext_ConnectMode 
  connectMode, object addInInst, ref Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    CommandWinExample(_applicationObject);
}

public void CommandWinExample(DTE2 dte)
{
    try
    {
        // Get a reference to the Command window.
        CommandWindow CW = dte.ToolWindows.CommandWindow;

        // Insert informative text into the Command window.
        CW.OutputString("This takes you to the Microsoft Web site.");

        // Add a command to the Command window and execute it.
        CW.SendInput("nav https://www.microsoft.com", true);

        // Clear the contents of the Command window.
        System.Windows.Forms.MessageBox.Show(
          "Clearing the Command window...");
        CW.Clear();
    }
    catch (Exception ex)
    {
        System.Windows.Forms.MessageBox.Show(ex.Message);
    }
}

راجع أيضًا:

المهام

كيفية القيام بما يلي: الصفات المميزة لإطار تغيير

كيفية القيام بما يلي: قم بإنشاء إضافة-في

الإرشادات التفصيلية: إنشاء معالج

المبادئ

مخطط نموذج كائن تلقائي

موارد أخرى

إنشاء و التحكم في بيئة Windows

إنشاء إضافة-زر 'Ins' ومعالجات

التنفيذ التلقائي والمرجع الامتداد