关于找到窗口的问题!!急!!

wuyuesisi 2003-12-12 09:20:09
某程序,其窗口标题为一段固定字符串后接一不断变化的百分比(???%……),而其类名的后面部分也随每次运行而不同(例如第一次运行为“ABCDE:4683”,第二次变成“ABCDE:1546”……)。请问如何返回其窗口的句柄??
...全文
72 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gototry 2004-01-02
  • 打赏
  • 举报
回复
楼主能不能把那更好的解决办法告诉我,我也遇到同样的问题了,高分相求
wuyuesisi 2003-12-31
  • 打赏
  • 举报
回复
枚举的确很慢……………………
已找到更好的解决方法。多谢。
wuyuesisi 2003-12-16
  • 打赏
  • 举报
回复
引用:“用EnumWindows枚举,在回调中用GetClassName得到类名,用left截断,和“ABCDE”比较”

以上。“比较”部分是关键,可否详细一点??
goodname008 2003-12-13
  • 打赏
  • 举报
回复
什么样的程序?能再具体一些吗?
获得那个百分比和类名后面的不同部分可行吗?
goodname008 2003-12-13
  • 打赏
  • 举报
回复
有时可能会很慢。 :(
rainstormmaster 2003-12-13
  • 打赏
  • 举报
回复
用EnumWindows枚举,在回调中用GetClassName得到类名,用left截断,和“ABCDE”比较

EnumWindows的例子:
'窗体
Private Sub Form_Load()
'Set the form's graphics mode to persistent
Me.AutoRedraw = True
'call the Enumwindows-function
EnumWindows AddressOf EnumWindowsProc, ByVal 0&
End Sub

'模块
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim sSave As String, Ret As Long
Ret = GetWindowTextLength(hwnd)
sSave = Space(Ret)
GetWindowText hwnd, sSave, Ret + 1
Form1.Print Str$(hwnd) + " " + sSave
'continue enumeration
EnumWindowsProc = True
End Function
踏平扶桑 2003-12-13
  • 打赏
  • 举报
回复
查找运行的程序的窗体名称,然后在进行比较

1,488

社区成员

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

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