I'm trying to make an AutoHotKey script to display a transparent overlay from an HTML file using the following code:
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
#SingleInstance, force
Menu Tray, tip, %A_ScriptName% ; Custom traytip
OverlayVisible := 0
; ---------------------- CUSTOMIZE BELOW HERE ----------------------
PositionX := 31 ; x position of top left corner of overlay
PositionY := 423 ; y position of top left corner of overlay
F1::
Gosub Sub_BuildHTML
Gosub Sub_ToggleOverlay
return
Sub_ToggleOverlay:
if !OverlayVisible {
Gosub Sub_ShowOverlay
} else {
Gosub Sub_HideOverlay
}
OverlayVisible := !OverlayVisible
return
; Creates and shows the GUI
Sub_ShowOverlay:
Gui GUI_Overlay:New, +ToolWindow +LastFound +AlwaysOnTop -Caption -Border +hwndGUI_Overlay_hwnd
Gui Margin, 0,0
Gui Add, ActiveX, w400 h225 vWB BackGroundTrans, Shell.Explorer
URL := "file:///" . A_ScriptDir . "/overlay.html"
WB.Navigate(URL)
WinSet Transparent, 255
;WinSet TransColor, White 0
Gui Show, Hide, Overlay
WinMove PositionX, PositionY
Gui GUI_Overlay:Show, NoActivate
return
Sub_HideOverlay:
Gui GUI_Overlay:Destroy
return
Sub_BuildHTML:
FileDelete, overlay.html
FileAppend,
(
<!DOCTYPE html>
<html>
<meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge"/>
<head>
<style type="text/css">
body {
background-color: transparent;
overflow:hidden;
}
#header1 {
color:blue;
}
</style>
</head>
<body>
<div id="header1">TEST</div>
<img src="https://i.stack.imgur.com/FBZq5.png" />
</body>
</html>
), overlay.html
return
Everything except the transparency is working great. I can use WinSet Transparent to make the entire control transparent but what I want is for just the edges of the overlay to fade out to transparency so that the actual content of the HTML is visible.
I created a background image for the HTML with the desired fade to transparent but because the background of the HTML is still white it is just a fade to white instead.
Seems to be an issue with IE not wanting to render a transparent background? Is there any way to fix this so that the background is really transparent or is there some other workaround possible?