Untitled

 avatar
unknown
plain_text
2 hours ago
8.0 kB
12
No Index
#NoEnv
#SingleInstance Force
#Persistent

; Use UTF-8 for all file operations
FileEncoding, UTF-8

; Include Enter (LF `n) and Enter (CR `r) + Tab `t + Space (note trailing space!)
;#Hotstring EndChars -()[]{}':;"/\,.?!`n`r`t 

; ==== Init / Defaults ====
cfgFile := A_ScriptDir . "\AutoCorrect.cfg"

; Fallback: falls INI nicht existiert -> DE
IniRead, startLang, %cfgFile%, Boot, StartLanguage, DE
if (startLang != "EN")
    startLang := "DE"

currentLanguage := startLang

Menu, Tray, UseErrorLevel
Menu, Tray, Add, Toggle Language (Current: %currentLanguage%), ToggleLanguage
Menu, Tray, Default, Toggle Language (Current: %currentLanguage%)
Menu, Tray, Tip, AutoCorrect Language Toggle
Menu, Tray, Icon

ScrollLock::Suspend
SetTitleMatchMode,2 ;this allows window matching with a partial match inside the whole window title
;------------------------------------------------------------------------------
; CHANGELOG:
;
; Sep 13 2007: Added more misspellings.
;              Added fix for -ign -> -ing that ignores words like "sign".
;              Added word beginnings/endings sections to cover more options.
;              Added auto-accents section for words like fiancée, naïve, etc.
; Feb 28 2007: Added other common misspellings based on MS Word AutoCorrect.
;              Added optional auto-correction of 2 consecutive capital letters.
; Sep 24 2006: Initial release by Jim Biancolo (http://www.biancolo.com)
;
; INTRODUCTION
;
; This is an AutoHotKey script that implements AutoCorrect against several
; "Lists of common misspellings":
;
; This does not replace a proper spellchecker such as in Firefox, Word, etc.
; It is usually better to have uncertain typos highlighted by a spellchecker
; than to "correct" them incorrectly so that they are no longer even caught by
; a spellchecker: it is not the job of an autocorrector to correct *all*
; misspellings, but only those which are very obviously incorrect.
;
; From a suggestion by Tara Gibb, you can add your own corrections to any
; highlighted word by hitting Win+H. These will be added to a separate file,
; so that you can safely update this file without overwriting your changes.
;
; Some entries have more than one possible resolution (achive->achieve/archive)
; or are clearly a matter of deliberate personal writing style (wanna, colour)
;
; These have been placed at the end of this file and commented out, so you can
; easily edit and add them back in as you like, tailored to your preferences.
;
; SOURCES
;
; http://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings
; http://en.wikipedia.org/wiki/Wikipedia:Typo
; Microsoft Office autocorrect list
; Script by jaco0646 http://www.autohotkey.com/forum/topic8057.html
; OpenOffice autocorrect list
; TextTrust press release
; User suggestions.
;
; CONTENTS
;
;   Settings
;   AUto-COrrect TWo COnsecutive CApitals (commented out by default)
;   Win+H code
;   Fix for -ign instead of -ing
;   Word endings
;   Word beginnings
;   Accented English words
;   Common Misspellings - the main list
;   Ambiguous entries - commented out
;------------------------------------------------------------------------------
SetNumlockState, AlwaysOn
SetCapsLockState, AlwaysOff
SetScrollLockState, AlwaysOff

;------------------------------------------------------------------------------
; Settings
;------------------------------------------------------------------------------
#NoEnv ; For security
#SingleInstance force

LCtrl & Capslock::

   SetCapsLockState, off

Return


;This is quite useful, selects the last typed word and googles it with your default browser
#g::
{
Send ^+{Left}
Send, ^c
Sleep 50
Run, https://www.google.com/search?q=%clipboard%
Return
}

#Persistent
#SingleInstance Force
SetTitleMatchMode, 2


return

;-------------------------
;Win-U makes selected case UPPERCASE, Win-T makes it Title Case
;-------------------------
#t::
{
clip_temp= %Clipboard%
send, ^x
titlecase= %Clipboard%
StringUpper titlecase, Clipboard, T
sleep, 200
Send %titlecase%
Sleep, 200
clipboard=%clip_temp%
return
}
#u::
{
clip_temp= %Clipboard%
send, ^x
StringUpper Clipboard, Clipboard
sleep, 200
Send %Clipboard%
Sleep, 200
clipboard=%clip_temp%
return
}


;------------------------------------------------------------------------------
; Capslock to enter misspelling correction.  It will be added to this script.
;------------------------------------------------------------------------------
; --- Language Toggle ---
>+CapsLock::GoSub, ToggleLanguage

ToggleLanguage:
if (currentLanguage = "EN") {
    currentLanguage := "DE"
    Menu, Tray, Rename, Toggle Language (Current: EN), Toggle Language (Current: DE)
    Menu, Tray, Default, Toggle Language (Current: DE)
    TrayTip, Language Set, Language is now: Deutsch, 1000
} else {
    currentLanguage := "EN"
    Menu, Tray, Rename, Toggle Language (Current: DE), Toggle Language (Current: EN)
    Menu, Tray, Default, Toggle Language (Current: EN)
    TrayTip, Language Set, Language is now: English, 1000
}
return



; --- CapsLock: Add new correction ---
Capslock::
AutoTrim On
ClipboardOld := ClipboardAll
Clipboard := ""
Send ^+{Left}
Send ^c
ClipWait 1
if ErrorLevel
    return
Clipboard := Trim(Clipboard)
StringReplace, Hotstring, Clipboard, ``, ````, All
StringReplace, Hotstring, Hotstring, `r`n, ``r, All
StringReplace, Hotstring, Hotstring, `n, ``r, All
StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
StringReplace, Hotstring, Hotstring, `;, ```;, All
Clipboard := ClipboardOld

SetTimer, MoveCaret, 10
; InputBox, Hotstring, New Hotstring, Provide the corrected word on the right side.`nExample: ::teh::the
InputBox, Hotstring, New Hotstring, Provide the corrected word on the right side. You can also edit the left side if you wish.nnExample entry:n::teh::the,,,,,,,, ::%Hotstring%::

if ErrorLevel <> 0
    return

correction := Trim(RegExReplace(Hotstring,":{2}.*:{2}",""))
Send %correction%{Space}
Hotstring := Trim(Hotstring)

scriptPath := A_ScriptFullPath
; Read current script
FileRead, scriptContent, %A_ScriptFullPath%

; Find the language block
searchTag := "#If (currentLanguage = """ currentLanguage """)"
pos := InStr(scriptContent, searchTag)
if (!pos) {
    MsgBox, 48, Error, Couldn't find the %searchTag% block in the script.
    return
}

; Find the end of the block (next #If after the current one)
rest := SubStr(scriptContent, pos + StrLen(searchTag))
nextIfPos := InStr(rest, "#If")
if (nextIfPos)
    insertPos := pos + StrLen(searchTag) + nextIfPos - 1
else
    insertPos := StrLen(scriptContent) + 1

; Build new content
newContent := SubStr(scriptContent, 1, insertPos - 1)
        . "" Hotstring "`n"
        . SubStr(scriptContent, insertPos)

; Overwrite the script file
FileDelete, %A_ScriptFullPath%
FileAppend, %newContent%, %A_ScriptFullPath%

; -------- NEW: gewünschte Startsprache für den Reload setzen --------
; Default nach Korrektur ist DE, außer wenn wir eine EN-Korrektur in den EN-Block eingefügt haben
reloadLang := (currentLanguage = "EN") ? "EN" : "DE"
IniWrite, %reloadLang%, %cfgFile%, Boot, StartLanguage


Reload
return

MoveCaret:
IfWinNotActive, New Hotstring
    return
Send {HOME}
Loop % StrLen(Hotstring) + 4
    SendInput {Right}
SetTimer, MoveCaret, Off
return





;------------------------------------------------------------------

;-------------------------------------------------------------------------------
; Anything below this point was added to the script by the user via the Capslock hotkey.
;-------------------------------------------------------------------------------

; --- Hotstrings for German ---
#If (currentLanguage = "DE")
::hallo::Hallo
#If

#If (currentLanguage = "EN")
::helo::hello
#If
Editor is loading...
Leave a Comment