Detect if active window is full screen or not

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
unaindz
Posts: 4
Joined: 01 May 2017, 05:31

Detect if active window is full screen or not

Post by unaindz » 07 May 2017, 13:01

How can I do this? I am so lost with this. I have been trying this for a week but without any result.

User avatar
MilesAhead
Posts: 232
Joined: 03 Oct 2013, 09:44

Re: Detect if active window is full screen or not

Post by MilesAhead » 07 May 2017, 13:31

Searching I came across this thread: https://autohotkey.com/board/topic/3888 ... plication/
"My plan is to ghostwrite my biography. Then hire another writer to put his
name on it and take the blame."

- MilesAhead

partof
Posts: 110
Joined: 16 Jan 2016, 08:38

Re: Detect if active window is full screen or not

Post by partof » 13 Dec 2017, 05:05

it's simple. You just need to find a color specific to full-creen (or not full screen). For exemple on full-screen I see the red cross yo close the chrome window, full screen is white.

You find all the info needed in the windows spy tool

Code: Select all

; put the mouse on the right top corner of the screen, freeze the spy tool, copy past the relative position (1357, 6 ).
PixelGetColor ColorWin, 1357, 6 RGB  ; get the color of this area
; In my case this part should be white in full screen
if (ColorWin!="0xFFFFFF")   ; if it's white (= fullscreen is OFF)
	send {f11};  then press f11 to activate fullscreen

User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Detect if active window is full screen or not

Post by jeeswg » 13 Dec 2017, 06:14

By comparing window positions/styles when the screen is/isn't fullscreen, I found some information, that could be used to identify whether or not the screen is fullscreen.

Code: Select all

q:: ;window - get info
WinGetPos, vWinX, vWinY, vWinW, vWinH, A
WinGet, vWinStyle, Style, A
WinGet, vWinExStyle, ExStyle, A
vOutput := Format("x{} y{} w{} h{}", vWinX, vWinY, vWinW, vWinH)
vOutput .= "`r`n" Format("{},{},{},{}", vWinX, vWinY, vWinW, vWinH)
vOutput .= "`r`n" Format("0x{:08X} 0x{:08X}", vWinStyle, vWinExStyle)

Clipboard := vOutput
MsgBox, % vOutput
return

;e.g. screen dimensions
;1280,720
;e.g. Media Player Classic
;maximised: -8,-8,1296,696 0x15CFC000 0x00000110
;fullscreen: 0,0,1280,720 0x150BC000 0x00000018
;e.g. Internet Explorer:
;maximised: -8,-8,1296,696 0x17CF0000 0x00000100
;fullscreen: 0,0,1280,720 0x170A0000 0x00000000

;maximised style: 0xC00000 ;WS_CAPTION := 0xC00000
;maximised style: 0x40000 ;WS_THICKFRAME := 0x40000
;maximised ex. style: 0x100 ;WS_EX_WINDOWEDGE := 0x100

w:: ;window - is fullscreen?
WinGetPos, vWinX, vWinY, vWinW, vWinH, A
WinGet, vWinStyle, Style, A
WinGet, vWinExStyle, ExStyle, A

vRet := ("0,0," A_ScreenWidth "," A_ScreenHeight = Format("{},{},{},{}", vWinX, vWinY, vWinW, vWinH))
MsgBox, % "is fullscreen: " (vRet ? "y" : "n")

vRet := !(vWinStyle & 0xC00000 = 0xC00000) ;WS_CAPTION := 0xC00000
MsgBox, % "is fullscreen: " (vRet ? "y" : "n")

vRet := !(vWinStyle & 0x40000) ;WS_THICKFRAME := 0x40000
MsgBox, % "is fullscreen: " (vRet ? "y" : "n")

vRet := !(vWinExStyle & 0x100) ;WS_EX_WINDOWEDGE := 0x100
MsgBox, % "is fullscreen: " (vRet ? "y" : "n")
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: Detect if active window is full screen or not

Post by LAPIII » 28 Sep 2022, 16:28

What I want to do is, if an active window is not full-screen then take an active window screen shot and if it is full-screen then take a screenshot. I need help though:

Code: Select all

w:: ;window - is fullscreen?
WinGetPos, vWinX, vWinY, vWinW, vWinH, A
WinGet, vWinStyle, Style, A
WinGet, vWinExStyle, ExStyle, A

vRet := ("0,0," A_ScreenWidth "," A_ScreenHeight = Format("{},{},{},{}", vWinX, vWinY, vWinW, vWinH))
WinGet, Style, Style, My Window Title
if (Style & 0x8000000)  ; 0x8000000 is WS_DISABLED.
    {
    Send ![Printscreen]
    }
else {
Send [Printscreen] ; or check if 0x8 is WS_EX_TOPMOST
}

Post Reply

Return to “Ask for Help (v1)”