Friday, May 14, 2010

Sneller werken en sorteren met AutoHotKey


AutoHotKey is een programma dat eigenlijk op geen enkele PC zou mogen ontbreken. Dit omdat het zoveel zaken eenvoudiger en vooral sneller kan maken. Het nadeel van AutoHotKey is dat het vaak enige tijd kost om het script aan te passen aan je eigen behoeften.

Je kunt AutoHotKey heel goed gebruiken als je heel vaak een paar standaard antwoorden gebruikt. In dat geval kun je hele blokken tekst oproepen door het intypen van een codewoord (kijk maar bij ::mvg in het script) of door een tekstblok aan een toetscombinatie te koppelen (b.v. Ctrl Y).

Nadat je AutoHotKey ginstalleerd hebt zie je een letter H in een groen vlakje in de Taskbar. Door met je rechter muistoets op het icoontje te drukken kun je het standaard script bestand openen. Hieronder heb ik een bestandje dat ik zelf gebruik. Ik heb een paar zaken weggelaten of ingekort. Voor mij zijn de belangrijkste zaken die ik iedere dag gebruik de volgende:

De rechter [Alt] toets op mijn Dell Latitude E6500 is nu een extra [Del] toets geworden.
De rechter [Ctrl] toets is nu een extra [Insert] toest, voornamelijk voor FreeMind.
De [Windows] + [Spatie] combinatie start een nieuwe Google pagina.
De [Ctrl] + [Shift] + V plakt de informatie uit het klembord als tekst alleen, zonder formatering.
De [Ctrl] + [Shift] + $ om het Euro-teken (€) te krijgen.
En [Ctrl] + [Shift] + D om de huidige datum en tijd in documenten en bestandsnamen te plaatsen.

Daarnaast gebruik ik de vele afkortingen, waarvan ik er maar een paar in de lijst laat zien als voorbeeld.

Omdat ik ook veel met het sorteren van tabellen werk heb ik ook een paar scriptjes om b.v. Outlook adressen die door een ; gescheiden worden en waarvan de achternaam eerst staat met een comma en dan pas de voornaam, om te zetten naar de voornaam eerst en dan de achternaam in een tabel vorm.

Of om een kleine tabel op het klembord snel te sorteren en alle dubbele eruit te gooien.

Kijk maar of je er wat aan hebt.

P.s. Ik heb over tijd van zoveel verschillende plaatsen voorbeelden gebruikt dat ik het niet allemaal weet terug te vinden.

Hier is een voorbeeld van wat sommige toetscombinaties doen nadat je de bron hebt gekopieerd:

=============================================
Sorteer en verwijder dubbele gegevens (kopieëer de bron met [Ctrl]+c
Bron

adlg akrg'dig'dag d
adrjkyue;ihgnd f e'jgadrg e
adlg akrg'dig'dag d
eoittoeitjrdteie5toiiere4t e[ rie5t 9u5ty-]5y
adlg akrg'dig'dag d
54y45oyiy 45e5t4e5y wrept 5t veptvqetpjiw
adlg akrg'dig'dag d
ki8rin ubyuca v vm lqecqq/q
adlg akrg'dig'dag d
5 v4j5yj4o5iy6juoy 45y 45y 45p v45

[Ctrl]+[Shift]+U (dit wordt d.m.v. "plakken" geplaatst)
5 v4j5yj4o5iy6juoy 45y 45y 45p v45
54y45oyiy 45e5t4e5y wrept 5t veptvqetpjiw
adlg akrg'dig'dag d
adrjkyue;ihgnd f e'jgadrg e
eoittoeitjrdteie5toiiere4t e[ rie5t 9u5ty-]5y
ki8rin ubyuca v vm lqecqq/q

==============================================
Gegevens met spaties voor en achter de tekst opschonen
Bron

' adlg akrg'dig'dag d
adrjkyue;ihgnd f e'jgadrg e
' eoittoeitjrdteie5toiiere4t e[ rie5t 9u5ty-]5y
' 54y45oyiy 45e5t4e5y wrept 5t veptvqetpjiw
ki8rin ubyuca v vm lqecqq/q
' 5 v4j5yj4o5iy6juoy 45y 45y 45p v45

[Ctrl]+[Shift]+T
adlg akrg'dig'dag d
adrjkyue;ihgnd f e'jgadrg e
eoittoeitjrdteie5toiiere4t e[ rie5t 9u5ty-]5y
54y45oyiy 45e5t4e5y wrept 5t veptvqetpjiw
ki8rin ubyuca v vm lqecqq/q
5 v4j5yj4o5iy6juoy 45y 45y 45p v45

==============================================
Email gegevens in een lijst plaatsen
Bron

abc@xyz.com; def@xyz.com; ghi@xyz.com; jkl@xyz.com; mno@xyz.com; pqr@xyz.com

[Ctrl]+[Shift]+I
abc@xyz.com
def@xyz.com
ghi@xyz.com
jkl@xyz.com
mno@xyz.com
pqr@xyz.com

==============================================
Email adressen uit een lijst, d.m.v. ; aan elkaar rijgen.
Bron

abc@xyz.com
def@xyz.com
ghi@xyz.com
jkl@xyz.com
mno@xyz.com
pqr@xyz.com

[Ctrl]+[Shift]+I
abc@xyz.com; def@xyz.com; ghi@xyz.com; jkl@xyz.com; mno@xyz.com; pqr@xyz.com;

==============================================




=====AutoHotKey Script=====

;This is a block of often used abbreviations that I want to expand (in EVERY application)
;In case you temporarily don't want this, you can either suspend autohotkey or type the abbreviation
;with a space somewhere in the abbreviation, when you later remove the space, the abbreviation will not be expanded.
::adm::administration
::afd::afdelingen
::afh::afhankelijk van
::b v::bij voorbeeld
::bv::b.v.
::d m v::door middel van
::i p v::in plaats van
::i v m::in verband met
::incl::inclusief
::ipv::i.p.v.
::ivm::i.v.m.
::ism::in samenwerking met
::mgr::manager
::mgrs::managers
::mgt::management
::mw::medewerker
::mws::medewerkers

::=<::{ASC 8804} ; type equal and less than sign, didn't use <= as this can be used to create left arrow ::>=::{ASC 8805} ; type more than sign and the equal sign , didn't use => as this can be used to create right arrow
::+/-::{ASC 0177} ; type +/- sign
::=/-::{ASC 0177} ; type +/- sign ; to make it easier, not having to press the Shift key for the plus sign.

::mvg::Met vriendelijke groet,{Enter}{Enter}Robert Ilbrink{Enter}{Enter}http://nl.linkedin.com/in/robertpilbrink{Enter}

; [Windows Key] + [Space] = Open Google in new tab in your default browser
#space::Run www.google.com

;I use the RIGHT ALT key on my DELL Latitude E6500 as a delete key.
;Special line in case the Dutch/NL international Keyboard keyboard is selected in the language bar.
;i don't like it when the Delete key is located so far away to the right top part of the keyboard.
LControl & RAlt::Send {DEL}

;I use the RIGHT ALT key on my DELL Latitude E6500 as a delete key
;Now the Standard Line for the US Keyboard keyboard in the language bar.
RAlt::Send {DEL}

;Use the Right Control Button as my Insert button on my DELL Latitude E6500.
;I use the insert key a lot with e.g. FreeMind or Xmind, used to own MindManager in 1996...
RControl::Send {Insert}

;[Ctrl]+[Shift]+$ = € an alternative could have been ::$$::€ , You need two $$ to get one €...
LControl & $::Send €

;[Ctrl]+[Shift]+" = ", Since I often use the Dutch languagebar settings to quickly write characters like é and à, writing a single " requires you to type the " and a {Space} because the Dutch language setting will use the " in combination with a letter to turn it into a special character. Bij using a {Space} after the " it knows that only the " is required. Pressing [Ctrl] + [Shift] + " will give me a double quote without having to type an extra [Space]
LControl & "::Send, {SHIFTDOWN}'{SHIFTUP}{SPACE}

;[Ctrl]+[Shift]+D = Paste Date & Time
;In various documents and filenames I want to be able to quickly insert the current date and time. Does roughly the same as [Ctrl] + ; in Excel.
^+D::
FormatTime, CurrentDateTime,, yyyyMMdd-HHmm
SendInput %CurrentDateTime%
return

;[Ctrl]+[Shift]+V = Paste Text Only, remove all formatting before pasting text
;This is what it all started. In certain Office 2007 applications,
;I could no longer easily write simple VBA macro's to paste text values only. No it is one script with
;the same behaviour throughout ALL applications.....(except for Evernote as Evernote also uses this combination)
^+v::
bak = %clipboard%
clipboard = %bak%
Send ^v
return

;Sub-routine to strip funny characters, used in the sorting function
REMOVECHAR:
AutoTrim,Off
StringCaseSense,On
StringReplace,string,string,–,-,All ;emdash
StringReplace,string,string,´,',All
StringReplace,string,string,’,',All
StringReplace,string,string,©,(C),All
StringReplace,string,string,“,",All ;left quote
StringReplace,string,string,”,",All ;right quote
StringReplace,string,string,®,(R),All
StringReplace,string,string,¼,1/4,All
StringReplace,string,string,½,1/2,All
StringReplace,string,string,¾,3/4,All
StringReplace,string,string,™,TM,All
StringReplace,string,string,«,<<,All StringReplace,string,string,»,>>,All
StringReplace,string,string,„,",All
StringReplace,string,string,•,-,All ;bullet
StringReplace,string,string,…,...,All
Return

^+U:: ; [Ctrl]+[Shift]+U (Unsorted)
;Column Sorting & Unique Filter
;YOU must first place the unsorted list in the clipboard [Ctrl]+c.
;then move cursor to where you want to paste the sorted and Unique data and type [Ctril]+[Shift]+U.
string = %clipboard%
Gosub,REMOVECHAR ;remove if you don't want santized values
Sort,string,C U
clipboard := string
Send ^v
return

^+T:: ; CTRL-SHIFT+T (Trim)
;Trim whitespace at the START AND END of every line in a block of text
;First place the block of text in the clipboard [Ctrl]+c
;Move to where you want to paste the trimmed text and press [Ctrl]+[Shift]+T
;You have to loop through every line.
;The standard behaviour is to only remove the spaces in front of the first line and after the last line
;In excel, I use the age old CaseConvert macro from Chip Pearson to do this....
textblock = %clipboard% ; Copy clipboard to var. textblock
clipboard = ; clear clipboard
Loop, parse, textblock, `n, `r ; loop through text block
{
string = %A_LoopField% ; copy current line of text to var. string
string := RegExReplace( string, "(^\s+)|(\s+$)") ; remove pefix & suffix spaces
clipboard = %clipboard%%string%`r`n ; glue current line at the end of your clipboard
}
Send ^v
return

^+M:: ; CTRL-SHIFT+M (Mail)
; Mail...take every email address in a block of text and separate each line in the block with ;
; First YOU must place the block of text in the clipboard [Ctrl]+c
; Move to where you want to paste the adjusted text and press [Ctrl]+[Shift]+M
; The standard behaviour is to remove the first and last spaces in each line and to end each line with a ;
; If you have multiple addresses per line you have to replace the [Space] or other character with a ;
; Instead of many lines in the block, you will get one very long line with ; as separators.
textblock = %clipboard% ; Copy clipboard to var. textblock
clipboard = ; clear clipboard
Loop, parse, textblock, `n, `r ; loop through text block
{
string = %A_LoopField% ; copy current line of text to var. string
string := RegExReplace( string, "(^\s+)|(\s+$)") ; remove pefix & suffix spaces
clipboard = %clipboard% %string%; ; glue current line/string at the end of your clipboard
}
Send ^v
return

^+I:: ; CTRL-SHIFT+I (iMail)
; Mail...take every email address in a block of text and separate each address as a line
; First YOU must place the block of text in the clipboard [Ctrl]+c
; Move to where you want to paste the adjusted text and press [Ctrl]+[Shift]+M
textblock = %clipboard% ; Copy clipboard to var. textblock
clipboard = ; clear clipboard
Loop, parse, textblock, `n, `r ; loop through text block
{
string = %A_LoopField% ; copy current line of text to var. string
StringReplace,string,string,;,`r`n,All
clipboard = %clipboard% %string%`r`n ; glue current line at the end of your clipboard
}
textblock = %clipboard%
clipboard = ; clear clipboard
Loop, parse, textblock, `n, `r ; loop through text block
{
string = %A_LoopField% ; copy current line of text to var. string
string := RegExReplace( string, "(^\s+)|(\s+$)") ; remove pefix & suffix spaces
clipboard = %clipboard%%string%`r`n ; glue current line at the end of your clipboard
}
Send ^v
return

^+O:: ; [Ctrl]+[Shift]+O
;Swap list of strings around comma... Clinton, Bill becomes Bill Clinton
;YOU must first place the list in the clipboard [Ctrl]+c.
;then move cursor to where you want to paste the list and type [Ctril]+[Shift]+O.
Textblock = %clipboard%
clipboard = ; clear clipboard
Loop, parse, textblock, `n, `r ; loop through text block
{
CurrentString = %A_LoopField% ; copy current line of text to var. CurrentString
StringGetPos, pos, CurrentString,`,
if pos >= 0
{
length1 := pos
length2 := pos + 2
StringLen, length, CurrentString
StringMid, StringOnLeft, CurrentString, 1, %length1%
StringMid, StringOnRight, CurrentString, %length2%, %length%
StringOnRight := RegExReplace( StringOnRight, "(^\s+)|(\s+$)") ; remove pefix & suffix spaces
}
clipboard = %clipboard%%StringOnRight% %StringOnLeft%`r`n ; glue current line at the end of your clipboard
}
Send ^v
return


;======================================
;Commented out instructions that I don't use anymore
;
;LControl & !::Send Dit is een test met een{ENTER}nieuwe regel voor de volgende tekst{ENTER}en een derde regel.
;
; [Linker Control] + < = =< , srews up sizing of selected text in Word ;LControl & <::send {ASC 8804} ; [Linker Control] + > = => , srews up sizing of selected text in Word
;LControl & >::send {ASC 8805}

; [Linker Control] + + = +/- , screws up zooming with Ctrl +
;LControl & +::send {ASC 0177}

=====Einde AutoHotKey Script=====

No comments:

Post a Comment