找回密码
 加入
搜索
查看: 2053|回复: 8

[AU3基础] 程序自身的窗口标题是动态的,如何获得自身状态

  [复制链接]
发表于 2010-12-31 16:45:28 | 显示全部楼层 |阅读模式
程序自身的窗口标题是动态的,如何获得自身是最小化、最大化状态,请高人指点,谢谢!
发表于 2010-12-31 17:03:09 | 显示全部楼层
WinGetState(hwnd)
无论标题怎样变化,句柄总是不变的
发表于 2010-12-31 17:34:19 | 显示全部楼层
二楼果然是强人,这个问题我一直在想呢
 楼主| 发表于 2010-12-31 21:28:11 | 显示全部楼层
WinGetHandle 获得窗口句柄也是要窗口标题啊。。
怎么办啊
 楼主| 发表于 2010-12-31 21:50:02 | 显示全部楼层
回复 2# ceoguang

给个例子,谢谢!
发表于 2010-12-31 22:07:36 | 显示全部楼层
获得窗口句柄有很多方法 搜索下论坛呗
 楼主| 发表于 2010-12-31 23:57:21 | 显示全部楼层
回复 6# sxd
方法是有很多,没搜索到像我这种情况的。
发表于 2011-1-1 02:31:22 | 显示全部楼层
回复 4# 83265358
While 1
        $handle = WinGetHandle("")
        If $handle<>"" Then ExitLoop
        Sleep(10)
WEnd

Exit( MsgBox(0,0,$handle) )
发表于 2011-1-1 10:03:41 | 显示全部楼层
本帖最后由 ceoguang 于 2011-1-1 13:10 编辑
WinGetHandle 获得窗口句柄也是要窗口标题啊。。
怎么办啊
83265358 发表于 2010-12-31 21:28

Win*及control*系统函数没说一定要用窗口标题,直接用句柄也是可以的,而且更高效及准确.

#include <WinAPI.au3>
$PID = ProcessExists("chrome.exe")
$hwnd = _GetProcessWindowHwnd($PID ) ;取谷歌浏览器的主窗口
MsgBox(64, "进程ID: " & $PID , "进程的主窗口句柄为: " & $hwnd & @LF & "窗口标题为: " & WinGetTitle($hwnd))

Func _GetProcessWindowHwnd($ProcessId)
        Local $aWindows, $i, $iPid
        $aWindows = WinList();取所有顶层窗口
        For $i = 1 To $aWindows[0][0]
                If $aWindows[$i][0] <> "" And _WinAPI_IsWindowVisible($aWindows[$i][1]) Then
                        _WinAPI_GetWindowThreadProcessId($aWindows[$i][1], $iPid);取窗口的PID
                        If $iPid = $ProcessId Then
                                Return $aWindows[$i][1];返回目标窗口的句柄
                        EndIf
                EndIf
        Next
        Return SetError(0,0,"")
        ;成功,返回窗口句柄,失败返回空
EndFunc   ;==>_GetProcessHwnd
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-27 01:05 , Processed in 0.080083 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表