获取没有标题的窗体是否存在有一个软件在关闭时会出现“正在压缩数据库...请等待xxxxxxxxx”(xx代表其他字符
获取没有标题的窗体是否存在
有一个软件在关闭时会出现“正在压缩数据库...请等待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
我知道用以上函数可以获取到窗体,可这个窗体没有标题,我需要怎么编程才能得知这个窗口有没有出现,以此判断软件正在关闭
[解决办法]既然已知窗体类名,那么使用Findwindow("类名称",vbnullstring)可以获取窗体句柄
[解决办法]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.
[解决办法]这个问题比较不难解决。首先类名你可以判断一下,然后这个窗口的子窗口的数量是一定的,到时候你也判断一下,然后和这个窗口关联的exe你也可以判断一下,看看是不是对应的exe文件,就可以确定了。实在不行挨个判断子窗口的类名,小意思了。我有个窗口的工具,子窗口数目,关联的exe都可以弄出来。我编程的时候经常用,我自己编写的,5000多行代码呢。
[解决办法]1.先用GetTopWindow返回当前窗口,然后提取窗口的特征数据,如宽度、高度,其控件的标题等。
2.如果特征不符合,则用GetNextWindow取得下一个窗口(此函数可以循环调用可以返回每一个窗口)