Code: Select all
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#Persistent
#SingleInstance force
#IfWinActive
#Hotstring c0 r0
;Global variables
;Left-click and right-click menus are not open when script begins
LeftClickMenuOpen := 0
RightClickMenuOpen := 0
;Program Start
gosub CreateLeftClickMenu
gosub CreateRightClickMenu
OnMessage(0x404, "AHK_NOTIFYICON")
fileread, savedtemplates, templates.txt
loop, parse, savedtemplates,\, `n`r
{
hs:=strsplit(a_loopfield,"|"," `n`r")
hotstring(hs[1],StrReplace(hs[2],"`n",""))
}
return
CreateLeftClickMenu:
Menu, LeftClickMenu, add, Add Template, Template
Menu, LeftClickMenu, add
Menu, LeftClickMenu, add, % "Exit", ExitProgram
return
CreateRightClickMenu:
Menu, tray, NoStandard
Menu, tray, add, Add Template, Template
Menu, tray, add
Menu, tray, add, % "Exit", ExitProgram
return
Template:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Template start
Gui, Add, Text, x6 y17 w180 h20 , Template Keyword
Gui, Add, Edit, x6 y37 w180 h20 vName
Gui, Add, Text, x6 y67 w180 h20 , More Info
Gui, Add, Edit, x6 y97 w610 h270 vInfo
Gui, Add, Button, x296 y387 w100 h30 gClear, Clear
Gui, Add, Text, x6 y387 h20, Add ^b between words you want to bold, ie: ^bHEENT^b
Gui, Add, Text, x6 y407 h20, Add ^i between words you want to italicize, ie: ^iHEENT^i
Gui, Add, Button, x406 y387 w100 h30 gSubmitMore, Submit + Add More
Gui, Add, Button, x516 y387 w100 h30 gSubmitExit, Submit + Exit
Gui, Show, x231 y199 h427 w623, New GUI Window
Return
Clear:
GuiControl,, Name
GuiControl,, Info
Gui, Submit, NoHide
returnClear:
GuiControl,, Name
GuiControl,, Info
Gui, Submit, NoHide
return
SubmitMore:
Gui, Submit, NoHide
if Name is space
{
Msgbox, Please insert some data first!
return
}
if FileExist("templates.txt")
{
FileAppend, `n\::%Name%|%Info%, templates.txt
}
Else
{
FileAppend, ::%Name%|%Info%, templates.txt
}
GuiControl,, Name
GuiControl,, Info
return
SubmitExit:
Gui, Submit, NoHide
if Name is space
{
Msgbox, Please insert some data first!
return
}
if FileExist("templates.txt")
{
FileAppend, `n\::%Name%|%Info%, templates.txt
}
Else
{
FileAppend, ::%Name%|%Info%, templates.txt
}
Reload
return
Esc::
GuiClose:
Gui Destroy
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Template End
return
/*
Lexikos method of detecting Left mouse click on ToolTray (modified)
If left click and left-click menu open, close left-click menu
If left click and left-click menu not open, open left-click menu
(and close right-click menu, if open)
If right click and right-click menu open, close right-click menu
If right click and right-click menu not open, open right-click menu
(and close left-click menu, if open)
*/
AHK_NOTIFYICON(wParam, lParam)
{
global LeftClickMenuOpen, RightClickMenuOpen
if (lParam = 0x202) ; WM_LBUTTONUP
{
;Close right-click menu
RightClickMenuOpen := 0
if (LeftClickMenuOpen)
{
;If left-click menu is open, close it
Send {Esc}
}
else
{
;If left-click menu is not open, open it
Menu, LeftClickMenu, Show
}
;Toggle state of left-click menu
;Open to close
;Close to open
LeftClickMenuOpen := !LeftClickMenuOpen
}
else if (lParam = 0x205) ; WM_RBUTTONUP
{
;Close left-click menu
LeftClickMenuOpen := 0
if (RightClickMenuOpen)
{
;If right-click menu is open, close it
Send {Esc}
}
else
{
;If right-click menu is not open, open it
Menu, Tray, Show
}
;Toggle state of right-click menu
;Open to close
;Close to open
RightClickMenuOpen := !RightClickMenuOpen
}
return 0
}
ExitProgram: