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

[GUI管理] 全屏检测怎么解决在桌面时也有效

  [复制链接]
发表于 2017-4-26 12:01:49 | 显示全部楼层 |阅读模式
我这有几个可以判断是否有全屏窗体的代码,但是都把桌面也当成全屏了,请问怎么才能在桌面时不判定成全屏,例如:
#include <WinAPI.au3>

Global $Struct = DllStructCreate($tagPoint)
Global $WindowsWidth = _WinAPI_GetSystemMetrics(0)
Global $WindowsHeight = _WinAPI_GetSystemMetrics(1)

While 1
        Sleep(100)
        If IsFullWindow() Then ;全屏
                MsgBox(0, "", "有全屏")
        EndIf
WEnd

Func IsFullWindow() ;检测当前窗口是否全屏,是:返回1,否则返回0
        Pos()
        $hwnd = _WinAPI_WindowFromPoint($Struct)
        If $hwnd = _WinAPI_GetDesktopWindow() Then Return 0 ;不检测资源管理器
        $tRect = _WinAPI_GetWindowRect($hwnd)
        $iLeft = DllStructGetData($tRect, "Left")
        $iTop = DllStructGetData($tRect, "Top")
        $iRight = DllStructGetData($tRect, "Right")
        $iBottom = DllStructGetData($tRect, "Bottom")
        If $WindowsWidth <= $iRight - $iLeft And $WindowsHeight <= $iBottom - $iTop Then Return 1
        Return 0
EndFunc   ;==>IsFullWindow

Func Pos()
        DllStructSetData($Struct, "x", MouseGetPos(0))
        DllStructSetData($Struct, "y", MouseGetPos(1))
EndFunc   ;==>Pos
 楼主| 发表于 2017-4-26 23:31:04 | 显示全部楼层
没有人遇到过吗?自己顶
发表于 2017-4-26 23:36:07 | 显示全部楼层
回复 2# sh1536


    怎麼用啊  我執行後沒反應??
发表于 2017-4-27 07:54:24 | 显示全部楼层
里面那不是有排除桌面的语句么
发表于 2017-4-27 08:43:46 | 显示全部楼层
#include <WinAPI.au3>
Global $Struct = DllStructCreate($tagPoint)
Global $WindowsWidth = _WinAPI_GetSystemMetrics(0)
Global $WindowsHeight = _WinAPI_GetSystemMetrics(1)
Local $array = _WinAPI_EnumWindows(True), $hDesktop
For $i = 1 To $array[0][0]
        If _WinAPI_GetClassName(_WinAPI_GetParent($array[$i][0])) = 'SHELLDLL_DefView' Then
                $hDesktop = _WinAPI_GetParent(_WinAPI_GetParent($array[$i][0]))
                ExitLoop
        EndIf
Next
While 1
        Sleep(100)
        If IsFullWindow() Then ;全屏
                MsgBox(0, "", "有全屏")
        EndIf
WEnd
Func IsFullWindow() ;检测当前窗口是否全屏,是:返回1,否则返回0
        Pos()
        $hwnd = _WinAPI_WindowFromPoint($Struct)
;~         If $hwnd = _WinAPI_GetDesktopWindow() Then Return 0 ;不检测资源管理器
        If $hwnd = $hDesktop Then Return 0 ;不检测资源管理器
        $tRect = _WinAPI_GetWindowRect($hwnd)
        $iLeft = DllStructGetData($tRect, "Left")
        $iTop = DllStructGetData($tRect, "Top")
        $iRight = DllStructGetData($tRect, "Right")
        $iBottom = DllStructGetData($tRect, "Bottom")
        If $WindowsWidth < $iRight - $iLeft And $WindowsHeight < $iBottom - $iTop Then Return 1
        Return 0
EndFunc   ;==>IsFullWindow
Func Pos()
        DllStructSetData($Struct, "x", MouseGetPos(0))
        DllStructSetData($Struct, "y", MouseGetPos(1))
EndFunc   ;==>Pos
发表于 2017-4-27 09:17:08 | 显示全部楼层
回复 5# haijie1223

怎麼我執行後 都沒反應??  作業系統問題嗎??
发表于 2017-4-27 10:23:32 | 显示全部楼层
回复 6# kk_lee69


    你把任务栏隐藏,然后把窗口最大化就有反应了。
发表于 2017-4-27 10:37:54 | 显示全部楼层
回复 7# haijie1223

哈哈  ~~ 果然ㄟ

我從不 隱藏任務攔的   難怪沒反應  呵呵
 楼主| 发表于 2017-4-27 12:09:52 | 显示全部楼层
回复 5# haijie1223


    感谢版主的回复,一般情况下用户的任务栏都不隐藏啊
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-20 14:37 , Processed in 0.078262 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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