-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmojiKeyboard.ahk
132 lines (113 loc) · 3.16 KB
/
EmojiKeyboard.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
OnExit, ExitSave ;Label to activate when the script is ending
Run, LuaMacros.exe EmojiKeyboardMacro.lua -r ;runs LuaMacros with the appropriate .lua file, auto-running the file as soon as the application loads
global emojiList := {}
emojiList := readArray("EmojiListSaved.txt") ;Loads associations from file into array 'emojiList'
MsgBox Emoji Keyboard Initialized.
;F24 - Run key in "KeyPressed.txt"
;F23 - Ctrl
;F22 - Enter
;F21 - Shift
F24:: ;Activate keys
FileRead, key, keypressed.txt
;Tippy(emojiList[key])
if emojiList[Key]
{
readyEmoji := emojiList[Key]
;SendInput {Raw}%readyEmoji%
clipStorage := ClipboardAll ;made changes to use clipboard to send text instead of raw input for speed when sending large amounts of text
clipboard =
clipboard = %readyEmoji%
ClipWait, 5
SendInput, ^v
Sleep 100
clipboard := clipStorage
}
return
^F24:: ;Program keys
FileRead, key, keypressed.txt
AddToEmojiList(key)
;MsgBox % "Added: " key ": " emojiList[key]
return
+F21::saveArray() ;Save associations
^+F21::loadArray() ;Load associations
~F22::Send, {Enter} ;Workaround to restore normal function of enter key
Tippy(tipsHere, wait:=333) ;Makes a tooltip appear by the cursor
{
ToolTip, %tipsHere%
SetTimer, noTip, %wait% ;--in 1/3 seconds by default, remove the tooltip
}
noTip:
ToolTip,
;removes the tooltip
return
AddToEmojiList(keyAssign) ;Adds the currently highlighted text to the list of associations, assigning it to keyAssign
{
global emojiList
clipStorage := ClipboardAll
clipboard =
Send, ^c
ClipWait, 0
if ErrorLevel
{
MsgBox, Adding emoji failed!
return
}
emoji = %clipboard%
;MsgBox %clipboard%
;MsgBox %emoji%
emojiList[keyAssign] := emoji
clipboard := clipStorage
clipStorage =
emoji =
}
genTextArray() ;Converts the array that holds the associations into text form for saving
{
global emojiList
fileCache =
For key, value in emojiList
{
;MsgBox % key A_Tab value
fileCache := fileCache . key A_Tab value . "`n"
}
return fileCache
}
readArray(fileName) ;Loads associations from fileName
{
arrayCache := {}
Loop, read, %fileName%
{
parseArray := StrSplit(A_LoopReadLine, A_Tab)
arrayCache[parseArray[1]] := parseArray[2]
;MsgBox % parseArray[1]
;MsgBox % parseArray[2]
;MsgBox % arrayCache[parseArray[1]]
}
return arrayCache
}
saveArray() ;Saves associations to EmojiListSaved.txt
{
textArray := genTextArray()
FileDelete, EmojiListSaved.txt
file := FileOpen("EmojiListSaved.txt", "rw","UTF-8")
file.Write(textArray)
file.close
MsgBox Saved to file!
return 0
}
loadArray() ;Saves associations to EmojiListSaved.txt
{
emojiList := readArray("EmojiListSaved.txt")
MsgBox Loaded from file!
return 0
}
;Esc::ExitApp ;debug hotkeys
;F12::Reload
ExitSave: ;Responsible for saving associations to file and closing LuaMacros when the script ends (See "OnExit, ExitSave" at beginning of script)
saveArray()
Process, Close, LuaMacros.exe
ExitApp