-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorkshop.ahk
144 lines (130 loc) · 4.11 KB
/
Workshop.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#InstallKeybdHook
#SingleInstance
#NoEnv
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
toggle := 0
SetTitleMatchMode, 2
; Debugging
; I recommend AutoHotkey Plus Plus for Visual Studio Code
; hotstrings
; Git Bash
::psh:: git add . && git commit -m "" && git push{left 13}
; RegEx
::\anything::.
::\matchAtLeastOnce::+
::\matchAtLeastZero::*
::\whitespace::\s
::[ \t\n\r\f\v]::\s
::startGroup::[
::endGroup::]
; Application-specific shortcuts
; RegEx by application
#IfWinActive, - Sublime Text
#IfWinActive
; Python
#IfWinActive, .py
::\regex::re.search(''){left 2}
#IfWinActive
; Java escapes more characters
#IfWinActive, .java
::\startInnerGroup::\[
::\endInnerGroup::\]
#IfWinActive
; Open or call programs
#0::Run, cmd ; directly
+#0::Run, "C:\Program Files (x86)\Notepad++\notepad++.exe" ; full path
; by aumid
!#0::Run, shell:Appsfolder\Microsoft.Getstarted_8wekyb3d8bbwe!App
; Hidden
^#0::
{
TempFile=%A_ScriptDir%\ip_temp.txt ; Define temp file
RunWait %comspec% /c "ipconfig > %TempFile%",,Hide ; Redirect info into temp file whilst hiding Command output
Return
}
; mouse movement
F12::
MouseGetPos, xpos, ypos
MsgBox, The cursor is at X%xpos% Y%ypos%.
Return
; Sequential Shortcuts
+#'::
{
sequenceTooltip("Pe&$o`n&Bitcoin`nLong ɨ`n^&interrobang`n&x Times`nBullet Point (&.)")
Input Key, CL1T1M ; since L1 specifies a total of 1 followup stroke, we don't need to handle ESC as a sequence break
; MsgBox % Key
switch Key
{
case "$":
Send {U+20B1}
Return
case "b":
Send {U+20BF}
Return
; case "B": ; case sensitive option C does not seem to work
; Send {U+0E3F}
; Return
case "i":
Send {U+0268}
Return
case Chr(9): ; ^iɨ
Send {U+203D}
Return
case Chr(73): ; +^i
Send {U+2E18}
Return
case "x":
Send {U+00D7}
Return
default: ; input character
Send % Key
Return
}
}
Return
; Sequential Shortcuts Helper Functions
sequenceTooltip(Tooltips)
{
IfWinExist, tooltipWin
Gui, destroy
Gui, +ToolWindow -Caption +0x400000 +alwaysontop
Gui, Font, s15
Gui, Add, text, x0 y0, %Tooltips%
SysGet, screenx, 0
SysGet, screeny, 1
xpos:=screenx / 2
ypos:=screeny / 2
Gui, Show, NoActivate xcenter ycenter AutoSize center, tooltipWin
SetTimer,tooltipWinClose, 1000
}
tooltipWinClose:
SetTimer,tooltipWinClose, off
Gui, destroy
Return
; terminal command that runs in the background which requires capturing console output
#If (WinActive("ahk_exe WindowsTerminal.exe") && WinActive("MSYS:/")) || WinActive("MINGW64") ; #todo migrate to Windows Terminal JSON settings? https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions
{
^!7:: ; squash current branch's changes into master ; mnemonic 7 comes from 7-zip
{
myBranchName := HiddenCommand("git branch --show current")
StringLen, myBranchNameLength, myBranchName
SendInput, git checkout master && git merge --squash %myBranchName% -m ""{left 1}
Return
}
^!c::clipboard := HiddenCommand("git rev-parse HEAD") ; copy commit stamp
}
; How to catch output from command line (In Git Bash Windows Terminal)
HiddenCommand(CmdToHide)
{
WinGetTitle, Title, A
SanitizedFolderName := RegExReplace(Title, "MSYS:/([a-z])", "$U1:") ; assumes Git Bash Windows Terminal
; SanitizedFolderName := RegExReplace(Title, "MINGW64:/([a-z])", "$U1:") ; assumes Git Bash
; assumes main drive, which isn't necessarily C:\
RunWait, %comspec% /c cd %SanitizedFolderName% && %CmdToHide% > C:\Users\Public\temp-cmd-output.txt,,Hide
tempCmdOutFile := FileOpen("C:\Users\Public\temp-cmd-output.txt", "r")
cmdOut := RegExReplace(tempCmdOutFile.ReadLine(), "(.*)\n$", "$1")
tempCmdOutFile.Close()
FileDelete, C:\Users\Public\temp-cmd-output.txt
return cmdOut
}