User:Ineuw/AutoHotKey

From Wikisource
Jump to: navigation, search

Introduction[edit]

Last updated: — Ineuw talk 02:13, 18 July 2015 (UTC)

  • Autohotkey.ahk keyboard macros script file for proofreading Wikisource text in Windows OS. These macros work in Firefox, Chrome and Opera browsers, but not with Internet Explorer 11.
  • The scripts are in two files: Autohotkey.ahk is the main file, and the Proofread.ahk script is the second file linked into the Autohotkey.ahk.
  • The installation generates a sample Autohotkey.ahk file in the My Documents folder. Both the file name and the folder are defaults, which means that on start Autohotkey.exe will look for the Autohotkey.ahk scrip in the my Documents folder without any redirection. The contents of sample Autohotkey.ahk file is to be replaced with the code below, but any drive, folder, and file name with the .ahk extension can be specified on the command line of the program shortcut link as follows.
"C:\Program Files\AutoHotkey\AutoHotkey.exe" D:\AHKFunctionsLibrary\Autohotkey.ahk
  • It is recommended the a shortcut link is also placed in the Windows Startup folder.
  • Note that in the script, the working drive "D:\" and the "\AHKFunctionsLibrary" is both my working and library folder. These are my choices of location. Update these to your preferred location.
  • The software's limitation is that the U.S. keyboard layout definition is to be used and when editing, the scripts are to be pasted into a text editor which supports ANSI and PC encoding (i.e: Windows Notepad). This is not a limitation when working with text directly in browsers.
  • Most keyboard key combination can assigned to satisfy one's preference, with some exceptions of the keys assigned by Microsoft, for their Windows keyboard. These exceptions are noted in my keyboard assignments macro key assignment list.
  • The cripts can be reassigned to different keyboard key combinations, deleted, or neutralized by placing the (;) semicolon at the beginning of the lines of code. This means every line of code beginning with the keyboard key assignment and including the "return" at the end of the code segment.
  • Some key combinations were omitted because they conflict with Windows, or are needed for more important tasks.
    • Ctrl+p for printer/printing is omitted.
    • Win+l locks out the user - in Vista and later Windows versions, (but not in XP).
  • After changes, the file is to be saved and then reloaded using either of the two following options:
    • The Ctrl+\ (Control and backslash) key combination which is assigned to reload the script or,
    • Using the right mouse button click on the system tray AutoHotkey icon and select from the context menu options "Reload This Script."
  • The script actions were thoroughly tested. The Proofread.ahk macro, in the section below is linked by the #include declaration of the first line of this file. It's location is to be edited according to one's personal preference.

Autohotkey macro key assignment list[edit]

Last updated: — Ineuw talk 22:06, 16 June 2015 (UTC)

This lists the current keyboard key assignments. No uppercase characters used. Key combinations with numerals refer to the keys above the characters and not the Number Pad keys.

;Alt+'          ''selected text''
;Alt+.          Proofread macro please see Proofread.ahk file at the end.
;Alt+0          {{larger|selected text}}
;Alt+1          }}
;Alt+2          {{}}
;Alt+4          {{Dhr}} {{rule|4em}} {{Dhr}}
;Alt+5          {{Dhr}} {{rule|65%}}{{rule|65%}} {{Dhr}}
;Alt+6          {{Dhr}} {{rule|12em}} {{Dhr}}
;Alt+7          {{c|{{fs75|selected text}}}}
;Alt+8          {{c|{{fs85|selected text}}}}
;Alt+9          {{c|{{fs90|selected text}}}}
;Alt+=          remove braces from {{—}}
;Alt+Down       {{hwe|
;Alt+Up         {{hws|
;Alt+a          [[Category:|]]
;Alt+b          '''selected text'''
;Alt+c          {{c|selected text}}
;Alt+d          {{Dhr}}
;Alt+e          | vertical bar at the beginning of the row for tables
;Alt+f          FIS images container
;Alt+g          {{gap}}
;Alt+h          {{fs70|{{sfrac||}}}} OR {{fs70|{{over||}}}} both are the same
;Alt+i          <i>selected text</i>
;Alt+j          {{left|selected text|2em}}
;Alt+k          |ptb.5 table style code
;Alt+l          {{Plr|selected text}}
;Alt+m          emdash —
;Alt+n          {{nop}}
;Alt+o          {{rh||'' ''|}}
;Alt+p          {{rh||''THE POPULAR SCIENCE MONTHLY.''|}}
;Alt+r          <ref>selected text</ref>
;Alt+s          {{sc|selected text}}
;Alt+t          {{ts|}}
;Alt+v          {{di|D}}rop initial at the beginning of the line
;Alt+w          width= 
;Alt+y          ·
;======================================
;Alt+Shift+a    {{color|red|''Arabic missing''}}
;Alt+Shift+b    <br />
;Alt+Shift+h    {{he|}} hebrew
;Alt+Shift+w    {{PSM link|T|V|M&Y|author=}}
;======================================
;Ctrl+\         re-load edited and saved this .ahk file
;Ctrl+i         Cleaned image and improved contrast
;Ctrl+j         Replaced Google copyright notice(s) with blank page(s)
;Ctrl+k         {{sic}}
;Ctrl+m         <math></math>
;Ctrl+p         {{ping|}}
;======================================
;Ctrl+Shift+8    {{fs85/s}}selected text{{fs85/e}}
;Ctrl+Shift+9    {{fs90/s}}selected text{{fs90/e}}
;Ctrl+Shift+b    |pb.5 table style code
;Ctrl+Shift+i    [[selected text|selected text]]
;Ctrl+Shift+f    sens Ctrl+f for find to search for "
;Ctrl+Shift+l    colspan= table style code
;Ctrl+Shift+n    {{in use}} {{under construction}}
;Ctrl+Shift+p    <p>
;Ctrl+Shift+s    :-) smiley
;Ctrl+Shift+t    |pt.5 table style code
;Ctrl+Shift+w    rowspan= 
;Ctrl+Shift+y    {Asc 0186} º degree indicator
;======================================
;win+-          {{fs|105%|{{sc|selected text}}}}
;win+0          {{fs|105%|''selected text''}}
;win+1          <section end=E />
;win+2          <section end=E /><section begin=B />{Left 3}
;win+3          <section end=B />
;win+8          {{fs|85%|selected text}} without centering
;win+9          {{fs|90%|selected text}}
;win+a          {{anchor|D}}
;win+b          <b>selected text</b>
;win+c          {{color|red / blue|selected text}}
;win+d          <div {{ts|width:430px;|ma|aj|sm85|lh11|it}}>selected text</div>
;win+e          {{anchor|D}}
;win+h          {{hi|selected text}}
;win+i          {{SIC|selected text|selected text|}}
;win+l          reserved by Windows, do not use
;win+o          {{smaller|selected text}}
;win+p          <poem style="display:table; line-height:105%; font-size:90%; margin-left:auto; margin-right:auto; width:auto;"></poem>
;win+q          {{SUBPAGENAME}}
;win+r          {{right|selected text|2em}}
;win+s          {{smallrefs}}
;win+t          {| {{ts|mc|sm85|lh11|ar|bc|bgt}} <!-- border --> table definition
;win+u          <sup>selected text</sup>
;win+v          <sub>selected text</sub>
;======================================

Autohotkey keyboard macro script for Windows OS[edit]

Last updated: — Ineuw talk 02:15, 18 July 2015 (UTC)

SetWorkingDir, D:\AHKFunctionsLibrary 

#Include D:\AHKFunctionsLibrary ; 

#Include Proofread.ahk ; link the 2nd file below to be loaded as one with this file

#SingleInstance force ; enforce single instance of the program to run  

#InstallKeybdHook ; enforce keyboard use

#NoEnv ; for future backward reference 

#Warn  ; generate warning messages

autotrim, off

clipboard :=

;Alt-'      ''selected text''
!'::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
clipwait, 0
    if (substr(selected, 0)= a_space)
    {
    selected := trim(selected)
    clipboard = ''%selected%''%a_space%
}
Else
{
    selected := trim(selected)
    clipboard = ''%selected%''
}
    sendinput, ^v
return 


;Alt-.      Proofread macro please see next Proofread.ahk file.

;Alt-1      }}
!1::
    sendinput, {raw}}}
return

;Alt-2      {{}}
!2::
    sendinput, {raw}{{}}
    sendinput, {Left 2}
return

;Alt-4      {{Dhr}} {{rule|4em}} {{Dhr}}
!4::
    sendinput, {Home}{Enter}
    sendinput, {raw}{{Dhr}}
    sendinput, {Enter}{Enter}
    sendinput, {raw}{{rule|4em}}
    sendinput, {Enter}{Enter}
    sendinput, {raw}{{Dhr}}
    sendinput, {Enter}
return

;Alt-5      {{Dhr}} {{rule|65%}}{{rule|65%}} {{Dhr}}
!5::
    sendinput, {Home}{Enter}
    sendinput, {raw}{{Dhr}}
    sendinput, {Enter}{Enter}
    sendinput, {raw}{{rule|65`%}}{{rule|65`%}}
    sendinput, {Enter}{Enter}
    sendinput, {raw}{{Dhr}}
    sendinput, {Enter}
return

;Alt-6      {{Dhr}} {{rule|12em}} {{Dhr}}
!6::
    sendinput, {Home}{Enter}
    sendinput, {raw}{{Dhr|32px}}
    sendinput, {Enter}{Enter}
    sendinput, {raw}{{rule|12em}}
    sendinput, {Enter}{Enter}
    sendinput, {raw}{{Dhr}}
    sendinput, {Enter}
return

;Alt-7      {{c|{{fs75|selected text}}}}
!7::
autotrim, on
selected :=
clipboard :=
Sendinput ^c
clipwait, 0
    selected := clipboard
    clipboard = {{c|{{fs75|%selected%}}}}
    sendinput, ^v
return

;Alt-8      {{c|{{fs85|selected text}}}}
!8::
autotrim, on
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    clipboard = {{c|{{fs85|%selected%}}}}
    sendinput, ^v
return

;Alt-9      {{c|{{fs90|selected text}}}}
!9::
autotrim, on
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    clipboard = {{c|{{fs90|%selected%}}}}
    sendinput, ^v
return

;Alt-0      {{larger|selected text}}
!0::
autotrim, on
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    clipboard = {{larger|%selected%}}
    sendinput, ^v
return

;Alt-=      remove braces from {{—}}
!=::
autotrim, on
selected :=
clipboard := 
clipwait, 0
sendinput, ^a^c
in_put := "`{{—`}}"
out_put := "—"
clipwait, 0
    clipboard := regexreplace(clipboard, in_put, out_put)
    sendinput, ^v^
return

;Alt-Dn     {{hwe|
!Down::
    sendinput, {Home}{raw}{{hwe|
return

;Alt-Up     {{hws|
!Up::
    sendinput, {raw}{{hws|
return

;Alt-a      [[Category:|]]
!a::
    sendinput, [[Category:]]{Left 2}
return

;Alt-b      '''selected text'''
!b::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space)
    {
    selected := trim(selected)
    clipboard = '''%selected%'''%a_space%
}
Else
{
    selected := trim(selected)
    clipboard = '''%selected%'''
}
    sendinput, ^v
return 

;Alt-c      {{c|selected text}}
!c::
autotrim, on
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    clipboard = {{c|%selected%}}
    sendinput, ^v
return

;Alt-d      {{Dhr}}
!d::
    sendinput, {Home}{raw}{{Dhr}}
return

;Alt-e      | vertical bar at the beginning of the row for tables
!e::
    sendinput, {Home}|{Down}{Home}
return

;Alt-f      FIS images container
!f::
    sendinput, {Home}{{}{{}FIS{Enter}
    sendinput, {Home} | file         = {Enter}
    sendinput, {Home} | width        = 500px|250px{Enter}
    sendinput, {Home} | cstyle       = margin-top:6px; margin-bottom:6px{Enter}
    sendinput, {Home} | float        = left|center|right{Enter}
    sendinput, {Home} | caption      = {Enter}
    sendinput, {Home} | talign       = center|justify{Enter}
    sendinput, {Home} | tstyle       = font-variant:small-caps; font-size:83`%{Enter}
    sendinput, {Home} | margin-right = 6px{Enter}
    sendinput, {Home} | margin-left  = 6px{Enter}
    sendinput, {Home} | tmleft       = 11px{Enter}
    sendinput, {Home} | indent       = -11px{Enter}
    sendinput, {Home}{}}{}}
return

;Alt-g      {{gap}}
!g::
    sendinput, {raw}{{gap}}
return

;Alt-h      {{fs70|{{sfrac||}}}} OR {{fs70|{{over||}}}} both are the same
!h::
    sendinput, {raw}{{fs70|{{sfrac||}}}}
    sendinput, {Left 5}
return

;Alt-i      <i>selected text</i>
!i::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space) 
    {
    selected := trim(selected)
    clipboard = <i>%selected%</i>%a_space%
}
Else
{
    selected := trim(selected)
    clipboard = <i>%selected%</i>
}
    sendinput, ^v
return

;Alt-j      {{left|selected text|2em}}
!j::
    sendinput, {Home}{raw}{{left|
    sendinput, {End}{raw}|2em}}
return

;Alt-k      |ptb.5  ((ts    table style code
!k::
    sendinput, {raw}|ptb.5
return

;Alt-l      {{Plr|selected text}}
!l::
autotrim, on
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = {{Plr|%selected%}}
    sendinput, ^v
return

;Alt-m      emdash —
!m::
    sendinput, {u+2014}
return

;Alt-n      {{nop}}
!n::
    sendinput, {Home}
    sendinput, {raw}{{nop}}
return

;Alt-o      {{rh||'' ''|}}
!o::
    sendinput, {raw}{{rh||''''|}}
    sendinput, {Home}{Right 8}
return

;Alt-p      {{rh||''THE POPULAR SCIENCE MONTHLY.''|}}
!p::
    sendinput, {raw}{{rh||''THE POPULAR SCIENCE MONTHLY.''|}}
    sendinput, {Home}{Right 5}
return

;Alt-r      <ref>selected text</ref>
!r::
autotrim, on
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = <ref>%selected%</ref>
    sendinput, ^v
return

;Alt-s      {{sc|selected text}}
!s::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space)
    {
    selected := trim(selected)
    clipboard = {{sc|%selected%}}%a_space%
}
else
{
    selected := trim(selected)
    clipboard = {{sc|%selected%}}
}
    sendinput, ^v
return

;Alt-t      {{ts|}}|
!t::
    sendinput, {raw}{{ts|}}|
    sendinput, {Left 3}
return

;Alt-v      {{di|D}}rop initial at the beginning of the line
!v::
    sendinput, {Home}{raw}{{di|
    sendinput, {Right}{raw}}}
return

;Alt-w      width=
!w::
    sendinput, width= {Left 1}
return

;Alt-y      ·
!y::
    sendinput, {Asc 0183}
return

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

;Alt-Shift-a     {{color|red|''Arabic missing''}}
!+a::
    sendinput, {raw}{{color|red|''Arabic missing''}}
return

;Alt-Shift-b    <br />
!+b::
    sendinput, `<br `/`>
return

;Alt-Shift-h    {{he|}} hebrew
!+h::
    sendinput, {{}{{}he|{}}{}}{Left 2}
return

;Alt-Shift-l     reserved by Windows
!+l::
return

;Alt-Shift-w    {{PSM link|T|V|M&Y|author=}}
!+w::
    sendinput, {raw}{{PSM link|Title|Vol|Mo&Yr|author=}}
return

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

;Ctrl-\     re-load this edited and saved .ahk file
^\::
    Reload
return

;Ctrl-i     Cleaned image and improved contrast
^i::
    sendinput, {raw}Cleaned image and improved contrast
return

;Ctrl-j     Replaced Google copyright notice(s) with blank page(s)
^j::
    sendinput, {raw}Replaced Google copyright notice(s) with blank page(s)
return

;Ctrl-k     {{sic}}
^k::
    sendinput, {raw}{{sic}}
return

;Ctrl-m     <math></math>
^m::
    sendinput, `<math`>`</math`>{Left 7}
return

;Ctrl-p     {{ping|}}
^p:: 
    sendinput, {raw}{{ping|}}
    sendinput, {Left 2}
return

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

;Ctrl-Shift-4   4 spacs
^+4::
    sendinput, %A_Space%%A_Space%%A_Space%%A_Space%
return

;Ctrl-Shift-8    {{fs85/s}}selected text{{fs85/e}}
^+8::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    clipboard = {{fs85/s}}%clipboard%{{fs85/e}}
    sendinput, ^v
return

;Ctrl-Shift-9    {{fs90/s}}selected text{{fs90/e}}
^+9::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    clipboard = {{fs90/s}}%clipboard%{{fs90/e}}
    sendinput, ^v
return

;Ctrl-Shift-b    |pb.5   ((ts    table style code
^+b::
    sendinput, {raw}|pb.5
return

;Ctrl-Shift-i    [[selected text|selected text]]
^+i::
autotrim, off
selected :=
clipboard :=
    sendinput, ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    ;clipboard = `[`[Portal:Popular Science Monthly/%selected%|%selected%`]`]
    clipboard = `[`[w:%selected%|%selected%`]`]
    sendinput, ^v
return

;Ctrl-Shift-l    colspan=    ((ts    table style code
^+l::
    sendinput, colspan= {Left 1}
return

;Ctrl-Shift-n    {{in use}} {{under construction}}
^+n::
    sendinput, {raw}{{in use}}
return

;Ctrl-Shift-p    <p>
^+p::
    sendinput, {raw}<p>
return

;Ctrl-Shift-s    :-) smiley
^+s::
    sendinput, [[File:A Smiley.jpg|15px]]
return

;Ctrl-Shift-t    pt.5   ((ts    table style code
^+t:: 
    sendinput, {raw}|pt.5
return

;Ctrl-Shift-w    rowspan= 
^+w::
    sendinput, rowspan= {Left 1}
return
 
;Ctrl-Shift-y    {Asc 0186} º degree indicator
^+y::
    sendinput, {Asc 0186}
return

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

;win--      {{fs|105%|{{sc|selected text}}}}
#-::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space)
    {
    selected := trim(selected)
    clipboard = {{fs|105`%|{{sc|%selected%''}}}}%a_space%
}
else
{
    selected := trim(selected)
    clipboard = {{fs|105`%|{{sc|%selected%}}}}
}
    sendinput, ^v
return

;win-0      {{fs|105%|''selected text''}}
#0::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space)
    {
    selected := trim(selected)
    clipboard = {{fs|105`%|''%selected%''}}%a_space%
}
else
{
    selected := trim(selected)
    clipboard = {{fs|105`%|%selected%}}
}
    sendinput, ^v
return

;win-1      <section end=E />
#1::
    sendinput, `<section begin=E `/`>{Left 3}
return

;win-2      <section end=E /><section begin=B />{Left 3}
#2::
    sendinput, {Enter}
    sendinput, `<section end=E `/`>`<section begin=B `/`>
    sendinput, {Left 22}
return

;win-3      <section end=B />
#3::
    sendinput, `<section end=B `/`>{Left 3}
return

;win-8      {{fs|85%|selected text}} without centering
#8::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space)
    {
    selected := trim(selected)
    clipboard = {{fs|85`%|%selected%}}%a_space%
}
else
{
    selected := trim(selected)
    clipboard = {{fs|85`%|%selected%}}
}
    sendinput, ^v
return


;win-9      {{fs|90%|selected text}}
#9::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space) 
    {
    selected := trim(selected)
    clipboard = {{fs|90`%|%selected%}}%a_space%
}
else
{
    selected := trim(selected)
    clipboard = {{fs|90`%|%selected%}}
}
    sendinput, ^v
return

;win-a      {{anchor|D}}
#a::
autotrim, off
    sendinput, {Home}{raw}{{anchor|D}}
    sendinput, {Left 2}
return

;win-b      <b>selected text</b>
#b::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space) 
    {
    selected := trim(selected)
    clipboard = <b>%selected%</b>%a_space%
}
else
{
    selected := trim(selected)
    clipboard = <b>%selected%</b>
}
    sendinput, ^v
return

;win-c      {{color|red / blue|selected text}}
#c::
autotrim, off
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    if (substr(selected, 0)= a_space) 
    {
    selected := trim(selected)
    clipboard = {{color|blue|%clipboard%}}%a_space%
}
else
{
    selected := trim(selected)
    clipboard = {{color|blue|%clipboard%}}
}
    sendinput, ^v
return

;win-d      <div {{ts|width:430px;|ma|aj|sm85|lh11|it}}>selected text</div>
#d::
autotrim, on
selected :=
clipboard :=
    sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = `<div {{ts|width:430px;|ma|aj|sm85|`lh11|it}}`>`n%selected%`n`</div`>
    sendinput, ^v
return

;win-e      {{anchor|D}}
#e::
    sendinput, {raw}{{anchor|D}}
    sendinput, {Left 2}
return

;win-f    Search for "
#f::
    sendinput, ^{Home}
    sendinput, ^f^a{Del}
    sendinput, "
    sleep, 250
    sendinput, {Esc}{Right}
return

;win-h      {{hi|selected text}}
#h::
autotrim, on
selected :=
clipboard :=
sendinput ^c
clipwait, 0
    selected := clipboard
    clipboard = {{hi|%selected%}}
    sendinput, ^v
return

;win-i      {{SIC|selected text|selected text|}}
#i::
autotrim, on
selected :=
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = {{SIC|%selected%|%selected%}}
    sendinput, ^v
return

;win-l      reserved by Windows, do not use
#l::return
return

;win-o      {{smaller|selected text}}
#o::
autotrim, on
selected :=
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = {{smaller|%selected%}}
    sendinput, ^v
return

;win-p      <poem style="display:table; line-height:105%; font-size:90%; margin-left:auto; margin-right:auto; width:auto;"></poem>
#p::
autotrim, on
selected :=
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = `<poem style="display:table; line-height:105`%; font-size:90`%; margin-left:auto; margin-right:auto; width:auto;"`>`n%clipboard%`n`<`/poem`>
    sendinput, ^v
return

;win-n       
#n::
    sendinput, {raw} 
return

;win-q      {{SUBPAGENAME}}
#q:: sendinput, {raw}{{SUBPAGENAME}}
return

;win-r      {{right|selected text|2em}}
#r:: 
    sendinput, {Home}{raw}{{right|
    sendinput, {End}{raw}|2em}}
return

;win-s      {{smallrefs}}
#s::
    sendinput, ^a{Del}
    clipboard = {{rule}}`n{{smallrefs}}
    sendinput, ^v`n
return

;win-t      {| {{ts|mc|sm85|lh12|ar|bc|bgt}} <!-- border --> {{ts   table definition
#t::
sendinput ^c
clipwait, 0
clipboard = {| {{ts|mc|sm85|lh12|ar|bc|bgt}} <!-- border -->
    sendinput, ^v
return

;win-u      <sup>selected text</sup>
#u::
autotrim, off
selected :=
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    selected := trim(selected)
    clipboard = <sup>%selected%</sup>
    sendinput, ^v
return

;win-v      <sub>selected text</sub>
#v::
autotrim, on
selected :=
clipboard :=
sendinput, ^c
clipwait, 0
    selected := clipboard
    clipboard = <sub>%selected%</sub>
    sendinput, ^v
return

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

Proofread.ahk[edit]

Last update: — Ineuw talk 02:17, 18 July 2015 (UTC)

  • The proofread script is assigned to the combination of he Alt + . keys, but any keyboard key, combinations of keys, or word typed on the keyboard, can be assigned to the user's preference.
  • This macro is in a separate file but linked to the Autohotkey.ahk by the #include declaration in the Autohotkey.ahk.
;Alt+. proofread
!.::

clipboard := 

autotrim, on

sendinput, ^a^c

; clipwait, 0 = slow clipboard action by 1/2 second delay

;reduce two spaces to one
in_put := A_Space . A_Space
out_put := A_Space
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding a comma
in_put := " ,"
out_put := ","
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding a period
in_put := " ."
out_put := "."
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding a semicolon
in_put := " \;"
out_put := ";"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;space preceeding a colon
in_put := " :"
out_put := ":"
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding a question mark
in_put := " \?"
out_put := "?"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding an exclamation mark
in_put := " !"
out_put := "!"
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space following an open bracket
in_put := "( "
out_put := "("
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding a close bracket
in_put := " )"
out_put := ")"
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;remove space preceeding a hyphen
in_put := " -"
out_put := "-"
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;space following a hyphen
in_put := "- "
out_put := "-"
clipboard := strreplace(clipboard, in_put, out_put)

clipwait, 0

;space preceeding a crlf OK
in_put := " `r`n"
out_put := "`r`n"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;space following a crlf OK
in_put := "`r`n "
out_put := "`r`n"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;change three crlfs to two crlf OK
in_put := "`r`n`r`n`r`n"
out_put := "`r`n`r`n"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;two crlfs to ~~ OK
in_put := "`r`n`r`n"
out_put := "~~"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;hyphen preceeding a crlf OK
in_put := "-`r`n"
out_put := ""
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;single crlf with space OK
in_put := "`r`n"
out_put := " "
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;strip space preceeding an mdash
;in_put := " —"
;out_put := "—"
;clipboard := strreplace(clipboard, in_put, out_put) 
clipboard := RegExReplace(clipboard, "im)\s+—","—")

clipwait, 0

;strip space following an mdash
;in_put := "— "
;out_put := "—"
;clipboard := strreplace(clipboard, in_put, out_put)
clipboard := RegExReplace(clipboard,"im)—\s+","—")

clipwait, 0

;two tildes restore paragraph breaks OK
in_put := "~~"
out_put := "`r`n`r`n"
clipboard := regexreplace(clipboard, in_put, out_put)

clipwait, 0

;two periods side by side OK
in_put := "...."
out_put := ". . . ."
clipboard := strreplace(clipboard, in_put, out_put)

sendinput, ^v^{Home}

Return