-
Notifications
You must be signed in to change notification settings - Fork 0
/
LanguageTools.ahk
83 lines (71 loc) · 2.12 KB
/
LanguageTools.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
; -----------------------------------------
; Definition, Translation and Accent Cycling Hot Keys
; by Oscar Duignan <[email protected]>
; -----------------------------------------
; Only one instance required
#SingleInstance force
#NoEnv
; -----------------------------------------
; Read settings file
; -----------------------------------------
Loop, read, settings.cfg
{
NextLine = %A_LoopReadLine%
LineLength := StrLen(NextLine)
if LineLength > 0
{
SemiColonPos := InStr(NextLine,";")
if SemiColonPos <> 1
{
StringSplit, VAR,NextLine,"="
%VAR1% = %VAR2%
}
}
}
StringReplace, ACCENT_TRANSFORMATIONS, ACCENT_TRANSFORMATIONS, %A_SPACE%, , All
; -----------------------------------------
; Set up the appropriate hot keys
; -----------------------------------------
HotKey, %DICTIONARY_HOTKEY%, Define, On
HotKey, %TRANSLATE_HOTKEY%, Translate, On
HotKey, %ACCENT_HOTKEY%, Cycle_Accents, On
exit
; -----------------------------------------
; Lookup selected text using dictionary.com
; -----------------------------------------
Define:
clipboardBackup := clipboard
SendPlay ^c
ClipWait
Run http://dictionary.reference.com/browse/%clipboard%
clipboard := clipboardBackup
Return
; -----------------------------------------
; Lookup selected text using google translate
; -----------------------------------------
Translate:
clipboardBackup := clipboard
SendPlay ^c
ClipWait
Run http://translate.google.com/translate_t#%TRANSLATE_FROM%|%TRANSLATE_TO%|%clipboard%
clipboard := clipboardBackup
Return
; -----------------------------------------
; Cycle through the accents for the character to the left of the text cursor
; -----------------------------------------
Cycle_Accents:
clipboardBackup := clipboard
clipboard := ""
SendPlay +{Left}^c
ClipWait
charPosition := InStr(ACCENT_TRANSFORMATIONS,clipboard,true)
if charPosition > 0
{
charPosition++
nextChar := SubStr(ACCENT_TRANSFORMATIONS,charPosition,1)
SendPlay {Raw}%nextChar%
} else {
SendPlay {Right}
}
clipboard := clipboardBackup
Return