ウィンドウハンドルを見つけ、したがって、上記の機能を使用すると、のような何かを行うことができるはずですSetForegroundWindow
Public Function FindWindowByPartialTitle(ByVal _
TestFlex_string As String) As Long
m_TestFlexString = TestFlex_string
m_TestFlexHwnd = 0
' Enumerate windows.
EnumWindows AddressOf EnumCallback, 0
' Return the hWnd found (if any).
FindWindowByPartialTitle = m_TestFlexHwnd
End Function
' Check a returned task to see if it's the one we want.
Public Function EnumCallback(ByVal app_hWnd As Long, ByVal _
param As Long) As Long
Dim buf As String
Dim title As String
Dim Length As Long
' Get the window's title.
Length = GetWindowTextLength(app_hWnd)
buf = Space$(Length)
Length = GetWindowText(app_hWnd, buf, Length)
title = Left$(buf, Length)
' See if the title contains the TestFlex string.
If InStr(title, m_TestFlexString) <> 0 Then
' This is the one we want.
m_TestFlexHwnd = app_hWnd
' Stop searching.
EnumCallback = 0
Else
' Continue searching.
EnumCallback = 1
End If
End Function
を呼び出す:だけでなくSetForegroundWindow decalreすることを忘れないでください
Dim saveAsHwnd as Long
call saveAsHwnd = FindWindowByPartialTitle("Save")
call SetForegroundWindo(saveAsHwnd)
を:
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long