Foxtable(狐表)用户栏目专家坐堂 → 关于ShowAppWindow


  共有2507人关注过本帖树形打印复制链接

主题:关于ShowAppWindow

帅哥哟,离线,有人找我吗?
lswwsl
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:183 积分:1733 威望:0 精华:0 注册:2012/2/27 15:00:00
关于ShowAppWindow  发帖心情 Post By:2015/10/11 17:25:00 [只看该作者]

如题,请问如何获取QQ对话窗口的标题以方便使用ShowAppWindow最小化?是QQ好友聊天窗口而非QQ主程序。

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/11 19:48:00 [只看该作者]

汗,测试了一下,没有完善的方法,只能大致获取,参考代码

 

全局代码

 

Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As EnumWindowsProc, ByVal lParam As Integer) As Integer

Public Delegate Function   EnumWindowsProc(ByVal   hwnd   As   Integer,   ByVal   lParam   As   Integer)   As   Boolean

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

<DllImport("user32.dll")> _
Public Function GetWindowTextLength(hWnd As Integer) As Integer
End Function

Public Function EnumWindowsProcCallBack(ByVal   hwnd   As   Integer,   ByVal   lParam   As   Integer)   As   Boolean
      Return Functions.Execute("EnumWindowsProcCallBack", hwnd, lparam)
End   Function

<DllImport("user32.dll")> _
Public Function GetWindowThreadProcessId(hWnd As Integer, ByRef pid As Integer) As Integer
End Function

 

内部函数 EnumWindowsProcCallBack

 

Dim hwnd As Integer = args(0)

Dim len As Integer = GetWindowTextLength(hWnd) + 1
Dim s As new StringBuilder(len)
If GetWindowText(hwnd, s, len ) > 0 Then
    Dim pid As Integer
    GetWindowThreadProcessId(hwnd, pid)
    If vars("ls").contains(pid) Then
        output.show(s.Tostring)
    End If
End If
Return True

 

调用代码

 

vars("ls") = new List(Of String)
Dim ps As  System.Diagnostics.Process() = System.Diagnostics.Process.GetProcessesByName("QQ")
For Each p As System.Diagnostics.Process In ps
    vars("ls").add(p.id)
Next

Dim CallBack As New EnumWindowsProc(AddressOf EnumWindowsProcCallBack)
EnumWindows(CallBack, 0)


 回到顶部