【发布时间】:2016-08-30 05:01:24
【问题描述】:
我正在尝试使用以下代码制作一个 AutoHotKey 脚本以显示 HTML 文件中的透明覆盖:
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="http://i.stack.imgur.com/FBZq5.png" />
</body>
</html>
), overlay.html
return
除了透明度之外的一切都很好。我可以使用 WinSet Transparent 使整个控件透明,但我想要的只是覆盖的边缘淡出为透明,以便 HTML 的实际内容可见。
我为 HTML 创建了一个背景图像,具有所需的淡入透明效果,但由于 HTML 的背景仍然是白色的,所以它只是淡入淡出到白色。
似乎是 IE 不想呈现透明背景的问题?有什么办法可以解决这个问题,使背景真正透明,还是有其他可能的解决方法?
【问题讨论】:
标签: html css internet-explorer activex autohotkey