-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiacritics and Nengo.ahk
212 lines (206 loc) · 6.23 KB
/
Diacritics and Nengo.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#Requires AutoHotkey v2.0
setTitleMatchMode 2
#Include "%A_ScriptDir%\Functions.ahk"
tutorialmode:= 0
;■■■■■■■■■■■■■ Keyboard commands for typing Japanese vowels in Romaji with macrons.
>!a:: Send "ā"
>!i:: Send "ī"
>!u:: Send "ū"
>!e:: Send "ē"
>!o:: Send "ō"
>+!a:: Send "Ā"
>+!i:: Send "Ī"
>+!u:: Send "Ū"
>+!e:: Send "Ē"
>+!o:: Send "Ō"
>!y:: Send "¥"
::aaa::
{
Send "ā"
}
::iii::
{
Send "ī"
}
::uuu::
{
Send "ū"
}
::eee::
{
Send "ē"
}
::ooo::
{
Send "ō"
}
::AAA::
{
Send "Ā"
}
::III::
{
Send "Ī"
}
::UUU::
{
Send "Ū"
}
::EEE::
{
Send "Ē"
}
::OOO::
{
Send "Ō"
}
::yyy::
{
Send "¥"
}
;■■■■■■■■■■■■■ Keyboard command for typing Korean vowels in Romanization with accent marks.
>^o:: Send "ŏ"
>^u:: Send "ŭ"
>+^o:: Send "Ŏ"
>+^u:: Send "Ŭ"
>^w:: Send "₩"
;▼▲▼▲▼▲▼▲▼▲▼▲▼ Functions
convertNengo(year){
;Convert Nengō to Western years.
RegExReplace(year, " ", "")
;Meiji era
if InStr(year, "m", 0) | InStr(year, "meiji", 0) | InStr(year, "明治"){
year:= RegExReplace(year, "i)meiji|m|明治")
if year > 45{
MsgBox "Error. The Meiji era ends in Meiji 45.", stopped, 4096
exit year
}else{
year:= year + 1867
return year
}
}
;Taishō Era
if InStr(year, "t", 0) | InStr(year, "taisho", 0) | InStr(year, "taishō") | InStr(year, "大正"){
year:= RegExReplace(year, "i)taishō|taisho|t|大正")
if (year > 15){
MsgBox "Error. The Taishō era ends in Taishō 15.", stopped, 4096
exit year
}else{
year:= year + 1911
return year
}
}
;Shōwa Era
if RegExMatch(year, "i)^s") | InStr(year, "showa", 0) | InStr(year, "shōwa", 0) | InStr(year, "昭和", 0){
year:= RegExReplace(year, "i)shōwa|showa|s|昭和")
if (year > 64){
MsgBox "Error. The Shōwa era ends in Shōwa 64.", stopped, 4096
exit
}else{
year:= year + 1925
return year
}
}
;Heisei Era
if InStr(year, "h", 0) | InStr(year, "heisei", 0) | InStr(year, "heiei", 0) | InStr(year, "平成", 0){
year:= RegExReplace(year, "i)heisei|h|平成")
if (year > 31){
MsgBox "Error. The Heisei era ends in Heisei 31.", stopped, 4096
}else{
year:= year + 1988
return year
}
}
;Reiwa Era
if InStr(year, "r", 0) | InStr(year, "reiwa", 0) | InStr(year, "令和", 0){
year:= RegExReplace(year, "i)reiwa|r|令和")
year:= year + 2018
return year
}
;Check if Western year can be converted.
if !isNumber(year){
year:= "n/a"
return year
}
if(year < 1868){
year:= "n/a"
return
}
switch year{
case 1868:
msgBox("Caution!`n`n1868 is a year when the imperial era changes.`n`nYou need to know the month and day of the date you are converting:`n`n--on or before September 7, 1868 is Keiō 4`n--on or after September 8, 1868 is Meiji 1`n`nThis script does not convert years when the imperial era changes.", "Dates in this year can't be converted.", 4096)
year:= "n/a"
return year
case 1912:
msgBox("Caution!`n`n1912 is a year when the imperial era changes.`n`nYou need to know the month and day of the date you are converting:`n`n--on or before June 11, 1912 is Meiji 45`n--on or after June 12, 1868 is Taishō 1`n`nThis script does not convert years when the imperial era changes.", "Dates in this year can't be converted.", 4096)
year:= "n/a"
return year
case 1926:
msgBox("Caution!`n`n1926 is a year when the imperial era changes.`n`nYou need to know the month and day of the date you are converting:`n`n--on or before December 26, 1926 is Taishō 15`n--on or after December 25, 1926 is Shōwa 1`n`nThis script does not convert years when the imperial era changes.", "Dates in this year can't be converted.", 4096)
year:= "n/a"
return year
case 1989:
msgBox("Caution!`n`n1989 is a year when the imperial era changes.`n`nYou need to know the month and day of the date you are converting:`n`n--on or before January 7, 1989 is Shōwa 64`n--on or after January 8, 1989 is Shōwa 1`n`nThis script does not convert years when the imperial era changes.", "Dates in this year can't be converted.", 4096)
year:= "n/a"
return year
case 2019:
msgBox("Caution!`n`n2019 is a year when the imperial era changes.`n`nYou need to know the month and day of the date you are converting:`n`n--on or before April 30, 2019 is Heisei 31`n--on or after May 1, 2019 is Reiwa 1`n`nThis script does not convert years when the imperial era changes.", "Dates in this year can't be converted.", 4096)
year:= "n/a"
return year
}
;Convert from Western years to Nengō.
;Meiji Era
if(year > 1868) & (year < 1912){
year:= year - 1867
return "Meiji " . year
}
;Taishō Era
if(year > 1912) & (year < 1926){
year:= year - 1911
return "Taishō " . year
}
;Shōwa Era
if(year > 1926) & (year < 1989){
year:= year - 1925
return "Shōwa " . year
}
;Heisei Era
if(year > 1989) & (year < 2019){
year:= year - 1988
return "Heisei " . year
}
;Reiwa Era
if(year > 2018) & (year < 2030){
year:= year - 2018
return "Reiwa " . year
}
}
;■■■■■■■■■■■■■ Convert Western or Japanese years to the other.
^+y::{
;Get year to convert.
if WinActive("ahk_exe EXCEL.EXE") | WinActive(" - Google Sheets") | WinActive(".xls"){
year:= copy()
year:= RegExReplace(year, "`r`n$")
}else{
Send "^+{left}"
Sleep nt
year:= copy()
}
year:= RegExReplace(year, "0", "0")
year:= RegExReplace(year, "1", "1")
year:= RegExReplace(year, "2", "2")
year:= RegExReplace(year, "3", "3")
year:= RegExReplace(year, "4", "4")
year:= RegExReplace(year, "5", "5")
year:= RegExReplace(year, "6", "6")
year:= RegExReplace(year, "7", "7")
year:= RegExReplace(year, "8", "8")
year:= RegExReplace(year, "9", "9")
;Convert from Nengō to Western year.
year:= convertNengo(year)
Sleep nt
Send year
Sleep nt
if WinActive("ahk_exe EXCEL.EXE") | WinActive(" - Google Sheets") | WinActive(".xls")
Send "{enter}"
}