MSDN

.NET API Documentation

AppActivate Method

Activates an application window.

Namespace

Microsoft.VisualBasic

Assembly

Microsoft.VisualBasic.dll

Syntax

Public Sub AppActivate (title As String)
Public Sub AppActivate (processId As Integer)

Parameters

NameTypeDescription
titleStringThe title of the window to activate. Partial titles are allowed.
processIdIntegerThe ID of the process that owns the window to activate.

Return Value

This method does not return a value.

Remarks

Exceptions

ExceptionCondition
ArgumentExceptionNo window with the specified title is found.
ArgumentOutOfRangeExceptionThe processId does not correspond to an existing process.

Example

Activate Notepad using its window title:

Imports Microsoft.VisualBasic

Module Example
    Sub Main()
        ' Launch Notepad
        Process.Start("notepad.exe")
        System.Threading.Thread.Sleep(500) ' wait for the window to appear

        ' Activate the Notepad window
        Interaction.AppActivate("Untitled - Notepad")
    End Sub
End Module

Related Topics