Completely hiding a GUI does not work v2.0.2

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
GothicIII
Posts: 20
Joined: 17 May 2022, 04:16

Completely hiding a GUI does not work v2.0.2

Post by GothicIII » 13 Jan 2023, 09:15

Hello again,

I upgraded AHK to v2.0.2 from v2.0b-4 and just realized that my hidden GUI does not work anymore.

I am spawning an Edge browser session pointing to a local page and using that to execute JS code. I do this for websocket communication for the StreamDeck library I just released.

Here is a code snippet:

Code: Select all

EmptyWindow := Gui("+Owner")
		EmptyWindow.Show()
		Webbrowser := Gui("+Parent" EmptyWindow.Hwnd)
		webpage := Webbrowser.Add("ActiveX",, "Shell.Explorer").value
		webpage.navigate("about:<!DOCTYPE html><meta http-equiv='X-UA-Compatible' content='IE=edge'><body></body>")
		Webbrowser.Show()
With #NoTrayIcon the process is completely invisible and the user cannot interfere with it. The AHK process itself is spawned by another application. v2.0b-4 does achieve this perfectly.

The same code does not work as intended on v2.0.2.
Specifically

Code: Select all

EmptyWindow := Gui("+Owner")
does not hide behind the main process invisible window anymore.

I cannot use the Method Gui.Hide() because the spawned Webbrowser stop responding immediatly and does not process any websocket events until the gui is visible again.
Sure, I could disable the GUI and move it to an area beyond visible bounderies like (x-10000) but I don't like that idea...

Is this a bug? Intended behavior? Is there a better way to accomplish this?

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Completely hiding a GUI does not work v2.0.2

Post by mikeyww » 13 Jan 2023, 10:40

Perhaps:

Code: Select all

#Requires AutoHotkey v2.0

gui1 := Gui('+Owner', 'GUI1')           ; Owned by script's window
gui1.AddText('w230', 'Test')
gui1.Show('x300 w200 h200')

gui2 := Gui('+Owner' gui1.Hwnd, 'GUI2') ; Owned by gui1, and therefore on top of it
gui2.AddText('w230', 'On top of GUI1')
gui2.Show('x200 w200 h200')

F3::gui1.Destroy                        ; Destroy both GUIs

GothicIII
Posts: 20
Joined: 17 May 2022, 04:16

Re: Completely hiding a GUI does not work v2.0.2

Post by GothicIII » 13 Jan 2023, 12:14

Nope. Both GUIs are showing in foreground.

EDIT: Just to be clear:
Both GUIs should be completely invisible to the user. No Taskbar, no TrayIcon, no Window. And it must remain active to be able to process data.

User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: Completely hiding a GUI does not work v2.0.2

Post by mikeyww » 13 Jan 2023, 12:37

You can hide them, though I did not test whether the browser stops working. That seems like it would be an issue beyond AHK itself.

Code: Select all

#Requires AutoHotkey v2.0

gui1 := Gui('+Owner', 'GUI1')           ; Owned by script's window
gui1.AddText('w230', 'Test')
; gui1.Show('x300 w200 h200')
; gui1.Hide

gui2 := Gui('+Owner' gui1.Hwnd, 'GUI2') ; Owned by gui1, and therefore on top of it
gui2.AddText('w230', 'On top of GUI1')
; gui2.Show('x200 w200 h200')
; gui2.Hide

F3::gui1.Destroy                        ; Destroy both GUIs
If you saw something that worked in beta but not final release, you might want to post in the bugs forum to see what response you get there. Perhaps it was a bug in one version or the other, but I'm not sure which.

just me
Posts: 9576
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Completely hiding a GUI does not work v2.0.2

Post by just me » 14 Jan 2023, 04:26

Code: Select all

EmptyWindow := Gui("+Owner -Caption")
EmptyWindow.Show("w0 h0")
Webbrowser := Gui("+Parent" EmptyWindow.Hwnd)
webpage := Webbrowser.Add("ActiveX",, "Shell.Explorer").value
webpage.navigate("about:<!DOCTYPE html><meta http-equiv='X-UA-Compatible' content='IE=edge'><body></body>")
Webbrowser.Show()
?

Post Reply

Return to “Ask for Help (v2)”