User:Ineuw/AutoHotKey

From Wikisource
Jump to: navigation, search
AutoHotkey.ahk keyboard macros script file for proofreading - in Windows OS.

Last update: — Ineuw talk 00:10, 18 April 2014 (UTC)

Keyboard key macro combinations
;Alt+'  ''italicize selected text''
;Alt+1  }} single set closing braces
;Alt+2  }}}} double set closing braces
;Alt+3  }}}}}} triple set closing braces
;Alt+4  {{Dhr}}{{rule|4em}}{{Dhr}}
;Alt+5  {{Dhr}}{{rule|65%}}{{rule|65%}}{{Dhr}}
;Alt+6  {{rule|12em}}
;Alt+7  {{c|{{fs75|selected text}}}}
;Alt+8  {{c|{{fs85|selected text}}}}
;Alt+9  {{c|{{fs90|selected text}}}}
;Alt+Dn {{hwe|
;Alt+End        Delete row of text
;Alt+Up {{hws|
;Alt+a  [[Category:|]]
;Alt+b  '''bold selected text'''
;Alt+c  {{c|selected text}}
;Alt+d  {{Dhr}}
;Alt+e  |
;Alt+f  centered image template
;Alt+g  {{gap}}
;Alt+h  {{fs70|{{over||}}}}
;Alt+i  <i>selected text</i>
;Alt+j  Author xxxxx
;Alt+k  |rowspan= {{ts|it}}|  xxxx
;Alt+l  {{left||2em}}
;Alt+m  em dash —
;Alt+n  {{nop}}
;Alt+o  {{rh||'' ''|}}
;Alt+p  {{rh||''THE POPULAR SCIENCE MONTHLY.''|}}
;Alt+r  {{Right|selected text|2em}}
;Alt+s  {{sc|selected text}}
;Alt+t  {{ts|al}}|
;Alt+u  Pt|Article title| PSM xxxx
;Alt+v  {{di|drop initial
;Alt+w  width=
;Alt+x  rh||smaller|.|
;Alt+y  º
;Alt+z  {{DEFAULTSORT:{{SUBPAGENAME}}}}
;AltShift+a     {{color|red|''Arabic missing''}}
;AltShift+b     <br />
;AltShift+h     {{he|}}
;AltShift+w     {{wsPSM|Title|Vol|Month year}} xxxx
;Ctrl+\ Reload this Autohotkey program
;Ctrl+i "Cleaned image & improved contrast"
;Ctrl+m <math></math>
;CtrlShift+b    neutralized
;CtrlShift+e    {{fs90/e}}
;CtrlShift+i    {{in use}}
;CtrlShift+l    colspan=
;CtrlShift+m    [[File:Face-smile.svg|20px]]
;CtrlShift+n    {{under construction}}
;CtrlShift+p    <p>
;CtrlShift+s    {{fs90/s}}
;CtrlShift+t    {{PSMTable}}
;CtrlShift+u    {{fs85|{{ua|note=hyphenated word was joined on the previous page because of the intervening image.~~~~}}}}
;CtrlShift+w    rowspan=
;CtrlShift+y    ·
;Win+8  {{fs85|selected}}
;Win+9  {{fs90|selected text}}
;Win+a  {{anchor|D}}
;Win+b  <b>Bold selected text</b>
;Win+c  {{sic}}
;Win+d  <div {{ts|width:400px|aj|it|sm85|lh1|pb1|mc}}>selected text</div>
;Win+f  complete image template used for floating images
;Win+h  {{hi|selected text}}
;Win+i  {{SIC|selected text|duplicates selected text}}
;Win+l  {{Plr|selected text}} - PSM literary review paragraph format PSM xxxx
;Win+m  neutralizes Windows super key
;Win+n   
;Win+p  {{float-center|<poem>poetry block of text {{fs90/s}}{{fs90/e}}</poem>}}
;Win+q  {{SUBPAGENAME}}
;Win+r  <ref>selected text</ref>
;Win+s  {{smallrefs}}
;Win+t  {| {{ts|ma|sm90|lh12|ar|bc}}  <!-- border -->
;Win+u  <sup>selected text</sup>
;Win+v  <sub>selected text</sub>
;Win+-  {{fs|105%|{{sc|selected text}}}}
;Win+0  {{fs|105%|''italicise selected text''}}}}
;Win+1  <section begin=E />
;Win+2  <section end=B />
;Win+3  <section end=E /><section begin=B />{Left 3}


Keyboard macro script
AutoTrim, Off

;Alt+End        Delete row
!End::
Send, {Home}
Send, {Shift Down}
Send, {End}
Send, {Shift Up}
Send, {Delete 2}
Return

;======================================

;Alt+1  single set closing braces
!1:: Sendinput, {}}{}}
Return

;Alt+2  double set closing braces
!2:: Sendinput, {}}{}}{}}{}}
Return

;Alt+3  triple set closing braces
!3:: Sendinput, {}}{}}{}}{}}{}}{}}
Return

;Alt+4  rule|4em
!4:: Sendinput, {Home}{Return}{{}{{}Dhr{}}{}}{Return}{Return}{{}{{}rule|4em{}}{}}{Return}{Return}{{}{{}Dhr{}}{}}{Return}
Return

;Alt+5  rule|65%
!5:: Sendinput, {{}{{}Dhr{}}{}}{Enter}{{}{{}rule|65`%{}}{}}{{}{{}rule|65`%{}}{}}{Enter}{{}{{}Dhr{}}{}}
Return

;Alt+6  rule|6em
!6:: Sendinput, {raw}{{rule|12em}}
Return

;Alt+7  center fs75|selected text
!7::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{c|{{fs75|%Trimmed%}}}}
Sendinput, ^v
Return

;Alt+8  center fs85|selected text
!8::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{c|{{fs85|%Trimmed%}}}}
Sendinput, ^v
Return

;Alt+9  center fs90|selected text
!9::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{c|{{fs90|%Trimmed%}}}}
Sendinput, ^v
Return

;Alt+Dn hwe|
!Down:: Sendinput, {raw}{{hwe|
Return

;Alt+Up hws|
!Up:: Sendinput, {{}{{}hws|
Return

;Alt+'  italicize selected text
!'::
clipboard =
send ^c
clipwait, 1
varItalics := clipboard
        if SubStr(varItalics, 0, 1)= Chr(32) {
        varItalics := Trim(varItalics)
        clipboard = ''%varItalics%''%A_Space%
}
Else
{
        varItalics := Trim(varItalics)
        clipboard = ''%varItalics%''
}

Sendinput, ^v
Return

;Alt+a  Category:|
!a:: Sendinput, [[Category:]]{Left 2}
Return

;Alt+b  bold selected text
!b::
clipboard =
send ^c
clipwait, 1
varBold := clipboard
        if SubStr(varBold, 0, 1)= Chr(32) {
        varBold := Trim(varBold)
        clipboard = '''%varBold%'''%A_Space%
}
Else
{
        varBold := Trim(varBold)
        clipboard = '''%varBold%'''
}

Sendinput, ^v
Return

;Alt+c  center|selected text
!c::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{c|%Trimmed%}}
Sendinput, ^v
Return

;Alt+d  Dhr
!d:: Sendinput, {Home}{raw}{{Dhr}}
Return

;Alt+e  |
!e:: Sendinput, {Home}|{Down}{Home}
Return

;Alt+f  centered image template
!f::
Sendinput, {Home}{{}{{}Dhr{}}{}}{Enter}
Sendinput, {Home}{{}{{}FI{Enter}
Sendinput, {Home} | file    = {Enter}
Sendinput, {Home} | width   = 430px{Enter}
Sendinput, {Home} | caption = {Enter}
Sendinput, {Home} | talign  = center.justify.right{Enter}
Sendinput, {Home} | tstyle  = font-variant:small-caps;{Enter}
Sendinput, {Home} | tmleft  = 2em{Enter}
Sendinput, {Home} | indent  = -2em{Enter}
Sendinput, {Home}{}}{}}{Enter}
Sendinput, {Home}{{}{{}Dhr{}}{}}
Return

;Alt+g  gap
!g:: Sendinput, {raw}{{gap}}
Return

;Alt+h  fs70 over||
!h::
Sendinput, {raw}{{fs70|{{over||}}}}
Sendinput, {Left 5}
Return

;Alt+i  <i>selected text</i>
!i::
clipboard =
send ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = <i>%Trimmed%</i>
Sendinput, ^v
Return

;Alt+j  Author
!j::
Sendinput, {Home}{raw}{{c|
Sendinput, {raw}{{fs90|
Sendinput, {raw}{{sc|
Sendinput, {End}
Sendinput, {raw}}}}}}}
Sendinput, {Home}
Return

;Alt+k  |rowspan= {{ts|it}}| 
!k:: Sendinput, |rowspan= {{}{{}ts|it{}}{}}|{Left 11}
Return

;Alt+l  Left|selected text|2em
!l:: Sendinput, {Home}{{}{{}left|{End}{raw}|2em}}
Return

;Alt+m  em dash
!m:: Sendinput, {Asc 0151}
Return

;Alt+n  nop
!n:: Sendinput, {Home}{{}{{}nop{}}{}}
Return

;Alt+o  RunningHeader||italicised text|
!o:: Sendinput, {{}{{}rh||'' ''|{}}{}}{Left 2}
Return

;Alt+p  RunningHeader|''THE POPULAR SCIENCE MONTHLY.''
!p:: Sendinput, {{}{{}rh||''THE POPULAR SCIENCE MONTHLY.''|{}}{}}{Left 36}
Return

;Alt+r  Right|selected text|2em
!r:: Sendinput, {Home}{{}{{}right|{End}{raw}|2em}}
Return

;Alt+s  small capitals|selected text
!s::
clipboard =
Sendinput, ^c
clipwait, 1
varSmallCaps := clipboard
        if SubStr(varSmallCaps, 0, 1)= Chr(32) {
        varSmallCaps := Trim(varSmallCaps)
        clipboard = {{sc|%varSmallCaps%}}%A_Space%
}
Else
{
        varSmallCaps := Trim(varSmallCaps)
        clipboard = {{sc|%varSmallCaps%}}
}

Sendinput, ^v
Return

;Alt+t  ts|al
!t:: Sendinput, {raw}{{ts|al}}|
Return

;Alt+u  Pt|Article title|
!u:: Sendinput, {Home}{{}{{}Pt|{End}|}}
Return

;Alt+v  drop initial
!v:: Sendinput, {Home}{{}{{}di|{Right}{}}{}}
Return

;Alt+w  width=
!w:: Sendinput, width= {Left 1}

;Alt+x  rh||smaller|.|
!x:: Sendinput, {{}{{}rh||{{}{{}smaller|{}}{}}|{}}{}}{Left 2}
;!x:: Sendinput, [[Category:Academic speeches]]
Return

;Alt+y  º
!y:: Sendinput, {Asc 0186}
Return

;Alt+z  
!z:: Sendinput, {raw}{{DEFAULTSORT:{{SUBPAGENAME}}}}
Return

;======================================

;win+1  <section begin=E />
#1:: Sendinput, {Home}`<section begin=E `/`>{Left 3}
Return

;win+2  <section end=B />
#2:: Sendinput, ^{End}`<section end=B `/`>{Left 3}
Return

;win+3  <section end=E /><section begin=B />{Left 3}
#3::
Sendinput, {raw}{{Dhr}}
Sendinput, {Enter}
Sendinput, {raw}{{PSM rule}}
Sendinput, {Enter}
Sendinput, `<section end=E `/`>`<section begin=B `/`>
Sendinput, {Left 22}
Return

;Win+8  fs85|selected text
#8::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{fs85|%Trimmed%}}
Sendinput, ^v
Return

;Win+9  fs90|selected text
#9::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{fs90|%Trimmed%}}
Sendinput, ^v
Return

;win+0  fs|105%|italicise selected text
#0::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{fs|105`%|''%Trimmed%''}}
Sendinput, ^v
Return

;win+-  fs|105%|{{small case|selected text
#-::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{fs|105`%|{{sc|%Trimmed%}}}}
Sendinput, ^v
Return

;Win+a  anchor|
#a:: Sendinput, {Home}{{}{{}anchor|D{}}{}}{Left 2}
Return

;Win+b  <b>Bold selected text</b>
#b::
clipboard =
send ^c
clipwait, 1
varBold := clipboard
        if SubStr(varBold, 0, 1)= Chr(32) {
        varBold := Trim(varBold)
        clipboard = <b>%varBold%</b>%A_Space%
}
Else
{
        varBold := Trim(varBold)
        clipboard = <b>%varBold%</b>
}

Sendinput, ^v
Return

;Win+c  sic
#c:: Sendinput, {raw}{{sic}}
Return

;Win+d  <div>selected text</div>
#d::
clipboard =
send ^c
clipwait, 1
varDiv := clipboard
varDiv := Trim(varDiv)
clipboard = <div {{ts|width:400px|aj|it|sm85|lh1|pb1|mc}}>%varDiv%</div>
Sendinput, ^v
Return

#e::
try {
    Run S:\Software\Explorer++\Explorer++.exe
} catch e {
    MsgBox Couldn't run Explorer++.`nPlease make sure it's in the same directory as this script (%A_ScriptDir%).
}
return

;Win+f  complete image template used for floating images
#f::
Sendinput, {Home}{{}{{}FIS{Enter}
Sendinput, {Home} | cstyle       = margin-top: 5px{Enter}
Sendinput, {Home} | talign       = center.justify{Enter}
Sendinput, {Home} | margin-right = 10px{Enter}
Sendinput, {Home} | margin-left  = 10px{Enter}
Sendinput, {Home} | tstyle       = font-variant:small-caps;{Enter}
Sendinput, {Home} | margin-left  = 2.0em{Enter}
Sendinput, {Home} | tmleft       = 2.0em{Enter}
Sendinput, {Home} | indent       = -2.0em{Enter}
Sendinput, {Home} | width        = 215px{Enter}
Sendinput, {Home} | float        = left.right{Enter}
Sendinput, {Home} | file         = {Enter}
Sendinput, {Home} | caption      = {Enter}
Sendinput, {Home}{}}{}}
Return

;Win+h  hanging indent|selected text
#h::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{hi|%Trimmed%}}
Sendinput, ^v
Return

;Win+i  SIC|selected text|duplicates selected text
#i::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{SIC|%Trimmed%|%Trimmed%}}
Sendinput, ^v
Return

;Win+l  Plr|selected text - PSM literary review paragraph format
#l::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{Plr|%Trimmed%}}
Sendinput, ^v
Return

;Win+m  Neutralizes Windows super key
#m::
Return

;Win+n   
#n:: Sendinput, {raw} 
Return

;Win+p  float-center|<poem>selected text
#p::
clipboard =
send ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = {{float-center|`<poem`>`n{{fs90/s}}%Trimmed%{{fs90/e}}`<`/poem`>}}
Sendinput, ^v
Return

;Win+q  SUBPAGENAME
#q:: Sendinput, {raw}{{SUBPAGENAME}}
Return

;Win+r  <ref>selected text</ref>
#r::
clipboard =
send ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = `<ref`>%Trimmed%`<`/ref`>
Sendinput, ^v
Return

;Win+s  rule and/or block-center smallrefs
;#s:: Sendinput, {{}{{}rule{}}{}}{Enter}{{}{{}smallrefs{}}{}}
;#s:: Sendinput, {raw}{{block-center|{{smallrefs}}}}
#s:: Sendinput, {raw}{{smallrefs}}
Return

;Win+t  table definition
#t:: Sendinput, {{}| {{}{{}ts|ma|sm90|lh12|ar|bc{}}{}} {raw} <!-- border -->
Return

;Win+u  <sup>selected text</sup>
#u::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = `<sup`>%Trimmed%`</sup`>
Sendinput, ^v
Return

;Win+v  <sub>selected text</sub>
#v::
clipboard =
Sendinput, ^c
clipwait, 1
Trimmed := clipboard
Trimmed := Trim(Trimmed)
clipboard = `<sub`>%Trimmed%`</sub`>
Sendinput, ^v
Return

;======================================

;Ctrl+\ Reload this document
^\::Reload

;Ctrl+i Cleaned image & improved contrast
^i:: Sendinput, {raw}Cleaned image & improved contrast
Return

;Ctrl+m <math>\scriptstyle </math>
^m:: Sendinput, <math></math>{Left 7}
Return

;======================================
;AltShift+a     arabic missing
!+a:: Sendinput, {raw}{{color|red|''Arabic missing''}}
Return

;AltShift+b     br
!+b:: Sendinput, `<br `/`>
Return

;AltShift+h     he Hebrew
!+h:: Sendinput, {{}{{}he|{}}{}}{Left 2}
Return

;AltShift+w     wsPSM template
!+w:: Sendinput, {{}{{}wsPSM|Title|Vol|Month year{}}{}}
Return

;======================================

;CtrlShift+b    neutralize
^+b::
Return

;CtrlShift+e    fs90/e
^+e:: Sendinput, {raw}{{fs90/e}}
Return

;CtrlShift+i    in use
^+i:: Sendinput, {raw}{{in use}}
Return

;CtrlShift+l    colspan=
^+l:: Sendinput, colspan= {Left 1}
Return

;CtrlShift+m    smilie
^+m:: Sendinput, [[File:Face-smile.svg|20px]]
Return

;CtrlShift+n    under construction
^+n:: Sendinput, {raw}{{under construction}}
Return

;CtrlShift+p    <p>
^+p:: Sendinput, {raw}<p>
Return

;CtrlShift+s    fs90/s
^+s:: Sendinput, {raw}{{fs90/s}}
Return

;CtrlShift+t    PSMTable
^+t:: Sendinput, {raw}{{PSMTable}}
Return

;CtrlShift+u    user annotation
^+u:: Sendinput, {{}{{}fs85|{{}{{}ua|note=hyphenated word was joined on the previous page because of the intervening image.~~~~}}}}{}}{}}{}}{}}
Return

;CtrlShift+w    rowspan=
^+w:: Sendinput, rowspan= {Left 1}
Return

;CtrlShift+y    {Asc 0183} ·
^+y:: Sendinput, {Asc 0183}
Return