小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

獲取 標(biāo)題窗口有空格,類名稱是亂碼的窗口句柄方法

 你喜歡那個 2012-05-06

1、建立一個標(biāo)準(zhǔn)工程

2、添加一個標(biāo)準(zhǔn)模塊

3、再工程里添加一個listbox列表框

4、添加2個command   1個timer

將下面代碼復(fù)制到,標(biāo)準(zhǔn)模塊內(nèi)

Option Explicit

Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam 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


'該函數(shù)是EnumWindows的回調(diào)函數(shù),EnumWindows函數(shù)將遍歷的窗口句柄傳遞到hwnd參數(shù)中
Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
  Dim astr As String * 256
  Dim L As Long
  
  L = GetWindowText(hwnd, astr, Len(astr))  '得到窗口的標(biāo)題
  If InStr(astr, " ") > 1 Then
        If InStr(LCase(astr), LCase("你要查找的標(biāo)題-關(guān)鍵字")) > 0 And InStr(LCase(astr), LCase(" - ")) = 0 Then   '將關(guān)鍵字換成你的就行了
            
            Form1.Combo1.AddItem Left(astr, InStr(1, astr, Chr(0)) - 1) & vbCrLf & hwnd
        End If
  End If
  EnumWindowsProc = True
End Function


5、將下面代碼復(fù)制到form1模塊內(nèi)(窗體模塊內(nèi))

Option Explicit

Private Sub Command1_Click()
    Timer1.Enabled = True  '啟動開查找時鐘
End Sub

Private Sub command2_click()
    Timer1.Enabled = False   '停止開始查找時鐘
End Sub

Private Sub Timer1_Timer()
    Call RefreshList
End Sub
Sub RefreshList()
    On Error Resume Next
    Dim L As Long
    Dim k As Long
    k = Combo1.ListIndex
    Combo1.Clear
    L = EnumWindows(AddressOf EnumWindowsProc, 0)
    If Combo1.ListCount > 0 Then Combo1.ListIndex = k

End Sub

6、將查找關(guān)鍵字換成你要查找的關(guān)鍵字,運(yùn)行即可,獲得窗體名稱與句柄。

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多