在模块中加入
 Option Explicit#If Win16 Then
   DefInt A-Z
   ' Required Win16 API declarations
   Private Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
   Public Declare Function SetActiveWindow Lib "User" (ByVal hwnd As Integer) As Integer
   Public Declare Function ShowWindow Lib "User" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
   Private Declare Function GetWindow Lib "User" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
   Private Declare Function GetWindowText Lib "User" (ByVal hwnd As Integer, ByVal lpString As String, ByVal aint As Integer) As Integer
   Private Declare Function GetParent Lib "User" (ByVal hwnd As Integer) As Integer
   Public Declare Function IsIconic Lib "User" (ByVal hwnd As Integer) As Integer
#ElseIf Win32 Then
   DefLng A-Z
   ' Required Win32 API declarations
   Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
   Public Declare Function SetActiveWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
   Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
   Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
   Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
   Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
   Public Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long
#End If
Public Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const HWND_TOPMOST = -1
'Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_NOTOPMOST = -2' Constants used with APIs
Public Const SW_RESTORE = 9' Constant used by GetWindowWord to find next window
Public Const GW_HWNDNEXT = 2' Constants used by FindWindowPartial
Public Const FWP_STARTSWITH = 0
Public Const FWP_CONTAINS = 1Public Sub AppActivatePartial(TitleContains$, Method%)
   Dim hWndApp 'As SysInt
   Dim nRet As Long
   '
   ' Retrieve window handle for first top-level window
   ' that starts with or contains the passed string.
   '
   hWndApp = FindWindowPartial(TitleContains, Method)
   If hWndApp Then
      '
      ' Switch to it, restoring if need be.
      '
      If IsIconic(hWndApp) Then
         Call ShowWindow(hWndApp, SW_RESTORE)
      End If
      nRet = SetActiveWindow(hWndApp)
      SendKeys "abAFLJASLDFJALSDFJLADSJFSJDALSJDc" & vbCrLf
   Else
      '
      ' Alert user that request failed.
      '
      MsgBox "No matching applications found."
   End If
End SubPublic Function FindWindowPartial(TitleStart$, Method%) As Long
   Dim hWndTmp 'As SysInt
   Dim nRet 'As SysInt
   Dim TitleTmp As String
   '
   ' Find first window and loop through all subsequent
   ' windows in master window list.
   '
   hWndTmp = FindWindow(vbNullString, vbNullString)
   Do Until hWndTmp = 0
      '
      ' Make sure this window has no parent.
      '
      If GetParent(hWndTmp) = 0 Then
         '
         ' Retrieve caption text from current window.
         '
         TitleTmp = Space(256)
         nRet = GetWindowText(hWndTmp, TitleTmp, Len(TitleTmp))
         If nRet Then
            '
            ' Clean up return string, preparing for
            ' case-insensitive comparison.
            '
            TitleTmp = UCase(Left(TitleTmp, nRet))
            '
            ' Use appropriate method to determine if
            ' current window's caption either starts
            ' with or contains passed string.
            '
            Select Case Method
               Case FWP_STARTSWITH
                  If InStr(TitleTmp, UCase(TitleStart)) = 1 Then
                     FindWindowPartial = hWndTmp
                     Exit Do
                  End If
               Case FWP_CONTAINS
                  If InStr(TitleTmp, UCase(TitleStart)) Then
                     FindWindowPartial = hWndTmp
                     Exit Do
                  End If
            End Select
         End If
      End If
      '
      ' Get next window in master window list and continue.
      '
      hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT)
   Loop
End Function
Private Sub Command1_Click()
  dim  conf As ConfigClass
  dim hwnd as long
  conf.title="你应用程序的标题"'就是form.caption的内容
  hwnd = FindWindowPartial(conf.title, 0)
  SetActiveWindow (hwnd)
end sub