xu25008
发表于 2010-11-1 16:00:26
用spy++可以
chenronting
发表于 2010-11-1 18:27:38
回复 15# a0204080
哈,那可不一定哦。加油, 相信自己,GOGOGO
ssjoe
发表于 2010-11-2 01:06:32
头痛啊,,问题无法解决。。。
qq123123
发表于 2010-11-2 07:02:59
匹配类的方法,应该和QQ2009登陆 窗口一样!
飘云
发表于 2010-11-2 12:30:50
为啥不能从进程着手呢,找到对应进程,进而转到对应的窗口,进而获取窗口句柄之类的
komaau3
发表于 2010-11-3 01:01:13
同情中....新手还要努力呀{:face (197):}
a0204080
发表于 2010-11-3 08:36:40
回复 20# 飘云
进程和窗口通过什么找啊?
{:face (396):}
飘云
发表于 2010-11-3 14:57:08
枚举所有窗口
#Include <WinAPI.au3>
_WinAPI_EnumWindows([$fVisible = True])
列出所有窗口的句柄,然后获取由指定窗口创建的线程标识
#Include <WinAPI.au3>
_WinAPI_GetWindowThreadProcessId($hWnd, ByRef $iPID)
然后,因为已知进程名,所以检查该指定进程是否存在.
ProcessExists ( "进程" )
成功则返回进程PID,将此PID与之前_WinAPI_GetWindowThreadProcessId获取到的PID值进行比较,相同则确定了窗口句柄,不同就继续下一个比较,直到所有窗口比较完为止,确定了窗口句柄后,可以用_WinAPI_GetWindowText获取指定窗口的标题条文本
#Include <WinAPI.au3>
_WinAPI_GetWindowText($hWnd)
这样,窗口标题就有了~
以上结论论坛搜索里都能搜到的相关的内容,另外Au3的帮助文档里也能找到,希望你学会搜索,遇到问题可以先搜搜论坛再问
飘云
发表于 2010-11-3 15:09:23
本帖最后由 飘云 于 2010-11-3 15:11 编辑
帮你找了个UDF
;===============================================================================
;
; Function Name: _ProcessGetHWnd
; Description: Returns the HWND(s) owned by the specified process (PID only !).
;
; Parameter(s): $iPid - the owner-PID.
; $iOption - Optional : return/search methods :
; 0 - returns the HWND for the first non-titleless window.
; 1 - returns the HWND for the first found window (default).
; 2 - returns all HWNDs for all matches.
;
; $sTitle - Optional : the title to match (see notes).
; $iTimeout - Optional : timeout in msec (see notes)
;
; Return Value(s):On Success - returns the HWND (see below for method 2).
; $array - number of HWNDs
; $array - title
; $array - HWND
;
; On Failure - returns 0 and sets @error to 1.
;
; Note(s): When a title is specified it will then only return the HWND to the titles
; matching that specific string. If no title is specified it will return as
; described by the option used.
;
; When using a timeout it's possible to use WinWaitDelay (Opt) to specify how
; often it should wait before attempting another time to get the HWND.
;
;
; Author(s): Helge
;
;===============================================================================
Func _ProcessGetHWnd($iPid, $iOption = 1, $sTitle = "", $iTimeout = 2000)
Local $aReturn = [], $aWin, $hTimer = TimerInit()
While 1
; Get list of windows
$aWin = WinList($sTitle)
; Searches thru all windows
For $i = 1 To $aWin
; Found a window owned by the given PID
If $iPid = WinGetProcess($aWin[$i]) Then
; Option 0 or 1 used
If $iOption = 1 OR ($iOption = 0 And $aWin[$i] <> "") Then
Return $aWin[$i]
; Option 2 is used
ElseIf $iOption = 2 Then
ReDim $aReturn
$aReturn += 1
$aReturn[$aReturn] = $aWin[$i]
$aReturn[$aReturn] = $aWin[$i]
EndIf
EndIf
Next
; If option 2 is used and there was matches then the list is returned
If $iOption = 2 And $aReturn > 0 Then Return $aReturn
; If timed out then give up
If TimerDiff($hTimer) > $iTimeout Then ExitLoop
; Waits before new attempt
Sleep(Opt("WinWaitDelay"))
WEnd
; No matches
SetError(1)
Return 0
EndFunc ;==>_ProcessGetHWnd
a0204080
发表于 2010-11-6 19:12:16
回复 24# 飘云
{:face (382):}
好是 晦涩难懂 哦……
先去 尝试 下 哦
加油 !!
xyold1
发表于 2010-11-7 09:36:26
飘云的例子很好,用API枚举窗口句柄,再对比窗口句柄对应的窗口名和进程名就能得到想要的窗口了
a0204080
发表于 2010-11-8 16:42:28
{:1_597:}哈哈获取到了!!#include <WinAPI.au3>
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
Local $aWindows, $i, $text
$aWindows = _WinAPI_EnumWindows()
For $i = 1 To $aWindows
$text = "Window Handle: " & $aWindows[$i] & @LF
$text &= "Window Class: " & $aWindows[$i] & @LF
$text &= "Window Title: " & WinGetTitle($aWindows[$i]) & @LF
$text &= "Window Text: " & WinGetText($aWindows[$i]) & @LF
$text &= "Window Process: " & WinGetProcess($aWindows[$i])
MsgBox(0, "Item " & $i & " of " & $aWindows, $text)
Next
EndFunc 一个一个 终于 找到 了
谢谢 飘云!!
谢谢关注 这个 帖子的 人……
a0204080
发表于 2010-11-8 16:44:17
成功的 图片 不会上传……
{:1_552:}
独孤伊狼
发表于 2011-8-2 00:19:19
你找到窗口标题又如何?你又不能操作内存!白费力气!
cheng8457
发表于 2011-8-18 06:26:09
我也好想知道唷~_~