by tmplinshi » 16 Nov 2019, 11:28
楼主应该是想要显示一个背景色半透明的窗口,我多提供一个代码吧。
Code: Select all
~Alt::
if IsDoubleClick() {
RemapKeys := !RemapKeys
if RemapKeys
ShowTransText("游戏模式")
else
ShowTransText()
}
return
#If RemapKeys
j::Left
l::Right
i::Up
k::Down
#If
IsDoubleClick() {
static doubleClickTime := DllCall("GetDoubleClickTime")
KeyWait, % LTrim(A_ThisHotkey, "~")
return (A_ThisHotKey = A_PriorHotKey) && (A_TimeSincePriorHotkey <= doubleClickTime)
}
; ShowTransText("Hello")
; ShowTransText("Hello", 10, 10, {bgColor:"0x1482DE", textColor:"White"})
ShowTransText(Text := "", X := 0, Y := 0, objOptions := "") {
if (Text = "") {
Gui, @STT_:Destroy
return
}
o := {bgColor:"Black", textColor:"0x00ff00", transN:200, fontSize:12}
for k, v in objOptions {
o[k] := v
}
Gui, @STT_:Destroy
Gui, @STT_:+AlwaysOnTop -Caption -SysMenu +ToolWindow +E0x20 +HWNDhGUI
Gui, @STT_:Font, % "s" o.fontSize
Gui, @STT_:Color, % o.bgColor
Gui, @STT_:Add, Text, % "c" o.textColor, %Text%
Gui, @STT_:Show, x%X% y%Y% NA
WinSet, Transparent, % o.transN, ahk_id %hGUI%
}
之前长按 Alt 也会被 IsDoubleClick 认为是双击,现已修复。
楼主应该是想要显示一个背景色半透明的窗口,我多提供一个代码吧。
[code]~Alt::
if IsDoubleClick() {
RemapKeys := !RemapKeys
if RemapKeys
ShowTransText("游戏模式")
else
ShowTransText()
}
return
#If RemapKeys
j::Left
l::Right
i::Up
k::Down
#If
IsDoubleClick() {
static doubleClickTime := DllCall("GetDoubleClickTime")
KeyWait, % LTrim(A_ThisHotkey, "~")
return (A_ThisHotKey = A_PriorHotKey) && (A_TimeSincePriorHotkey <= doubleClickTime)
}
; ShowTransText("Hello")
; ShowTransText("Hello", 10, 10, {bgColor:"0x1482DE", textColor:"White"})
ShowTransText(Text := "", X := 0, Y := 0, objOptions := "") {
if (Text = "") {
Gui, @STT_:Destroy
return
}
o := {bgColor:"Black", textColor:"0x00ff00", transN:200, fontSize:12}
for k, v in objOptions {
o[k] := v
}
Gui, @STT_:Destroy
Gui, @STT_:+AlwaysOnTop -Caption -SysMenu +ToolWindow +E0x20 +HWNDhGUI
Gui, @STT_:Font, % "s" o.fontSize
Gui, @STT_:Color, % o.bgColor
Gui, @STT_:Add, Text, % "c" o.textColor, %Text%
Gui, @STT_:Show, x%X% y%Y% NA
WinSet, Transparent, % o.transN, ahk_id %hGUI%
}[/code]
之前长按 Alt 也会被 IsDoubleClick 认为是双击,现已修复。