GroupAdd auo_gruop, ahk_exe msedge.exe
GroupAdd auo_gruop, ahk_exe chrome.exe
GroupAdd auo_gruop, ahk_exe snipaste.exe
GroupAdd auo_gruop, ahk_exe mspaint.exe
#IfWinActive ahk_group auo_gruop
{
; 添加到word
!CapsLock::add2word()
; 查词
`::searchWord()
}
add2word(){
; 将图片复制到粘贴板
Send ^c
; t 用来存放标题
InputBox, title, TITLE, , , 600,100,50,100
InputBox, content, CONTENT, , , 600,100,50,100
if ErrorLevel
MsgBox, CANCEL was pressed.
else
; 如果标题为空,则返回
if title=
{
Return
}
; 如果内容为空,则继续,为内容赋值空串,防止后面报错
if content=
{
content:=""
}
insertTitle(title)
insertPic()
insertContent(content)
}
insertTitle(real_title){
; active the document was opened
oWord := ComObjActive("Word.Application")
oWord.Selection.TypeParagraph
; add some split while line
oWord.Selection.TypeText(real_title)
; save the active word document
oWord.ActiveDocument.Save
}
insertPic(){
; clipboard = ; 让剪贴板初始为空, 这样可以使用 ClipWait 检测文本什么时候被复制到剪贴板中.
; ClipWait
; active the document was opened
oWord := ComObjActive("Word.Application")
oWord.Selection.TypeParagraph
; paste the clipboard to the word document
oWord.Selection.Paste
; save the active word document
oWord.ActiveDocument.Save
}
insertContent(content){
; active the document was opened
oWord := ComObjActive("Word.Application")
oWord.Selection.TypeParagraph
content_arr := StrSplit(content, " ")
For index, value in content_arr{
content_new := index ". " value "`n"
; add some split while line
oWord.Selection.TypeText(content_new)
}
oWord.Selection.TypeText("---------------------------------------------------`n")
oWord.Selection.TypeParagraph
; save the active word document
oWord.ActiveDocument.Save
ToolTip, add
SetTimer, RemoveToolTip, -1000
return
RemoveToolTip:
ToolTip
return
}
searchWord(){
Click right
SendInput, {Up 3}
SendInput, {Enter}
}
#w::Suspend