## 如何实现多层键盘切换？ Topic is solved

Moderators: arcticir, tmplinshi

g1879

### 如何实现多层键盘切换？

fwejifjjwk2
Posts: 63
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 ){
}
Else {
}
}
return

#if (Index = 1)

j::Down
k::Up
h::Left
l::Right
#if ; End #if

``````
Last edited by fwejifjjwk2 on 17 Nov 2019, 18:15, edited 2 times in total.

tmplinshi
Posts: 1596
Joined: 01 Oct 2013, 14:57

### 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)
}``````

Guest

Guest

### Re: 如何实现多层键盘切换？

tmplinshi wrote:
15 Nov 2019, 08:58

Code: 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"))
}``````

fwejifjjwk2
Posts: 63
Joined: 10 Aug 2019, 01:49

### Re: 如何实现多层键盘切换？

@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 ){
Gui,Destroy
}
Else {
;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, Show, NoActivate Y%y% X%x% NA, Title of Window
}

``````
Last edited by fwejifjjwk2 on 17 Nov 2019, 18:14, edited 2 times in total.

tmplinshi
Posts: 1596
Joined: 01 Oct 2013, 14:57

### Re: 如何实现多层键盘切换？

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%
}``````

g1879

### Re: 如何实现多层键盘切换？

tmplinshi wrote:
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%
}``````

Guest

### 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 ){
Gui,Destroy
}
Else {
;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, Show, NoActivate Y%y% X%x% NA, Title of Window
}

``````

qwfpgj

### Re: 如何实现多层键盘切换？

@tmplinshi

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)
}

``````