Browse Source

Upload files to ''

liuyuqi 4 years ago
parent
commit
cf6e25c5e9
1 changed files with 93 additions and 91 deletions
  1. 93 91
      显示组合键.ahk

+ 93 - 91
显示组合键.ahk

@@ -1,92 +1,94 @@
-#SingleInstance force
-#NoEnv
-SetBatchLines, -1
-
-transN := 200	; 透明度
-
-
-; #################################
-;		GUI
-; #################################
-;
-Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
-Gui, Margin, 0, 0
-WinSet, ExStyle, +0x20		 ; 鼠标穿透
-WinSet, Transparent, %transN%
-Gui, Color, Black
-Gui, Font, cWhite s50 bold, Arial
-Gui, Add, Text, vHotkeyText Center y20
-
-
-; #################################
-;		绑定按键
-; #################################
-;重复95次,A_Index表示第i次,默认0。Chr(32)表示空格
-Loop, 95
-	Hotkey, % "~*" Chr(A_Index + 32), Display
-
-Loop, 24 ; F1-F24
-	Hotkey, % "~*F" A_Index, Display
-
-Loop, 10 ; Numpad0 - Numpad9
-	Hotkey, % "~*Numpad" A_Index - 1, Display
-
-Otherkeys := "NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|Tab|Enter|Esc|BackSpace|Del|Insert|Home|End|PgUp|PgDn|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|Pause"
-Loop, parse, Otherkeys, |
-	Hotkey, % "~*" A_LoopField, Display
-
-Return
-
-
-; #################################
-;		显示按键
-; #################################
-;
-Display:
-	If A_ThisHotkey =
-		Return
-
-	mods := "Ctrl|Shift|Alt|LWin|RWin"
-	prefix =
-
-	Loop, Parse, mods, |
-		if GetKeyState(A_LoopField)
-			prefix := prefix A_LoopField " + "
-
-	if !prefix		; 如果没有组合键则不显示
-		return
-
-	key := SubStr(A_ThisHotkey, 3)
-	if (key = " ")
-		key := "Space"
-
-	ShowHotkey(prefix key)
-	FadeOut()
-Return
-
-
-; ===================================================================================
-ShowHotkey(Hotkey)
-{
-	GuiControl,, HotkeyText, %Hotkey%
-
-	WinGetPos, ActWin_X, ActWin_Y, ActWin_W, ActWin_H, A
-	text_w := ActWin_W, gui_y := (ActWin_Y+ActWin_H) - 115 - 50
-	GuiControl, Move, HotkeyText, w%text_w% center
-
-	Gui, Show, NoActivate x%ActWin_X% y%gui_y% h115 w%text_w%
-}
-
-FadeOut(sleep = 1000)
-{
-	global transN
-
-	Sleep, %Sleep%
-	Gui, +LastFound
-
-	Loop, % transN
-		WinSet, Transparent, % (A_Index - transN - 1) * -1
-
-	Gui, Hide
-	WinSet, Transparent, % transN
+#SingleInstance force
+#NoEnv
+SetBatchLines, -1
+
+transN := 200	; 透明度
+
+
+; #################################
+;		GUI
+; #################################
+;
+Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
+Gui, Margin, 0, 0
+WinSet, ExStyle, +0x20		 ; 鼠标穿透
+WinSet, Transparent, %transN%
+Gui, Color, Black
+Gui, Font, cWhite s50 bold, Arial
+Gui, Add, Text, vHotkeyText Center y20
+
+
+; #################################
+;		绑定按键
+; #################################
+;重复95次,A_Index表示第i次,默认0
+Loop, 95
+	Hotkey, % "~*" Chr(A_Index + 32), Display
+
+Loop, 24 ; F1-F24
+	Hotkey, % "~*F" A_Index, Display
+
+Loop, 10 ; Numpad0 - Numpad9
+	Hotkey, % "~*Numpad" A_Index - 1, Display
+
+Otherkeys := "NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|Tab|Enter|Esc|BackSpace|Del|Insert|Home|End|PgUp|PgDn|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|Pause"
+Loop, parse, Otherkeys, |
+	Hotkey, % "~*" A_LoopField, Display
+
+Return
+
+
+; #################################
+;		显示按键
+; #################################
+;
+Display:
+	If A_ThisHotkey =
+		Return
+
+	mods := "Ctrl|Shift|Alt|LWin|RWin"
+	prefix =
+
+	Loop, Parse, mods, |
+		if GetKeyState(A_LoopField)
+			prefix := prefix A_LoopField " + "
+
+	if !prefix		; 如果没有组合键则不显示
+		Return
+
+	key := SubStr(A_ThisHotkey, 3)
+	if (key = " ")
+		key := "Space"
+
+	ShowHotkey(prefix key)
+	FadeOut()
+Return
+
+
+; ===================================================================================
+ShowHotkey(Hotkey)
+{
+	GuiControl, , HotkeyText, %Hotkey%
+
+	WinGetPos, ActWin_X, ActWin_Y, ActWin_W, ActWin_H, A
+	text_w := ActWin_W, gui_y := (ActWin_Y + ActWin_H) - 100 -50 ;gui_y可能会
+	GuiControl, Move, HotkeyText, w%text_w% center
+	Try{
+		Gui, Show, NoActivate x%ActWin_X% y%gui_y% h115 w%text_w%
+	}
+		
+}
+
+FadeOut(sleep = 1000)
+{
+	global transN
+
+	Sleep, %Sleep%
+	Gui, +LastFound
+
+	Loop, % transN
+		WinSet, Transparent, % (A_Index - transN - 1) * -1
+
+	Gui, Hide
+	WinSet, Transparent, % transN
 }