找回密码
 加入
搜索
查看: 1734|回复: 5

[AU3基础] 如果此参数为 0, 则本函数相当于 _WinAPI_EnumWindows()?[已解决]

[复制链接]
发表于 2016-12-13 12:26:12 | 显示全部楼层 |阅读模式
本帖最后由 cashiba 于 2017-3-18 09:30 编辑


如上。
如下:
#include <WinAPISys.au3>
#include <Array.au3>
#include <WinAPI.au3>

local $srr=_WinAPI_EnumChildWindows(0)
if @error then
        msgbox(4096,"提示","发生错误",3)
        ;exit
EndIf
_ArrayDisplay($Srr)
;以上运行后无反应无结果。
;以下运行后有正常结果。
Local $srr = _WinAPI_EnumWindows()
_ArrayDisplay($Srr)
为什么效果不一样?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2016-12-13 12:41:20 | 显示全部楼层
本帖最后由 tubaba 于 2016-12-13 12:44 编辑

從 include 文件来看,应该是解释有误,或者是翻译错误,此hwnd如果=_WinAPI_GetDesktopWindow(),那么
函數相當於_WinAPI_EnumWindows(),即
#include <WinAPISys.au3>
#include <Array.au3>
#include <WinAPI.au3>

local $srr=_WinAPI_EnumChildWindows(_WinAPI_GetDesktopWindow())
if @error then
        msgbox(4096,"提示","发生错误",3)
        ;exit
EndIf
_ArrayDisplay($Srr)
;以上运行后无反应无结果。
;以下运行后有正常结果。
Local $srr = _WinAPI_EnumWindows()
_ArrayDisplay($Srr)


或者

Func _WinAPI_EnumChildWindows($hWnd, $bVisible = True)
if $hWnd=0 then $hWnd=_WinAPI_GetDesktopWindow();在原函數加上這一行
        If Not _WinAPI_GetWindow($hWnd, 5) Then Return SetError(2, 0, 0) ; $GW_CHILD

        Local $hEnumProc = DllCallbackRegister('__EnumWindowsProc', 'bool', 'hwnd;lparam')

        Dim $__g_vEnum[101][2] = [[0]]
        DllCall('user32.dll', 'bool', 'EnumChildWindows', 'hwnd', $hWnd, 'ptr', DllCallbackGetPtr($hEnumProc), 'lparam', $bVisible)
        If @error Or Not $__g_vEnum[0][0] Then
                $__g_vEnum = @error + 10
        EndIf
        DllCallbackFree($hEnumProc)
        If $__g_vEnum Then Return SetError($__g_vEnum, 0, 0)

        __Inc($__g_vEnum, -1)
        Return $__g_vEnum
EndFunc   ;==>_WinAPI_EnumChildWindows
 楼主| 发表于 2016-12-13 13:15:03 | 显示全部楼层
谢谢tubaba老师指点!

刚看到这些函数,在练习中......遇到的问题.
以为自己写法有误,还没怀疑到原函数或帮助文件解释错误的问题。
 楼主| 发表于 2016-12-13 13:20:22 | 显示全部楼层
另外,这两个函数分别来自于两个自定义函数群
#include <WinAPISys.au3>
_WinAPI_EnumChildWindows

#include <WinAPI.au3>
_WinAPI_EnumWindows
在函数构造机制上有差别吗?
发表于 2016-12-13 17:09:54 | 显示全部楼层
從 include 文件来看,应该是解释有误,或者是翻译错误,此hwnd如果=_WinAPI_GetDesktopWindow(),那么
函數相 ...
tubaba 发表于 2016-12-13 12:41


检查了下, 翻译没有问题, 看来应该是官方文档描述错误.........
 楼主| 发表于 2016-12-13 20:35:42 | 显示全部楼层
_WinAPI_EnumChildWindows
_WinAPI_EnumWindows
看到这两个函数的时候,就在想,
既然_WinAPI_EnumWindows是_WinAPI_EnumChildWindows的特例,
那么完全可以只用_WinAPI_EnumChildWindows.......

不太懂API
问下大神们:
_WinAPI_EnumChildWindows能完全代替_WinAPI_EnumWindows吗?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-18 08:57 , Processed in 0.088795 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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