如何实现多层键盘切换? Topic is solved
Moderators: tmplinshi, arcticir
-
- Posts: 89
- Joined: 10 Aug 2019, 01:49
Re: 如何实现多层键盘切换?
Code: Select all
Index = 0
intInterval := 500
~LControl::
if (A_PriorHotkey <> "~LControl" or A_TimeSincePriorHotkey > intInterval)
{
KeyWait, LControl
return
}
Else {
if (Index = 1 ){
EnvAdd, Index ,-1
}
Else {
EnvAdd, Index ,1
}
}
return
#if (Index = 1)
j::Down
k::Up
h::Left
l::Right
#if ; End #if
Last edited by fwejifjjwk2 on 05 Apr 2021, 20:38, edited 3 times in total.
Re: 如何实现多层键盘切换? Topic is solved
Code: Select all
~Alt::IsDoubleClick() ? (RemapKeys := !RemapKeys) : ""
#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)
}
Re: 如何实现多层键盘切换?
感谢。我还想实现双击alt后在屏幕左上角显示一个半透明的符号,处于最高层,用来指示当前状态,再次双击消失。请问该如何做?谢谢。tmplinshi wrote: ↑15 Nov 2019, 08:58Code: Select all
~Alt::IsDoubleClick() ? (RemapKeys := !RemapKeys) : "" #If RemapKeys j::Left l::Right i::Up k::Down #If IsDoubleClick() { return (A_ThisHotKey = A_PriorHotKey) && (A_TimeSincePriorHotkey <= DllCall("GetDoubleClickTime")) }
-
- Posts: 89
- Joined: 10 Aug 2019, 01:49
Re: 如何实现多层键盘切换?
Code: Select all
keyboard_state = 0
intInterval := 300
~LAlt::
if (A_PriorHotkey <> "~LAlt" or A_TimeSincePriorHotkey > intInterval)
{
KeyWait, LAlt
return
}
Else {
if (keyboard_state = 1 ){
EnvAdd, keyboard_state ,-1
Gui,Destroy
}
Else {
EnvAdd, keyboard_state ,1
;SoundBeep, 200, 300
showtext(1)
}
}
return
#if (keyboard_state = 1)
j::Left
l::Right
i::Up
k::Down
#if ; End #if
showtext(str)
{
x := 10
y := 10
Gui,Destroy
Gui,+AlwaysOnTop +Disabled -Caption -SysMenu +Owner +LastFound
WinGet,hwnd,ID
Gui, font, s26 ECF3F7 w600, Verdana
Gui, Color, ECF3F7
WinSet, TransColor, ECF3F7
Gui,Add,Text,BackgroundTrans,%str%
Gui, Show, NoActivate Y%y% X%x% NA, Title of Window
}
Last edited by fwejifjjwk2 on 05 Apr 2021, 20:37, edited 3 times in total.
Re: 如何实现多层键盘切换?
楼主应该是想要显示一个背景色半透明的窗口,我多提供一个代码吧。
之前长按 Alt 也会被 IsDoubleClick 认为是双击,现已修复。
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%
}
Re: 如何实现多层键盘切换?
谢谢你tmplinshi wrote: ↑16 Nov 2019, 11:28楼主应该是想要显示一个背景色半透明的窗口,我多提供一个代码吧。
之前长按 Alt 也会被 IsDoubleClick 认为是双击,现已修复。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% }
Re: 如何实现多层键盘切换?
非常感谢fwejifjjwk2 wrote: ↑15 Nov 2019, 23:31@Guest
Code: Select all
keyboard_state = 0 intInterval := 300 ~LAlt:: if (A_PriorHotkey <> "~LAlt" or A_TimeSincePriorHotkey > intInterval) { KeyWait, LAlt return } Else { if (keyboard_state = 1 ){ EnvAdd, keyboard_state ,-1 Gui,Destroy } Else { EnvAdd, keyboard_state ,1 ;SoundBeep, 200, 300 showtext(1) } } return #if (keyboard_state = 1) j::Left l::Right i::Up k::Down #if ; End #if showtext(str) { x := 10 y := 10 Gui,Destroy Gui,+AlwaysOnTop +Disabled -Caption -SysMenu +Owner +LastFound WinGet,hwnd,ID Gui, font, s26 ECF3F7 w600, Verdana Gui, Color, ECF3F7 WinSet, TransColor, ECF3F7 Gui,Add,Text,BackgroundTrans,%str% Gui, Show, NoActivate Y%y% X%x% NA, Title of Window }
Re: 如何实现多层键盘切换?
@tmplinshi
我在1.1.32的版本下使用出现了问题,您的长按修复版本并没有修复问题,在我运行脚本之后,第一次长按alt还是会被视为双击,而映射后,再次长按并不能将上下左右映射回来,只能通过双击使上下左右变回jkil,我的解决方案是在您的代码起始处加入keywait命令,之后运行效果良好。现修改如下,供参考:
我在1.1.32的版本下使用出现了问题,您的长按修复版本并没有修复问题,在我运行脚本之后,第一次长按alt还是会被视为双击,而映射后,再次长按并不能将上下左右映射回来,只能通过双击使上下左右变回jkil,我的解决方案是在您的代码起始处加入keywait命令,之后运行效果良好。现修改如下,供参考:
Code: Select all
~Alt::
keyWait, Alt
if IsDoubleClick() {
RemapKeys := !RemapKeys
}
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)
}