0

次のコードの問題を理解できません -

i = 15
While (i < 100)
    If i Mod 2 = 0 Then
        handle = FindWindow(vbNullString, "My Details - Windows Internet Explorer")
        Range("A1").Value = handle
        BringWindowToTop handle
        Application.Wait DateAdd("s", 1, Now)
    Else
        handle1 = FindWindow(vbNullString, "Codeomnitrix - Outlook Web App - Mozilla Firefox")
        Range("A2").Value = handle1
        BringWindowToTop handle1
        Application.Wait DateAdd("s", 1, Now)
    End If

    i = i + 15
Wend

両方のウィンドウを切り替えて、1 秒までフォーカスを合わせる必要がありますが、実際には、Firefox を一番上に置くだけで、切り替えはありません。

ありがとう

4

2 に答える 2

1

Autoit の使用を検討している場合、これは非常に簡単です。

autoit dll への参照を追加します。

ここに画像の説明を入力

オートイットをダウンロード

Sub test()

   Dim oAutoit As New AutoItX3
   oAutoit.Opt "WinTitleMatchMode", 2  ' Match any substring in the title
   oAutoit.WinActivate "My Details - Windows Internet Explorer" ' Activates (gives focus to) a window.

End Sub
于 2013-07-18T06:53:20.853 に答える
0

起動時に最小化されたウィンドウがポップアップしないことがわかりました。

Private Declare Function GetWindowPlacement Lib _
        "user32" (ByVal hwnd As Integer, _
        ByRef lpwndpl As WINDOWPLACEMENT) As Integer
Private Declare Function SetWindowPlacement Lib "user32" _
       (ByVal hwnd As Integer, ByRef lpwndpl As WINDOWPLACEMENT) As Integer

Private Const SW_SHOWMINIMIZED As Short = 2
Private Const SW_SHOWMAXIMIZED As Short = 3
Private Const SW_SHOWNORMAL As Short = 1

Private Structure WINDOWPLACEMENT
    Dim length As Integer
    Dim flags As Integer
    Dim showCmd As Integer
    Dim ptMinPosition As POINTAPI
    Dim ptMaxPosition As POINTAPI
    Dim rcNormalPosition As RECT
End Structure

[...]

Dim handle As Integer
Dim wp As WINDOWPLACEMENT

handle = FindWindow(vbNullString, "My Details - Windows Internet Explorer")
GetWindowPlacement(handle, wp)
wp.showCmd = SW_SHOWNORMAL
SetWindowPlacement(handle, wp)

これはすべてCodeproject の記事からコピーして、ウィンドウを復元します。

于 2013-07-18T07:57:46.830 に答える