autohotkey 经过1.2秒的mousedown

https://www.fastkeysautomation.com/forum/viewtopic.php?f=6&t=651

after_button_down
KeyWait, LButton, T1.2    ;1.2 sec
If ErrorLevel
  Run, www.google.com
Else
  Send {LButton}

autohotkey bmark ark

抓取标签,输出为json

bmark
#SingleInstance 
Menu, Tray, Icon, borsalino-w.ico ;set tray icon
TrayTip, bMark, Ready To Capture ;notify user ready to capture & force show icon

Clipboard =   ;initialize clipboard (make empty now, check for successful capture later)
caps=0 ;initialize tab count (sucessful captures)


NumpadEnter::
Enter::
;-----Numpad enter and regular enter/return now hotkeys
StringLen, length, a ;determine if any previous captures
IfEqual, length, 0 ;by evaluating string length
	Gosub, Shortcut   ;if no tags (no previous captures) make a shortcut instead of a page
Gosub, Releasekeys ;done with hotkeys
Gosub, GUI ;prompt user to save to file
Return



Right::
;-----Right arrow now a hotkey
If (A_PriorHotkey!=A_ThisHotkey)
{
	MouseGetPos,,, WinUMID  ;get mouse position
	WinActivate, ahk_id %WinUMID%  ;focus the window under the mouse
}
Gosub, GetTab ;ready to capture tab
Send, ^{Tab}	 ;goto next tab (to the right)
Return



Left::
;-----Left arrow now a hotkey
If (A_PriorHotkey!=A_ThisHotkey)
{
	MouseGetPos,,, WinUMID  ;get mouse position
	WinActivate, ahk_id %WinUMID%  ;focus the window under the mouse
}
Gosub, GetTab ;ready to capture tab
Send, {Ctrl Down}{Shift Down}{Tab}{Shift Up}{Ctrl Up}  ;goto previous tab (to the left)
Return




GetTab:
;-----Get Page URL
Send, ^l  ;focus the location/url field
Sleep, 250  ;allow time for ui to update/focus the url field
Send, ^c  ;copy url to clipboard
Sleep, 150  ;allow time for clipboard to update
StringLen, length, Clipboard  ;check the length of what was captured
IfEqual, length, 0 ;if clipboard capture was unsucessful, try again
	Return   ;this prevents advancing to next tab. remain on tab until actually captured.

;-----Get Page Title
WinGetActiveTitle, PageTitle   ;get title of webpage via titlebar
StringLen, length, PageTitle  ;check length of page title
IfEqual, length, 0 
	Return   ;if title capture was unsucessful, try again

;-----Clean-up Page Title Output
StringGetPos, HyphenPos, PageTitle, -, R ;find first hyphen from the right (preceeds browser name)
StringLeft, PageTitle, PageTitle, HyphenPos-1 ;remove the name of the brower from the title bar (i.e. firefox, opera, etc.)

IfInString, PageTitle, `'  ;single quotes will break sytax
	sQuote:="'"  ;so use HTML single quote as substitute
	StringReplace, PageTitle, PageTitle, `', %sQuote%, All ;replace all instances

IfInString, PageTitle, `" ;double quotes will break sytax
	dQuote:=""" ;so use HTML double quote as substitute
	StringReplace, PageTitle, PageTitle, `", %dQuote%, All ;replace all instances

;-----Now Proceed to Record Info
Gosub, MakeField   ;use capture to make a JSON field
Clipboard =   ;reset clipboard back to length zero
Return



Shortcut:
;-----Make a standard windows internet shortcut
Send, ^l  ;first focus url
Sleep, 200  ;wait for gui to update
Send, ^c  ;now capture url to clipboard
StringLen, length, Clipboard  ;very copy to clipboard
IfEqual, length, 0  ;if unsucessful
	Gosub, Exit  ;forgetaboutit, otherwise, keep going
Gosub, Releasekeys ;done with hotkeys
Gosub, Save ;prompt user for location to save
Return


MakeField:
;-----Use 'a' build JSON containing url (from clipboard) & site name (from title bar GUI under windows)
a = `t{`n ;begin JSON field
a = %a%`t"link": "%Clipboard%" ;add first piece of data
a = %a%,`n ;include delimitter
a = %a%`t"title": "%PageTitle%" ;add second piece of data
a = %a%`n`t} ;close JSON field

IfNotInString, links, %clipboard% ;check for url (stored to clipboard) in document (stored in the links variable)
{
	links = %links%%a%,`n ;if a unique url, add to list of of links
	caps+=1 ;update total number of unique tabs captures
	Tooltip, %caps% Tabs Captured ;notify user via tooltip
}
Return




Releasekeys:
;-----Done with all hotkeys. Turn them off so as to prevent interference with dialog to follow.
Tooltip,  ;clear tooltips
Hotkey, Right, off
Hotkey, Left, off
Hotkey, Enter, off
Hotkey, NumpadEnter, off
Return



GUI:
;-----GUI time
Gui, Destroy   ;clean-up (in-case it wasn't done last time)

Gui, Add, Text, x6 y12 w60 h20 +Right, Keywords: ;prompt for keywords
Gui, Add, Edit, x66 y12 w400 h50 -WantReturn vKeywords, 

Gui, Add, Text, x6 y72 w60 h20 +Right, Tags:
Gui, Add, Edit, x66 y72 w400 h20 vTags, 

Gui, Add, Button, x366 y102 w100 h30 default, Save  ;build save button
Gui, Add, Button, x256 y102 w100 h30 , Cancel  ;build cancel/exit button

Gui, Show, x131 y91 h140 w478, Enter Keywords & Tags to find it later.  ;give it a title, then present GUI to user
Return




;-----Define what to do when user clicks save
Save:
ButtonSave:
Gui, Submit

;-----Build Meta Info
FormatTime, dstamp, %A_NowUTC% ,ddd, ddMMM  ;create a date stamp
StringUpper, dstamp, dstamp ;date to upper-case
FormatTime, tstamp, %A_NowUTC% ,HH:mm  ;create a time stamp
FormatTime, metaFilename, %A_NowUTC% ,yyyy  ;prepend four digit year to meta filename
year=%metaFilename% ;already have, year save it for later

FormatTime, monthDay, %A_NowUTC% ,MMMdd  ;3char month and day of month
StringUpper, monthDay, monthDay ;date to upper-case
FormatTime, timeSec, %A_NowUTC% ,HHmmss  ;filename from year, day of year, and 24hr machine time-to the sec
FormatTime, DayofYear, %A_NowUTC% ,YDay0  ;day of year, 1-366, with leading zeros

;filename from year, day of year, date and 24hr machine time-to the sec
FormatTime, metaFilename, ,yyyy  ;prepend four digit year to meta filename

;UPDATED filename and path
Filename=%year%%DayofYear%%monthDay%%timeSec%

userdat=..\users\founder
flat=%userdat%\local\flatdb
cache=%userdat%\local
live=%userdat%\live
tabjs=%userdat%\static\tabjs


m = `t{`n ;begin JSON field
m = %m%`t"record": "#tabshare%Filename%" 
m = %m%,`n ;include delimitter
m = %m%`t"date": "%dstamp%"
m = %m%,`n ;include delimitter
m = %m%`t"time": "%tstamp%" 
m = %m%,`n ;include delimitter
m = %m%`t"year": "%year%" 
m = %m%,`n ;include delimitter
m = %m%`t"tags": "%Tags%" 
m = %m%,`n ;another delimitter
m = %m%`t"keywords": "%Keywords%" 
m = %m%`n`t} ;close JSON field
meta = %m%,`n



;-----Build tabshare files

;name functions and declare syntax
xMeta_before=head`=`[`n ;open function, to include json array
xMeta_after=`n`]`;passContent`(head,'xmeta'`)`;  ;close function, ending json array

xMarks_before=links`=`[`n ;open function, to include json array
xMarks_after=`n`]`;passContent`(links,'xmarks'`)`;  ;close function, ending json array

doc = %xMarks_before%`n%links%`n%xMarks_after%  ;compile full list of links in JSON
doc = %xMeta_before%`n%meta%`n%xMeta_after%`n%doc%  ;for new docs, compile meta information

tsPath = %tabjs%\%Filename%.tabshare.js ;specify relative directory and filetype for save

FileAppend %doc%, %tsPath%  ;then save to disk



;-----Update (prepend) master meta

master = %flat%\%metaFilename%imeta.tabshare.json  ;specify relative path to master meta json
FileRead, json, %master% ;grab existing index meta  ;read into variable
FileMove, %master%, %master%.bak, 1  ;backup master json
update=%meta%%json% ;append latest record
FileAppend %update%, %master%  ;save to master meta file


;-----Create static meta file js

iMeta_before=index`=`[`n ;open function, to include json array
iMeta_after=`n`]`;passContent`(index,'imeta'`)`;  ;close function, ending json array

mscript = %cache%\%metaFilename%imeta.tabshare.js ;specify relative directory and filetype for save
FileMove, %mscript%, %mscript%.bak, 1  ;backup static meta

mdoc = %iMeta_before%`n%update%%iMeta_after%`n  ;prepare static index meta
FileAppend %mdoc%, %mscript%  ;save to static meta file

metascript = %live%\%metaFilename%imeta.tabshare.js ;rel dir for prestage
FileCopy %mscript%, %metascript%, 1  ;copy to staging area





;-----ini meta
;keep track of total number records inside each index file
IniRead, rCount, %flat%\metaSum.ini, %metaFilename%imeta.tabshare.js, Number of Records, 0
rCount+=1
IniWrite, %rCount%, %flat%\metaSum.ini, %metaFilename%imeta.tabshare.js, Number of Records

;=============search enhancement (future)==========

;-----Keep all keywords
FileAppend, `, %Keywords%, %flat%\keywords.txt  ;track all keywords used
;-----Keep All Tags
FileAppend, `, %Tags%, %flat%\tags.txt  ;track all keywords used




;-----SYNC/Upload via Copy

upDir=%userprofile%\odrive\Dropbox\Apps\Cloud Cannon\tabshare
tabshareUP = %upDir%\users\founder\static\tabjs\%Filename%.tabshare.js ;specify relative directory and filetype for save
metaUP = %upDir%\users\founder\live\%metaFilename%imeta.tabshare.js ;rel dir for prestage

Tooltip, "Uploading..."

FileDelete %metaUP%
FileCopy %metascript%, %metaUP%, 1  ;copy to staging area
FileCopy %tsPath%, %tabshareUP%  ;copy to staging area

Tooltip, "Done."


esc::
Exit:
ButtonCancel:
GuiClose:
Gui, Destroy
TrayTip, bMark, Done
ExitApp

autohotkey 热键AHK

热键AHK

hotkeys.ahk
; Script for a bunch of a+ hotkeys idek what I would do w/o.
; There's one to open Volume Mixer, Notepad, Personalization window, Dual Wallpaper, turning the volume up and down, playing and pausing mpc (mpc doesn't need to be active, how gr8), showing and hiding titlebars and moving windows by holding down alt with the left mouse button (basically AltDrag).
; Remove the semicolons in front of line 61 and 62 if you want to be able to move windows by holding down the left and right click buttons, it's a great hotkey but caused problems for me while playing vidyas, so idk use it if you wish.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; Modifiers

; # = Windows Key;
; ! = Alt;        
; ^ = Control;
; + = Shift;
; & = Used to combine keys (ctrl+alt = ^&!);

; Hide taskbar
#T::
if toggle := !toggle
{
WinHide ahk_class Shell_TrayWnd
WinHide Start ahk_class Button
}
else
{
WinShow ahk_class Shell_TrayWnd
WinShow Start ahk_class Button
}
return

; Win+A - Open Volume Mixer
#a::
    Run sndvol
    Return

; Ctrl+Alt+P - Open Personalization menu
^!p::
    Run "::{26EE0668-A00A-44D7-9371-BEB064C98683}\1\::{ED834ED6-4B5A-4BFE-8F11-A626DCB6A921}"
    Return

; Ctrl+Alt+C - Open Control Panel
^!C::
    Run "::{26EE0668-A00A-44D7-9371-BEB064C98683}"
    Return

; Win+N - Open Notepad
#n::
    Run Notepad
    Return

; Win+w - Open DualWallpaper
#w::
    Run "E:\Programs\DualMonitor\DualWallpaper.exe"
    Return    


; Win+U - Open UxStyle
#U::
    Run "C:\UxStyle.exe"
    Return    

; Media Keys - Ctrl Left/Right to previous/next song - F8 to pause/play

^NumpadEnd::Send   {Media_Prev}
F8::Send {Media_Play_Pause}
^NumpadPgdn::Send  {Media_Next}

; Win+H - Hide Titlebar
    #h::
      WinSet, Style, -0xc00000, A
    return
     

; Win+S - Show Titlebar
    #s:: 
      WinSet, Style, +0xc00000, A
    return


 ; Ctrl+Up - Turn volume up 
     ^Up::
     SoundSet +5
     Return    


; Ctrl+Down - Turn volume down
      ^Down::
     SoundSet -5
     Return 


; F7 to play/pause MPC-HC
F7::
    SendMessage,0x0111,889,,,ahk_class MediaPlayerClassicW  
Return     


; Move windows using Alt and left click (altdrag replacement), and left and right click together
;~LButton & RButton::
;~RButton & LButton::
!LButton::
CoordMode, Mouse  ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin% 
if EWD_WinState = 0  ; Only if the window isn't maximized 
    SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return

EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U  ; Button has been released, so drag is complete.
{
    SetTimer, EWD_WatchMouse, off
    return
}
GetKeyState, EWD_EscapeState, Escape, P
if EWD_EscapeState = D  ; Escape has been pressed, so drag is cancelled.
{
    SetTimer, EWD_WatchMouse, off
    WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
    return
}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1   ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX  ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY
return

autohotkey AutoHotKey脚本,用于在arXiv抽象页面和PDF之间切换。此脚本仅支持Chrome安全性(您不希望它毁了它

AutoHotKey脚本,用于在arXiv抽象页面和PDF之间切换。此脚本仅支持Chrome以确保安全性(您不希望它破坏可能存在冲突的键绑定的其他应用程序),但更改起来很简单。

toggle_arxiv.ahk
/*
Under context of Chrome browser, and if the URL starts with "https://arxiv.org/":
"Windows + Alt + P" - Go to PDF is in abstract page, and go to abstract page if in PDF
                      (will not overwrite clipboard)
*/
#IfWinActive ahk_exe chrome.exe
#!p::
Send ^l
Sleep, 100
oldClipboard := Clipboard
Send ^c
Sleep, 200
if (RegExMatch(Clipboard, "^https:\/\/arxiv\.org\/") != 0)
{
	if (RegExMatch(Clipboard, "O)^https:\/\/arxiv\.org\/pdf\/(\d+\.\d+(v\d+)?)\.pdf$", match) != 0)
	{
		arxivId := match.Value(1)
		toUrl := "https://arxiv.org/abs/" . arxivId
		Send % toUrl . "{Enter}"
	}
	else if (RegExMatch(Clipboard, "O)^https:\/\/arxiv\.org\/abs\/(\d+\.\d+(v\d+)?)$", match) != 0)
	{
		arxivId := match.Value(1)
		toUrl := "https://arxiv.org/pdf/" . arxivId . ".pdf"
		Send % toUrl . "{Enter}"
	}
	else
	{
		MsgBox % "Unrecognizable URL: " . Clipboard
		Send, {Esc}
	}
}
else
{
	MsgBox, "#!p shortcut only functions under arXiv pages"
	Send, {Esc}
}
Clipboard := oldClipboard
Return
#IfWinActive

autohotkey Always on Top(AOT)v1.0

AOT.ahk
; <COMPILER: v1.1.25.01>
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
^SPACE::  Winset, Alwaysontop, , A

autohotkey OpenPHT_Mapping.ahk

将USB遥控器上的按钮映射到OpenPHT。

OpenPHT_Mapping.ahk
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;SC132::Send {LWin down}{Alt down}{Enter}{LWin up}{Alt up}
;Appskey::Send {RWin}
;
;F3::Send !{^t}
;
;Launch_Mail::Send !{F4}
;return
;
;Launch_Media::Send !{enter}
;return

Browser_search::^2
Browser_Back::Escape
Browser_Home::Tab
Volume_Up::F10
Volume_Down::F9
Volume_Mute::F8
Sleep::F2
Launch_Media::F6
Launch_Mail::i

autohotkey 排除特定窗口最小化当前窗口

排除特定窗口最小化当前窗口

排除特定窗口最小化当前窗口.ahk
;***************************************
;除特定窗口外使用#c最小化当前窗口
;**************************************
GroupAdd, minExclude, ahk_class Progman
GroupAdd, minExclude, ahk_class Shell_TrayWnd
GroupAdd, minExclude, ahk_class DV2ControlHost
GroupAdd, minExclude, ahk_class SysListView32
GroupAdd, minExclude, ahk_class Button


#IfWinNotActive, ahk_group minExclude
#c::
    WinMinimize, A
Return
#IfWinNotActive

;***************************************
;Scite热键修改
;**************************************
#IfWinActive ahk_exe SciTE.exe
CapsLock::
SendInput,^{Enter}
return
#IfWinActive

autohotkey 将短ESC映射到IME ON / OFF和长ESC到Escape

将短ESC映射到IME ON / OFF和长ESC到Escape

ESC-IME.ahk
$Esc::
  KeyWait, Esc, T0.1
  if ErrorLevel
    send,{Esc}
  else
    send,!{vkC0}
  keywait, Esc
return

autohotkey KeypressOSD.AHK

aerb_mouse_mapping.ahk
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

; Search Button
Browser_search::^2

; Back Button
Browser_Back::BackSpace

; Volume Up
Volume_Up::F10

; Volume Down
Volume_Down::F9

; Exclamation point
Launch_Mail::^1

; Mute Button
Volume_Mute::F8

; Clapperboard
Launch_Media::i
KeypressOSD.AHK
; KeypressOSD.ahk
;--------------------------------------------------------------------------------------------------------------------------
; ChangeLog : v2.40 (2018-03-19) - Added font and background color settings
;             v2.30 (2018-03-16) - Settings are now saved to ini file.
;                                - Added settings GUI and tray menu.
;                                - Moved this script from Gist to GitHub.
;             v2.22 (2017-02-25) - Now pressing same combination keys continuously more than 2 times,
;                                  for example press Ctrl+V 3 times, will displayed as "Ctrl + v (3)"
;             v2.21 (2017-02-24) - Fixed LWin/RWin not poping up start menu
;             v2.20 (2017-02-24) - Added displaying continuous-pressed combination keys.
;                                  e.g.: With CTRL key held down, pressing K and U continuously will shown as "Ctrl + k, u"
;             v2.10 (2017-01-22) - Added ShowStickyModKeyCount option
;             v2.09 (2017-01-22) - Added ShowModifierKeyCount option
;             v2.08 (2017-01-19) - Fixed a bug
;             v2.07 (2017-01-19) - Added ShowSingleModifierKey option (default is True)
;             v2.06 (2016-11-23) - Added more keys. Thanks to SashaChernykh.
;             v2.05 (2016-10-01) - Fixed not detecting "Ctrl + ScrollLock/NumLock/Pause". Thanks to lexikos.
;             v2.04 (2016-10-01) - Added NumpadDot and AppsKey
;             v2.03 (2016-09-17) - Added displaying "Double-Click" of the left mouse button.
;             v2.02 (2016-09-16) - Added displaying mouse button, and 3 settings (ShowMouseButton, FontSize, GuiHeight)
;             v2.01 (2016-09-11) - Display non english keyboard layout characters when combine with modifer keys.
;             v2.00 (2016-09-01) - Removed the "Fade out" effect because of its buggy.
;                                - Added support for non english keyboard layout.
;                                - Added GuiPosition setting.
;             v1.00 (2013-10-11) - First release.
;--------------------------------------------------------------------------------------------------------------------------

#SingleInstance force
#NoEnv
SetBatchLines, -1
ListLines, Off

global TransN, ShowSingleKey, ShowMouseButton, ShowSingleModifierKey, ShowModifierKeyCount
     , ShowStickyModKeyCount, DisplayTime, GuiPosition, FontSize, GuiHeight, hGUI_s, BkColor, FontColor, FontStyle, FontName
scriptPID := DllCall("GetCurrentProcessId")

ReadSettings()
CreateTrayMenu()
CreateGUI()
CreateHotkey()
return

#if !WinExist("ahk_pid " scriptPID)
	OnKeyPressed:
		try {
			key := GetKeyStr()
			ShowHotkey(key)
			SetTimer, HideGUI, % -1 * DisplayTime
		}
	return

	OnKeyUp:
	return

	_OnKeyUp:
		tickcount_start := A_TickCount
	return

; ===================================================================================
CreateGUI() {
	global

	Gui, +AlwaysOnTop -Caption +Owner +LastFound +E0x20
	Gui, Margin, 0, 0
	Gui, Color, %BkColor%
	Gui, Font, c%FontColor% %FontStyle% s%FontSize%, %FontName%
	Gui, Add, Text, vHotkeyText Center y20

	WinSet, Transparent, %TransN%
}

CreateHotkey() {
	Loop, 95
	{
		k := Chr(A_Index + 31)
		k := (k = " ") ? "Space" : k

		Hotkey, % "~*" k, OnKeyPressed
		Hotkey, % "~*" k " Up", _OnKeyUp
	}

	Loop, 24 ; F1-F24
	{
		Hotkey, % "~*F" A_Index, OnKeyPressed
		Hotkey, % "~*F" A_Index " Up", _OnKeyUp
	}

	Loop, 10 ; Numpad0 - Numpad9
	{
		Hotkey, % "~*Numpad" A_Index - 1, OnKeyPressed
		Hotkey, % "~*Numpad" A_Index - 1 " Up", _OnKeyUp
	}

	Otherkeys := "WheelDown|WheelUp|WheelLeft|WheelRight|XButton1|XButton2|Browser_Forward|Browser_Back|Browser_Refresh|Browser_Stop|Browser_Search|Browser_Favorites|Browser_Home|Volume_Mute|Volume_Down|Volume_Up|Media_Next|Media_Prev|Media_Stop|Media_Play_Pause|Launch_Mail|Launch_Media|Launch_App1|Launch_App2|Help|Sleep|PrintScreen|CtrlBreak|Break|AppsKey|NumpadDot|NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|Tab|Enter|Esc|BackSpace"
	           . "|Del|Insert|Home|End|PgUp|PgDn|Up|Down|Left|Right|ScrollLock|CapsLock|NumLock|Pause|sc145|sc146|sc046|sc123"
	Loop, parse, Otherkeys, |
	{
		Hotkey, % "~*" A_LoopField, OnKeyPressed
		Hotkey, % "~*" A_LoopField " Up", _OnKeyUp
	}

	If ShowMouseButton {
		Loop, Parse, % "LButton|MButton|RButton", |
			Hotkey, % "~*" A_LoopField, OnKeyPressed
	}

	for i, mod in ["Ctrl", "Shift", "Alt"] {
		Hotkey, % "~*" mod, OnKeyPressed
		Hotkey, % "~*" mod " Up", OnKeyUp
	}
	for i, mod in ["LWin", "RWin"]
		Hotkey, % "~*" mod, OnKeyPressed
}

MouseHotkey_On() {
	Loop, Parse, % "LButton|MButton|RButton", |
		Hotkey, % "~*" A_LoopField, On
}

MouseHotkey_Off() {
	Loop, Parse, % "LButton|MButton|RButton", |
		Hotkey, % "~*" A_LoopField, Off
}

ShowHotkey(HotkeyStr) {
	if WinActive("ahk_id " hGUI_s) {
		ActWin_X := ActWin_Y := 0
		ActWin_W := A_ScreenWidth
		ActWin_H := A_ScreenHeight
	} else {
		WinGetPos, ActWin_X, ActWin_Y, ActWin_W, ActWin_H, A
		if !ActWin_W
			throw
	}

	text_w := (ActWin_W > A_ScreenWidth) ? A_ScreenWidth : ActWin_W
	GuiControl, 1:    , HotkeyText, %HotkeyStr%

	GuiControl, 1:Move, HotkeyText, x0 y0 w%text_w% h%GuiHeight%
	GuiControl, +0x201, HotkeyText

	if (GuiPosition = "Top")
		gui_y := ActWin_Y
	else
		gui_y := (ActWin_Y+ActWin_H) - GuiHeight - 50

	Gui, 1:Show, NoActivate x%ActWin_X% y%gui_y% h%GuiHeight% w%text_w%
}

GetKeyStr() {
	static modifiers := ["Ctrl", "Shift", "Alt", "LWin", "RWin"]
	static repeatCount := 1

	for i, mod in modifiers {
		if GetKeyState(mod)
			prefix .= mod " + "
	}

	if (!prefix && !ShowSingleKey)
		throw

	key := SubStr(A_ThisHotkey, 3)

	if (key ~= "i)^(Ctrl|Shift|Alt|LWin|RWin)$") {
		if !ShowSingleModifierKey {
			throw
		}
		key := ""
		prefix := RTrim(prefix, "+ ")

		if ShowModifierKeyCount {
			if !InStr(prefix, "+") && IsDoubleClickEx() {
				if (A_ThisHotKey != A_PriorHotKey) || ShowStickyModKeyCount {
					if (++repeatCount > 1) {
						prefix .= " ( * " repeatCount " )"
					}
				} else {
					repeatCount := 0
				}
			} else {
				repeatCount := 1
			}
		}
	} else {
		if ( StrLen(key) = 1 ) {
			key := GetKeyChar(key, "A")
		} else if ( SubStr(key, 1, 2) = "sc" ) {
			key := SpecialSC(key)
		} else if (key = "LButton") && IsDoubleClick() {
			key := "Double-Click"
		}
		_key := (key = "Double-Click") ? "LButton" : key

		static pre_prefix, pre_key, keyCount := 1
		global tickcount_start
		if (prefix && pre_prefix) && (A_TickCount-tickcount_start < 300) {
			if (prefix != pre_prefix) {
				result := pre_prefix pre_key ", " prefix key
			} else {
				keyCount := (key=pre_key) ? (keyCount+1) : 1
				key := (keyCount>2) ? (key " (" keyCount ")") : (pre_key ", " key)
			}
		} else {
			keyCount := 1
		}

		pre_prefix := prefix
		pre_key := _key

		repeatCount := 1
	}
	return result ? result : prefix . key
}

SpecialSC(sc) {
	static k := {sc046: "ScrollLock", sc145: "NumLock", sc146: "Pause", sc123: "Genius LuxeMate Scroll"}
	return k[sc]
}

; by Lexikos -- https://autohotkey.com/board/topic/110808-getkeyname-for-other-languages/#entry682236
GetKeyChar(Key, WinTitle:=0) {
	thread := WinTitle=0 ? 0
		: DllCall("GetWindowThreadProcessId", "ptr", WinExist(WinTitle), "ptr", 0)
	hkl := DllCall("GetKeyboardLayout", "uint", thread, "ptr")
	vk := GetKeyVK(Key), sc := GetKeySC(Key)
	VarSetCapacity(state, 256, 0)
	VarSetCapacity(char, 4, 0)
	n := DllCall("ToUnicodeEx", "uint", vk, "uint", sc
		, "ptr", &state, "ptr", &char, "int", 2, "uint", 0, "ptr", hkl)
	return StrGet(&char, n, "utf-16")
}

IsDoubleClick(MSec = 300) {
	Return (A_ThisHotKey = A_PriorHotKey) && (A_TimeSincePriorHotkey < MSec)
}

IsDoubleClickEx(MSec = 300) {
	preHotkey := RegExReplace(A_PriorHotkey, "i) Up$")
	Return (A_ThisHotKey = preHotkey) && (A_TimeSincePriorHotkey < MSec)
}

HideGUI() {
	Gui, Hide
}

; -------------------------------------------------------------------

ReadSettings() {
	IniFile := SubStr(A_ScriptFullPath, 1, -4) ".ini"

	IniRead, TransN               , %IniFile%, Settings, TransN               , 200
	IniRead, ShowSingleKey        , %IniFile%, Settings, ShowSingleKey        , 1
	IniRead, ShowMouseButton      , %IniFile%, Settings, ShowMouseButton      , 1
	IniRead, ShowSingleModifierKey, %IniFile%, Settings, ShowSingleModifierKey, 1
	IniRead, ShowModifierKeyCount , %IniFile%, Settings, ShowModifierKeyCount , 1
	IniRead, ShowStickyModKeyCount, %IniFile%, Settings, ShowStickyModKeyCount, 0
	IniRead, DisplayTime          , %IniFile%, Settings, DisplayTime          , 100
	IniRead, GuiPosition          , %IniFile%, Settings, GuiPosition          , Bottom
	IniRead, FontSize             , %IniFile%, Settings, FontSize             , 50
	IniRead, GuiHeight            , %IniFile%, Settings, GuiHeight            , 115
	IniRead, BkColor              , %IniFile%, Settings, BkColor              , Black
	IniRead, FontColor            , %IniFile%, Settings, FontColor            , White
	IniRead, FontStyle            , %IniFile%, Settings, FontStyle            , w700
	IniRead, FontName             , %IniFile%, Settings, FontName             , Arial
}

SaveSettings() {
	IniFile := SubStr(A_ScriptFullPath, 1, -4) ".ini"

	IniWrite, %TransN%               , %IniFile%, Settings, TransN
	IniWrite, %ShowSingleKey%        , %IniFile%, Settings, ShowSingleKey
	IniWrite, %ShowMouseButton%      , %IniFile%, Settings, ShowMouseButton
	IniWrite, %ShowSingleModifierKey%, %IniFile%, Settings, ShowSingleModifierKey
	IniWrite, %ShowModifierKeyCount% , %IniFile%, Settings, ShowModifierKeyCount
	IniWrite, %ShowStickyModKeyCount%, %IniFile%, Settings, ShowStickyModKeyCount
	IniWrite, %DisplayTime%          , %IniFile%, Settings, DisplayTime
	IniWrite, %GuiPosition%          , %IniFile%, Settings, GuiPosition
	IniWrite, %FontSize%             , %IniFile%, Settings, FontSize
	IniWrite, %GuiHeight%            , %IniFile%, Settings, GuiHeight
	IniWrite, %BkColor%              , %IniFile%, Settings, BkColor
	IniWrite, %FontColor%            , %IniFile%, Settings, FontColor
	IniWrite, %FontStyle%            , %IniFile%, Settings, FontStyle
	IniWrite, %FontName%             , %IniFile%, Settings, FontName
}

CreateTrayMenu() {
	Menu, Tray, NoStandard
	Menu, Tray, Add, Settings, ShowSettingsGUI
	Menu, Tray, Add, About, ShowAboutGUI
	Menu, Tray, Add
	Menu, Tray, Add, Exit, _ExitApp
}

ShowAboutGUI() {
	Gui, a:Font, s12 bold
	Gui, a:Add, Text, , KeypressOSD v2.30
	Gui, a:Add, Link, gOpenUrl, <a>https://github.com/tmplinshi/KeypressOSD</a>
	Gui, a:Show,, About
	Return

	OpenUrl:
		Run, https://github.com/tmplinshi/KeypressOSD
	return
}

_ExitApp() {
	ExitApp
}

ShowSettingsGUI() {
	global

	Gui, s:Destroy
	Gui, s:+HWNDhGUI_s
	Gui, s:Font, s12
	Gui, s:Add, Text, , Transparency:
	Gui, s:Add, Text, x+10 w100 vTransNVal, %TransN%
	Gui, s:Add, Slider, xm+10 vTransN Range0-255 ToolTip gUpdateTransVal, %TransN%
	Gui, s:Add, Checkbox, xm h24 vShowSingleKey Checked%ShowSingleKey%, Show Single Key
	Gui, s:Add, Checkbox, xm h24 vShowMouseButton Checked%ShowMouseButton%, Show Mouse Button
	Gui, s:Add, Checkbox, xm h24 vShowSingleModifierKey Checked%ShowSingleModifierKey%, Show Single Modifier Key
	Gui, s:Add, Checkbox, xm h24 vShowModifierKeyCount Checked%ShowModifierKeyCount%, Show Modifier Key Count
	Gui, s:Add, Checkbox, xm h24 vShowStickyModKeyCount Checked%ShowStickyModKeyCount%, Show Sticky Modifier Key Count
	Gui, s:Add, Text, xm, Display
	Gui, s:Add, Edit, x+10 w100 Number Center vDisplayTime, %DisplayTime%
	Gui, s:Add, Text, x+10, Milliseconds
	Gui, s:Add, Text, xm, Gui Position:
	Gui, s:Add, DDL, x+10 w150 Center vGuiPosition gUpdateGuiPosition, Bottom||Top
	GuiControl, s:Choose, GuiPosition, %GuiPosition%
	Gui, s:Add, Text, xm, Font Size:
	Gui, s:Add, Edit, x+10 w100 Number Center vFontSize gUpdateFontSize, %FontSize%
	Gui, s:Add, UpDown, Range1-1000 gUpdateFontSize, %fontSize%
	Gui, s:Add, Text, xm, Gui Height:
	Gui, s:Add, Edit, x+10 w100 Number Center vGuiHeight gUpdateGuiHeight, %GuiHeight%
	Gui, s:Add, UpDown, Range5-1000 gUpdateGuiHeight, %GuiHeight%
	Gui, s:Add, Button, xm gChangeBkColor, Change Background Color
	Gui, s:Add, Button, xm gChangeFont, Change Font
	Gui, s:Add, Button, x+50 gChangeFontColor, Change Font Color

	Gui, s:Show,, Settings - KeypressOSD
	ShowHotkey("KeypressOSD")
	SetTimer, HideGUI, Off
	return

	UpdateGuiPosition:
		GuiControlGet, GuiPosition
		ShowHotkey("KeypressOSD")
	return

	UpdateGuiHeight:
		GuiControlGet, newH,, GuiHeight
		if newH {
			GuiHeight := newH
			ShowHotkey("KeypressOSD")
		}
	return

	UpdateTransVal:
		GuiControlGet, TransN
		GuiControl,, TransNVal, % TransN

		Gui, 1:+LastFound
		WinSet, Transparent, %TransN%
	return

	UpdateFontSize:
		GuiControlGet, FontSize
		Gui, 1:Font, s%FontSize%
		GuiControl, 1:Font, HotkeyText
	return

	sGuiClose:
		FontSize_pre := FontSize

		Gui, s:Submit

		ShowMouseButton ? MouseHotkey_On() : MouseHotkey_Off()

		if (FontSize_pre != FontSize) {
			Gui, 1:Font, s%FontSize%
			GuiControl, 1:Font, HotkeyText
		}

		if !GuiHeight
			GuiHeight := 115

		SaveSettings()
		Gui, s:Destroy
		Gui, 1:Hide
	return

	ChangeBkColor:
		newColor := BkColor
		if Select_Color(hGUI_s, newColor) {
			Gui, 1:Color, %newColor%
			ShowHotkey("KeypressOSD")
			SetTimer, HideGUI, Off
			BkColor := newColor
		}
	return

	ChangeFontColor:
		newColor := FontColor
		if Select_Color(hGUI_s, newColor) {
			Gui, 1:Font, c%newColor%
			GuiControl, 1:Font, HotkeyText
			ShowHotkey("KeypressOSD")
			SetTimer, HideGUI, Off
			FontColor := newColor
		}
	return

	ChangeFont:
		fStyle := FontStyle " s" FontSize
		fName  := FontName
		fColor := FontColor

		if Select_Font(hGUI_s, fStyle, fName, fColor) {
			FontStyle := fStyle
			FontName := fName
			FontColor := fColor
			if RegExMatch(FontStyle, "\bs\K\d+", FontSize) {
				FontStyle := RegExReplace(FontStyle, "\bs\d+")
				GuiControl,, FontSize, %FontSize%
			}

			Gui, 1:Font
			Gui, 1:Font, %fStyle% c%FontColor%, %fName%
			GuiControl, 1:Font, HotkeyText
			ShowHotkey("KeypressOSD")
			SetTimer, HideGUI, Off
		}
	return
}




; https://autohotkey.com/boards/viewtopic.php?p=112730#p112730
;-------------------------------------------------------------------------------
Select_Font(hGui, ByRef Style, ByRef Name, ByRef Color) { ; using comdlg32.dll
;-------------------------------------------------------------------------------
    static SubKey := "SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontDPI"


    ;-----------------------------------
    ; LOGFONT structure
    ;-----------------------------------
    VarSetCapacity(LOGFONT, 128, 0)

    If RegExMatch(Style, "s\K\d+", s) {
        RegRead, LogPixels, HKLM, %SubKey%, LogPixels
        NumPut(s * LogPixels // 72, LOGFONT, 0, "Int")
    }

    If RegExMatch(Style, "w\K\d+", w)
        NumPut(w, LOGFONT, 16, "Int")

    If InStr(Style, "italic")
        NumPut(255, LOGFONT, 20, "Int")

    If InStr(Style, "underline")
        NumPut(1, LOGFONT, 21, "Int")

    If InStr(Style, "strikeout")
        NumPut(1, LOGFONT, 22, "Int")

    StrPut(Name, &LOGFONT + 28, StrLen(Name) + 1)


    ;-----------------------------------
    ; CHOOSEFONT structure
    ;-----------------------------------

    ; CHOOSEFONT structure expects text color in BGR format
    BGR := convert_Color(Color)

    If (A_PtrSize = 8) { ; 64 bit
        VarSetCapacity(CHOOSEFONT, 104, 0)
        NumPut(     104, CHOOSEFONT,  0, "UInt") ; StructSize
        NumPut(    hGui, CHOOSEFONT,  8, "UInt") ; hwndOwner
        NumPut(&LOGFONT, CHOOSEFONT, 24, "UInt") ; lpLogFont
        NumPut(   0x141, CHOOSEFONT, 36, "UInt") ; Flags
        NumPut(     BGR, CHOOSEFONT, 40, "UInt") ; bgrColor
    }

    Else { ; 32 bit
        VarSetCapacity(CHOOSEFONT, 60, 0)
        NumPut(      60, CHOOSEFONT,  0, "UInt") ; StructSize
        NumPut(    hGui, CHOOSEFONT,  4, "UInt") ; hwndOwner
        NumPut(&LOGFONT, CHOOSEFONT, 12, "UInt") ; lpLogFont
        NumPut(   0x141, CHOOSEFONT, 20, "UInt") ; Flags
        NumPut(     BGR, CHOOSEFONT, 24, "UInt") ; bgrColor
    }


    ;-----------------------------------
    ; call ChooseFont function
    ;-----------------------------------
    FuncName := "comdlg32\ChooseFont" (A_IsUnicode ? "W" : "A")
    If Not DllCall(FuncName, "UInt", &CHOOSEFONT)
        Return, False


    ;-----------------------------------
    ; results to return
    ;-----------------------------------

    ; style
    Style := "s" NumGet(CHOOSEFONT, A_PtrSize = 8 ? 32 : 16, "Int") // 10
    Style .= " w" NumGet(LOGFONT, 16)
    If NumGet(LOGFONT, 20, "UChar")
        Style .= " italic"
    If NumGet(LOGFONT, 21, "UChar")
        Style .= " underline"
    If NumGet(LOGFONT, 22, "UChar")
        Style .= " strikeout"

    ; name
    Name := StrGet(&LOGFONT + 28)

    ; chosen color
    RGB := convert_Color(NumGet(CHOOSEFONT, A_PtrSize = 8 ? 40 : 24, "UInt"))
    Color := SubStr("0x00000", 1, 10 - StrLen(RGB)) SubStr(RGB, 3)
    Return, True
}



;-------------------------------------------------------------------------------
Select_Color(hGui, ByRef Color) { ; using comdlg32.dll
;-------------------------------------------------------------------------------

    ; CHOOSECOLOR structure expects text color in BGR format
    BGR := convert_Color(Color)

    ; unused, but a valid pointer to the structure
    VarSetCapacity(CUSTOM, 64, 0)


    ;-----------------------------------
    ; CHOOSECOLOR structure
    ;-----------------------------------

    If (A_PtrSize = 8) { ; 64 bit
        VarSetCapacity(CHOOSECOLOR, 72, 0)
        NumPut(     72, CHOOSECOLOR,  0) ; StructSize
        NumPut(   hGui, CHOOSECOLOR,  8) ; hwndOwner
        NumPut(    BGR, CHOOSECOLOR, 24) ; bgrColor
        NumPut(&CUSTOM, CHOOSECOLOR, 32) ; lpCustColors
        NumPut(  0x103, CHOOSECOLOR, 40) ; Flags
    }

    Else { ; 32 bit
        VarSetCapacity(CHOOSECOLOR, 36, 0)
        NumPut(     36, CHOOSECOLOR,  0) ; StructSize
        NumPut(   hGui, CHOOSECOLOR,  4) ; hwndOwner
        NumPut(    BGR, CHOOSECOLOR, 12) ; bgrColor
        NumPut(&CUSTOM, CHOOSECOLOR, 16) ; lpCustColors
        NumPut(  0x103, CHOOSECOLOR, 20) ; Flags
    }


    ;-----------------------------------
    ; call ChooseColorA function
    ;-----------------------------------

    If Not DllCall("comdlg32\ChooseColorA", "UInt", &CHOOSECOLOR)
        Return, False


    ;-----------------------------------
    ; result to return
    ;-----------------------------------

    ; chosen color
    RGB := convert_Color(NumGet(CHOOSECOLOR, A_PtrSize = 8 ? 24 : 12, "UInt"))
    Color := SubStr("0x00000", 1, 10 - StrLen(RGB)) SubStr(RGB, 3)
    Return, True
}



;-------------------------------------------------------------------------------
convert_Color(Color) { ; convert RGB <--> BGR
;-------------------------------------------------------------------------------
    $_FormatInteger := A_FormatInteger
    SetFormat, Integer, Hex
    Result := (Color & 0xFF) << 16 | Color & 0xFF00 | (Color >> 16) & 0xFF
    SetFormat, Integer, % $_FormatInteger
    Return, Result
}

autohotkey input_self

input_self
Capslock & 1::
clip:=clipboard
text = () 
clipboard = %text%
Send ^v
Send {left}
clipboard = %clip%
return

Capslock & 2::
clip:=clipboard
text = "" 
clipboard = %text%
Send ^v
Send {left}
clipboard = %clip%
return

Capslock & 3::
clip:=clipboard
text = ("") 
clipboard = %text%
Send ^v
Send {left}{left}
clipboard = %clip%
return

Capslock & 4::
clip:=clipboard
text = &
clipboard = %text%
Send ^v
clipboard = %clip%
return

[1]示例
::exc::
text = excel 插件_ 
clipboard = %text%
Send ^v
return