-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.ahk
More file actions
49 lines (40 loc) · 1.4 KB
/
script.ahk
File metadata and controls
49 lines (40 loc) · 1.4 KB
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
;------------------------------------------
; English ⇄ Arabic Keyboard Mapper
; Hotkey: Ctrl + Shift + R
; By: molo
;------------------------------------------
enToAr := { "q": "ض", "w": "ص", "e": "ث", "r": "ق", "t": "ف", "y": "غ", "u": "ع", "i": "ه", "o": "خ", "p": "ح", "[": "ج", "]": "د", "a": "ش", "s": "س", "d": "ي", "f": "ب", "g": "ل", "h": "ا", "j": "ت", "k": "ن", "l": "م", ";": "ك", "'": "ط", "z": "ئ", "x": "ء", "c": "ؤ", "v": "ر", "b": "لا", "n": "ى", "m": "ة", ",": "و", ".": "ز", "/": "ظ"}
arToEn := {}
for key, value in enToAr
arToEn[value] := key
^+r::
oldClipboard := ClipboardAll
Send, ^c
ClipWait, 1
selectedText := Clipboard
if (!selectedText) {
Clipboard := oldClipboard
return
}
result := ""
Loop, Parse, selectedText
{
char := A_LoopField
charLower := RegExReplace(char, "[A-Z]", Chr(Asc(char)+32)) ; lowercase conversion
; English to Arabic
if (enToAr.HasKey(charLower))
result .= enToAr[charLower]
; Arabic to English
else if (arToEn.HasKey(char))
result .= arToEn[char]
else
result .= char
}
; Paste Into Selected Input
Clipboard := result
Sleep, 50
Send, ^v
; Restore original clipboard
Sleep, 50
Clipboard := oldClipboard
return