This is a utility for keeping a personal list of favorite smiles/emoticons and inserting them in any forum that supports [img] or <img> tags.
To insert a smiley in a forum post, just click it in the Smile Master window. To add a smiley to the list, copy the URL and then click Add on the menu bar. To remove a smiley, right-click it and click Delete.
There are two optional ways to add smilies as well. By Alt+Right-clicking an image in your browser. Or automatically, by watching the clipboard for .gif or.png URLs. As you can see there's also an option to use HTML tags instead of BBCode. The Max Size option will resize smilies that are larger in either dimension so as not to take up too much space in the Smile Master window. (The actual smiley will, of course, be unchanged.
Code:
; AutoHotkey Version: 1.0.47.00
; Language: English
; Author: ManaUser
#SingleInstance Force
#NoEnv
SendMode Input
OnExit HandleExit
SetWorkingDir %A_ScriptDir%
IfExist smile.ico
Menu TRAY, Icon, smile.ico
IfNotExist SmileData
FileCreateDir SmileData
SetWorkingDir SmileData
SetTitleMatchMode RegEx
GroupAdd Browser, - Microsoft Internet Explorer$
GroupAdd Browser, - Mozilla
GroupAdd Browser, - Opera$
SmileCount := 0
X := 0
Y := 0
RowHeight := 0
MaxSize =
OpenTag = [img]
CloseTag = [/img]
Menu, TRAY, NoStandard
Menu, TRAY, Add, &Show, ShowGui
Menu, TRAY, Add, &Exit, HandleExit
Menu, TRAY, Default, &Show
Menu, OptionMenu, Add, &Alt+Right-Click Add, ToggleAltAdd
Menu, OptionMenu, Add, &Watch Clipboard, ToggleAutoAdd
Menu, OptionMenu, Add
Menu, OptionMenu, Add, Use &HTML, ToggleHTML
Menu, OptionMenu, Add
Menu, OptionMenu, Add, &Max Size:%A_Space%, SetMaxSize
Menu, MyMenuBar, Add, &Add, AddNow
Menu, MyMenuBar, Add, &Options, :OptionMenu
Menu, ContextMenu, Add, &Delete, DeleteSmile
Gui Menu, MyMenuBar
Gui +Resize +E0x200 +ToolWindow +AlwaysOnTop
Gui +MinSize85x40 +LastFound
LoadSetting("XPos", 600, GuiX)
LoadSetting("YPos", 300, GuiY)
LoadSetting("Width", 79, GuiWidth)
LoadSetting("Height", 79, GuiHeight)
Gui Show, X%GuiX% Y%GuiY% NoActivate, Smile Master
MyID := WinExist()
WinMove ahk_id %MyID%, , %GuiX%, %GuiY%, %GuiWidth%, %GuiHeight%
Hotkey IfWinActive, ahk_group Browser
SetTimer KeepOffTop, 200
HotKey !Rbutton, Off
LoadSetting("AddWithAlt", 0, AltAdd)
LoadSetting("WatchClipboard", 0, ClipWatch)
LoadSetting("UseHTML", 0, UseHTML)
LoadSetting("MaxImageSize", 64, NewSize)
If AltAdd
GoSub aToggleAltAdd
If ClipWatch
GoSub aToggleAutoAdd
If UseHTML
GoSub aToggleHTML
GoSub aSetMaxSize
Loop SMILE=*.*
LoadSmile(A_LoopFileFullPath)
Return
; ***************** Hotkeys *****************
#IfWinActive ahk_group Browser
!Rbutton::
SavedClip := ClipboardAll
Clipboard =
If WinActive("- Opera$")
{
If (A_Cursor = "Unknown") ;Image is also a link
SendPlay {Click Right}y
else
SendPlay {Click Right}c
}
Else If WinActive("- Mozilla")
SendPlay {Click Right}o
Else If WinActive("- Microsoft Internet Explorer$")
{
SendPlay {Click Right}{Up}{Enter}
WinWaitActive, Properties,
MouseClick, left, 96, 218
MouseClick, left, 96, 218
MouseClick, left, 96, 218
SendPlay ^c{Tab}{Enter}
}
ClipWait 0.5
URL := Clipboard
Clipboard := SavedClip
If (RegExMatch(URL, "i)^https?://.*\.(gif|png|jpg|jpeg)$"))
AddSmile(URL)
Return
; ***************** GUI Subs ****************
ShowGui:
Gui Show, NoActivate
Return
GuiSize:
Reposition()
Return
AddNow:
URL := RegExReplace(Clipboard, "i)\[img](.*)\[/img]", "$1")
If (RegExMatch(URL, "i)^https?://.*\.(gif|png|jpg|jpeg)$"))
AddSmile(URL)
Else
MsgBox Clipboard does not contain a valid image URL.
Return
ToggleAltAdd:
AltAdd := !AltAdd
SaveSetting("AddWithAlt", AltAdd)
aToggleAltAdd:
Menu, OptionMenu, ToggleCheck, &Alt+Right-Click Add
HotKey !Rbutton, Toggle
Return
ToggleAutoAdd:
ClipWatch := !ClipWatch
SaveSetting("WatchClipboard", ClipWatch)
aToggleAutoAdd:
Menu, OptionMenu, ToggleCheck, &Watch Clipboard
Return
ToggleHTML:
UseHTML := !UseHTML
SaveSetting("UseHTML", UseHTML)
aToggleHTML:
Menu, OptionMenu, ToggleCheck, Use &HTML
If UseHTML
{
OpenTag = <img src="
CloseTag = ">
}
Else
{
OpenTag = [img]
CloseTag = [/img]
}
Return
SetMaxSize:
Gui -AlwaysOnTop
InputBox NewSize, Enter New Max Image Size,
( LTrim
Images larger than this will be shown at this size to save space on the Smile Master interface.
Enter 0, the word None, or nothing for no limit.
), , 350, 160, , , , , %MaxSize%
Gui +AlwaysOnTop
If ErrorLevel
Return
NewSize += 0
If (NewSize = "" OR NewSize < 0)
NewSize = None
SaveSetting("MaxImageSize", NewSize)
Reload ;I could have made a resizer function...
Return
aSetMaxSize:
Menu OptionMenu, Rename, &Max Size: %MaxSize%, &Max Size: %NewSize%
MaxSize := NewSize
Reposition()
Return
SmileClick:
Gui Show, Hide
Send % OpenTag . %A_GuiControl% . CloseTag
Gui Show, NoActivate
Return
GuiContextMenu:
If (SubStr(A_GuiControl, 1, 5) = "Smile")
{
SmileClicked := A_GuiControl
Menu ContextMenu, Show
}
Return
DeleteSmile:
GuiControl, Hide, %SmileClicked%
GuiControlGet FileName, , %SmileClicked%
FileDelete %FileName%
%SmileClicked% =
Reposition()
Return
; *************** Other Subs ****************
KeepOffTop:
;IfWinActive Smile Master ;Returned a false positive, oddly enough
If (WinExist("A") = MyID)
{
If NOT GetKeyState("LButton")
{
Gui Show, Hide
Gui Show, NoActivate
;Let;s check the current position too
WinGetPos GuiX, GuiY, , , ahk_id %MyID%
}
}
Return
HandleExit:
SaveSetting("XPos", GuiX)
SaveSetting("YPos", GuiY)
SaveSetting("Width", GuiWidth)
SaveSetting("Height", GuiHeight)
ExitApp
Return
OnClipboardChange:
If (ClipWatch = 1 AND A_EventInfo = 1)
{
URL := RegExReplace(Clipboard, "i)\[img](.*)\[/img]", "$1")
If (RegExMatch(URL, "i)^https?://.*\.(gif|png)$"))
AddSmile(URL)
}
Return
; **************** Functions ****************
AddSmile(URL)
{
Global
FileName := FileEncode(URL)
UrlDownloadToFile %URL%, %FileName%
If ErrorLevel
{
MsgBox Could not download image.
return
}
LoadSmile(FileName)
}
LoadSmile(FileName)
{
Global
WinGetPos, , , GuiWidth, , ahk_id %MyID%
SmileCount ++
Gui, Add, Picture, X%X% Y%Y% AltSubmit gSmileClick vSmile%SmileCount%, %FileName%
Smile%SmileCount% := FileDecode(FileName)
GuiControlGet Pic, Pos, Smile%SmileCount%
If (MaxSize != "None" AND PicW > MaxSize AND PicW > PicH)
{
GuiControl, , Smile%SmileCount%, *W%MaxSize% *H-1 %FileName%
GuiControlGet Pic, Pos, Smile%SmileCount%
}
Else If (MaxSize != "None" AND PicH > MaxSize)
{
GuiControl, , Smile%SmileCount%, *H%MaxSize% *W-1 %FileName%
GuiControlGet Pic, Pos, Smile%SmileCount%
}
If (X + PicW + 11 > GuiWidth)
{
X := 0
Y += RowHeight
RowHeight := 0
GuiControl, MoveDraw, Smile%SmileCount%, X%X% Y%Y%
}
X += PicW
If (PicH > RowHeight)
RowHeight := PicH
}
Reposition()
{
Global
X := 0
Y := 0
RowHeight := 0
WinGetPos, , , GuiWidth, GuiHeight, ahk_id %MyID%
Loop %SmileCount%
{
If (Smile%A_Index% = "")
Continue
GuiControlGet Pic, Pos, Smile%A_Index%
If (X + PicW + 11 > GuiWidth)
{
X := 0
Y += RowHeight
RowHeight := 0
}
GuiControl, MoveDraw, Smile%A_Index%, X%X% Y%Y%
X += PicW
If (PicH > RowHeight)
RowHeight := PicH
}
}
FileEncode(URL)
{
StringReplace, URL, URL, /, #F, 1
StringReplace, URL, URL, :, #C, 1
StringReplace, URL, URL, *, #S, 1
StringReplace, URL, URL, ?, #Q, 1
URL := "SMILE=" . URL
Return URL
}
FileDecode(FileName)
{
StringReplace, FileName, FileName, #F, /, 1
StringReplace, FileName, FileName, #C, :, 1
StringReplace, FileName, FileName, #S, *, 1
StringReplace, FileName, FileName, #Q, ?, 1
StringTrimLeft, FileName, FileName, 6
Return FileName
}
GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^c
ClipWait
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}
SaveSetting(Key, Value)
{
IniWrite, %Value%, SmileMaster.ini, General, %Key%
}
LoadSetting(Key, Default = " ", ByRef Value = 0)
{
IniRead, Value, SmileMaster.ini, General, %Key%, %Default%
IniRead, OutputVar, Filename, Section, Key [, Default]
Return Value
}
Download the tray icon. (Optional) This goes in the same folder as the script.
In case you don't know where to get smilies, here one place:
http://www.mysmilies.com/
Note that it must be a source that allows remote linking.
This script will create a sub-folder named Smile Master to store the files and an ini for settings.
Let me know if you think it's

or if you get

and need help.
