sh1536 发表于 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

sh1536 发表于 2017-4-26 23:31:04

没有人遇到过吗?自己顶

kk_lee69 发表于 2017-4-26 23:36:07

回复 2# sh1536


    怎麼用啊我執行後沒反應??

haijie1223 发表于 2017-4-27 07:54:24

里面那不是有排除桌面的语句么

haijie1223 发表于 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
        If _WinAPI_GetClassName(_WinAPI_GetParent($array[$i])) = 'SHELLDLL_DefView' Then
                $hDesktop = _WinAPI_GetParent(_WinAPI_GetParent($array[$i]))
                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

kk_lee69 发表于 2017-4-27 09:17:08

回复 5# haijie1223

怎麼我執行後 都沒反應??作業系統問題嗎??

haijie1223 发表于 2017-4-27 10:23:32

回复 6# kk_lee69


    你把任务栏隐藏,然后把窗口最大化就有反应了。

kk_lee69 发表于 2017-4-27 10:37:54

回复 7# haijie1223

哈哈~~ 果然ㄟ

我從不 隱藏任務攔的   難怪沒反應呵呵

sh1536 发表于 2017-4-27 12:09:52

回复 5# haijie1223


    感谢版主的回复,一般情况下用户的任务栏都不隐藏啊
页: [1]
查看完整版本: 全屏检测怎么解决在桌面时也有效