Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it also possible to apply acrylic effect? #4

Open
H5820121 opened this issue Sep 12, 2024 · 3 comments
Open

Is it also possible to apply acrylic effect? #4

H5820121 opened this issue Sep 12, 2024 · 3 comments

Comments

@H5820121
Copy link

H5820121 commented Sep 12, 2024

I would be very grateful if you could write, how you can apply for mygui an acrylic effect or other effects, Or you can't just Mica (Alt)?
Thank you!

@1j01
Copy link

1j01 commented Sep 13, 2024

I was able to get acrylic working by enabling DWMWA_USE_HOSTBACKDROPBRUSH and using DWMSBT_TRANSIENTWINDOW (3) instead of DWMSBT_TABBEDWINDOW (4) for the backdrop type.

#Include "./GuiEnhancerKit.ahk"

; https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
DWMWA_USE_HOSTBACKDROPBRUSH := 16
DWMWA_SYSTEMBACKDROP_TYPE := 38
; https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type
DWMSBT_AUTO := 0
DWMSBT_NONE := 1
DWMSBT_MAINWINDOW := 2
DWMSBT_TRANSIENTWINDOW := 3
DWMSBT_TABBEDWINDOW := 4

ShowTestWindow() {
	Win := GuiExt()

	Win.SetFont("cWhite s16", "Segoe UI")
	Win.SetDarkTitle()  ; needed for dark window background apparently, even though there's no title bar
	Win.SetDarkMenu()  ; should be unnecessary in this simple example

	Win.BackColor := 0x000000

	; Sample content
	Win.Add("Text", "x0 y0 w300 h200 Center +0x200", "Hello, world!")

	; Close when pressing Escape
	Win.OnEvent("Escape", (*) => Win.Destroy())
	; Always on top makes it easy to preview the blur effect against different backgrounds.
	Win.Opt("+AlwaysOnTop -SysMenu -Caption -Border +Owner")

	; Seem to have to show the window before enabling the blur effect
	Win.Show("w300 h200")

	; Enables rounded corners.
	; Doesn't seem to hide the border if the window is already shown, but `-Border` takes care of that.
	Win.SetBorderless(6)
	; Set blur-behind accent effect. (Supported starting with Windows 11 Build 22000.)
	if (VerCompare(A_OSVersion, "10.0.22600") >= 0) {
		Win.SetWindowAttribute(DWMWA_USE_HOSTBACKDROPBRUSH, true)  ; required for DWMSBT_TRANSIENTWINDOW
		Win.SetWindowAttribute(DWMWA_SYSTEMBACKDROP_TYPE, DWMSBT_TRANSIENTWINDOW)
	}
}

ShowTestWindow()

Notes:

  • I found that I had to call SetBorderless after showing the window, for the blur-behind effects to work. This seems to run counter to the example on the readme, so I don't know if this is correct usage, but it seems to work!
  • I'm not sure about the situation if you want a window with a border/caption.
  • The effect seems somewhat unreliable, but resizing the window apparently triggers it to update, so maybe triggering a resize event or something could make it reliable. (Setting up the effect before showing the window seems like the proper way to fix this, but I couldn't get it to work that way.)

@H5820121
Copy link
Author

@1j01 Wonderful, thank you very much!
How do I change the opacity setting?
Thanks!

@1j01
Copy link

1j01 commented Oct 4, 2024

@H5820121 I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants