我尝试使用以下代码制作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不想呈现透明背景的问题?有没有办法解决这个问题,以便背景真的透明或者是否有其他解决办法?
答案 0 :(得分:0)
答案 1 :(得分:0)