用winapi32里的函数,能获取指定窗口的句柄,然后就可以得到其标题,具体怎么办自己想,只提供思路。

解决方案 »

  1.   

    findwindow function obtain the handle
    getwindowtext function obtain the window title
      

  2.   

    对了,     用FINDWINDOW如何取得最前窗口的句柄呢?
      

  3.   

    handle=GetActiveWindow()
    GetWindowText(handle, str,len(str))
      

  4.   

    handle=GetForegroundWindow()
    GetWindowText(handle, str,len(str))
      

  5.   

    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPublic Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Long注:GetForegroundWindow取得当前焦点所在的窗口
      

  6.   

    FindWindow VB声明 
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
    说明 
    寻找窗口列表中第一个符合指定条件的顶级窗口(在vb里使用:FindWindow最常见的一个用途是获得ThunderRTMain类的隐藏窗口的句柄;该类是所有运行中vb执行程序的一部分。获得句柄后,可用api函数GetWindowText取得这个窗口的名称;该名也是应用程序的标题) 
    返回值 
    Long,找到窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError 
    参数表 
    参数 类型及说明 
    lpClassName String,指向包含了窗口类名的空中止(C语言)字串的指针;或设为零,表示接收任何类 
    lpWindowName String,指向包含了窗口文本(或标签)的空中止(C语言)字串的指针;或设为零,表示接收任何窗口标题 
    注解 
    很少要求同时按类与窗口名搜索。为向自己不准备参数传递一个零,最简便的办法是传递vbNullString常数
     
    示例 
    Dim hw&, cnt&
    Dim rttitle As String * 256
    hw& = FindWindow("ThunderRT5Main", vbNullString) ' ThunderRTMain under VB4
    cnt = GetWindowText(hw&, rttitle, 255)
    MsgBox Left$(rttitle, cnt), 0, "RTMain title" GetWindowText VB声明 
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long 
    说明 
    取得一个窗体的标题(caption)文字,或者一个控件的内容(在vb里使用:使用vb窗体或控件的caption或text属性) 
    返回值 
    Long,复制到lpString的字串长度;不包括空中止字符。会设置GetLastError 
    参数表 
    参数 类型及说明 
    hwnd Long,欲获取文字的那个窗口的句柄 
    lpString String,预定义的一个缓冲区,至少有cch+1个字符大小;随同窗口文字载入 
    cch Long,lpString缓冲区的长度 
    注解 
    不能用它从另一个应用程序的编辑控件中获取文字
     
      

  7.   

    GetForegroundWindow VB声明 
    Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow" () As Long 
    说明 
    获得前台窗口的句柄。这里的“前台窗口”是指前台应用程序的活动窗口 
    返回值 
    Long,前台窗口的句柄 
    注解 
    windows nt支持多个桌面,它们相互间是独立的。每个桌面都有自己的前台窗口
     
      

  8.   

    怎样从另一个程序中获得控件比如说TEXT控件的内容呢?
      

  9.   

    哦,对了,用GetWindoeText不能获得其它程序的TEXT控件的内容的
    用发送消息好像可以,但我记不清了。不行只有用hook了
      

  10.   

    真的要用要键盘截取吗?或者FINDWINDOWEX管用,那么网页中的内容如何获取呢?
      

  11.   

    先用 GetForegroundWindow 取得当前窗口句柄,再用GetWindowText取标题
      

  12.   

    handle=GetForegroundWindow()
    GetWindowText(handle, str,len(str))
      

  13.   

    还可以用SETWINDOWTEXT来设置某个窗口的CAPTION
      

  14.   

    就是调用Api函数获得窗口句柄
    handle=GetForegroundWindow()
    GetWindowText(handle, str,len(str))
      

  15.   

    我在win98下运行编译好的vb程序,可他说“类未注册。查找对象,其CLSID为"{>00000010-0000-0010-8000-00AA006D2EA4}”还说“运行时错误713':类未注册。查找对象,其CLSID为"{>00000010-0000-0010-8000-00AA006D2EA4}”请大家帮忙看看,急,急,急
      

  16.   

    用一个函数就行了。
    GetWindowText