回覆列表
  • 1 # 使用者1465424935672

    1.定義一個模組, 內容為:

    Option Explicit

    Public Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long

    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

    Public Declare Function FindWindowa Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

    Public Declare Function GetForegroundWindow Lib "user32" () As Long

    Option Explicit

    Private Sub Command1_Click()

    Dim hwnd As Long

    hwnd = GetForegroundWindow " FindWindowa("Notepad", "新建 文字文件.txt - 記事本")

    Dim str1 As String, len1 As Long

    str1 = Space(255) "定義接收字串.

    GetWindowText hwnd, str1, 1024

    Do While hwnd 0

    hwnd = GetNextWindow(hwnd, 2) "只有2才表示找下一個視窗

    len1 = GetWindowText(hwnd, str1, Len(str1))

    If (InStr(1, str1, "記事", 1) > 0) Then

    MsgBox "你要的視窗找到了, 它是:" + str1

    Exit Sub "這一句看情況修改

    End If

    Loop

    MsgBox "很遣憾, 沒有你要找的視窗"

    End Sub

    3. 測試, 一定會透過..

  • 中秋節和大豐收的關聯?
  • 如何看待北大家長植竣媽媽開辦收費群,每人每年收費9980元,且不開發票不退費?