获取没有标题的窗体是否存在

panyong 2011-09-13 01:06:02
有一个软件在关闭时会出现“正在压缩数据库...请等待xxxxxxxxx”(xx代表其他字符,里面还有换行)
我用Spy++获取他的窗体:标题文本为空, 窗体类名:#32770(固定的), 窗口句柄:6047C(这个是会变的)
获取里文字的时候 窗口句柄: B0538(这个获取每次都不一样)窗口类名:Edit,标题文本就是开头说的“正在压缩数据库...请等待xxxxxxxxx”

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long


我知道用以上函数可以获取到窗体,可这个窗体没有标题,我需要怎么编程才能得知这个窗口有没有出现,以此判断软件正在关闭
...全文
98 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
smalle 2011-10-18
  • 打赏
  • 举报
回复
1.先用GetTopWindow返回当前窗口,然后提取窗口的特征数据,如宽度、高度,其控件的标题等。
2.如果特征不符合,则用GetNextWindow取得下一个窗口(此函数可以循环调用可以返回每一个窗口)
w12wangbo 2011-10-18
  • 打赏
  • 举报
回复
这个问题比较不难解决。首先类名你可以判断一下,然后这个窗口的子窗口的数量是一定的,到时候你也判断一下,然后和这个窗口关联的exe你也可以判断一下,看看是不是对应的exe文件,就可以确定了。实在不行挨个判断子窗口的类名,小意思了。我有个窗口的工具,子窗口数目,关联的exe都可以弄出来。我编程的时候经常用,我自己编写的,5000多行代码呢。
worldy 2011-09-22
  • 打赏
  • 举报
回复
System Classes
The system registers the system classes for all processes to use. Any process can use a system class at any time. Because the system registers these classes, a process cannot destroy them.

Each Win32-based application receives its own copy of the system classes. All 16-bit Windows-based applications in the same VDM share system classes, just as they do on 16-bit Windows.

The following table describes the system classes:

Class Description
Button The class for a button.
ComboBox The class for a combo box.
ComboLBox The class for the list box contained in a combo box.
DDEMLEvent Windows NT: The class for DDEML events.
Edit The class for an edit control.
ListBox The class for a list box.
MDIClient The class for an MDI client window.
Message Windows NT 5.0 and later: The class for a message-only window.
ScrollBar The class for a scroll bar.
Static The class for a static control.
#32768 The class for a menu.
#32769 The class for the desktop window.
#32770 The class for a dialog box.
#32771 The class for the task switch window.
#32772 Windows NT: The class for icon titles.
worldy 2011-09-22
  • 打赏
  • 举报
回复
"#32770"是一个系统的窗口类
  • 打赏
  • 举报
回复
这个道理和你检测D盘文件道理一样
D:\A\B\库存\1.txt

你只要知道了窗体结构,所有窗体列出来然后比较哪个标题是空的,再比较里面的文字就好了
panyong 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 veron_04 的回复:]
既然已知窗体类名,那么使用Findwindow("类名称",vbnullstring)可以获取窗体句柄
[/Quote]
请问大哥,您说的是:窗体类名:#32770(固定的)这个吗?我也用了Findwindow("类名称",vbnullstring)

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Sub Command1_Click()
iHwnd = FindWindow("#32770", vbNullString)
If iHwnd <> 0 Then
MsgBox "存在"
Else
MsgBox "不存在"

End If
End Sub


一直提示存在 其实都没开,是这样书写吗?还是"#32770"这种类型的窗口有可能只不一个,所以才 一直提示存在
panyong 2011-09-22
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 worldy 的回复:]
System Classes
The system registers the system classes for all processes to use. Any process can use a system class at any time. Because the system registers these classes, a process cannot destroy t……
[/Quote]
大哥,能具体点吗?改怎么写代码
贝隆 2011-09-13
  • 打赏
  • 举报
回复
既然已知窗体类名,那么使用Findwindow("类名称",vbnullstring)可以获取窗体句柄

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧