批量搜索工具升级,使用easyini库重写配置文件,可以自己添加功能了
/*
* @Author: HZN
* @Date: 2022-04-18 14:50:28
* @Last Modified by: HZN
* @Last Modified time: 2022-04-18 20:16:13
存在问题历史和热键下午改
*/
Hotkey, IfWinActive, MSearch
Hotkey, ^enter, Search
#NoTrayIcon ;~不显示托盘图标
#Persistent ;~让脚本持久运行
#SingleInstance,Force ;~运行替换旧实例
初始=
(
[搜索引擎]
百度=https://www.baidu.com/s?wd=
谷歌=https://www.google.com/search?q=
知乎=https://www.zhihu.com/search?type=content&q=
词典=https://dict.cn/search?q=
淘宝=https://s.taobao.com/search?q=
京东=https://search.jd.com/Search?keyword=
豆瓣=https://www.douban.com/search?q=
[编程搜索]
mdn=https://developer.mozilla.org/en-US/search?q=
Git=https://github.com/search?utf8=`%E2`%9C`%93&q=
ahk中文论坛=https://www.autoahk.com/?s=
微软=https://docs.microsoft.com/zh-cn/search/?terms=
[自定义]
大妈=https://search.smzdm.com/?c=home&s=
高德=https://ditu.amap.com/search?query=
[搜索语法]
标题=intitle
内容=intext
链接锚点=inanchor:login
网站=site
url=inurl
链接特定url=link:www.baidu.com
特定类型文件=filetype
关联=related
信息=info
搜索语法=搜索语法
[站内搜索]
政府=site:gov.cn
stackoverflow=site:stackoverflow.com
站内搜索=站内搜索
[编程语言]
js=js
python=python
c=c
ahk=ahk
编程语言=编程语言
[历史]
)
IfNotExist,MSearch.ini
{
MSearch:= class_EasyIni("MSearch.ini",初始)
MSearch.save()
}
MSearch:= class_EasyIni("MSearch.ini")
for sec,kv in MSearch
分类.= sec "|"
#s::
MSearch:
Clipboard:=""
Send,^c
gui,Destroy
Gui Add, Text, w-2 h-2 section
; Gui Add, Text, y+5 section,
gosub 读取菜单
gui, font, s15, Verdana
Gui Add, Edit ,y+5 xs-4 w1000 h100 Hwndhedit vKeywords,%Clipboard%
Gui Add,Button, xs-4 gSearch,Search
Gui Add,Button, x+5 g增加新内容,增加新内容
Gui add, DropDownList,x+5 w120 vnewsec,% 分类
Gui Show, ,MSearch
return
Search:
Gui submit, NoHide
Keywords:=RegExReplace(Keywords,"\r\n|\r|\n")
For sec,kv in MSearch{
For k,v in kv {
If %k% = 1
run , % kv[k] . RegExReplace(Keywords,"%","%25")
}
}
MSearch["历史"][Keywords]:=Keywords
MSearch.save()
return
读取菜单:
for sec,kv in MSearch{
switch sec
{
case "搜索引擎":
Gui Add, Text,,%sec%
for k, v in MSearch["搜索引擎"]
Gui Add, CheckBox, % ((k ~= "谷歌") ? "Checked" : "") . " x+5 v" k,%k%
case "编程搜索":
Gosub 创建勾选框
case "自定义":
Gosub 创建勾选框
Default:
for k,v in kv
搜索.= k "|"
bhh := (sec="搜索语法") ? "xs y+5" : "x+5 "
Gui add, DropDownList, %bhh% w120 v%sec% gAEdit, % 搜索 sec "||"
}
搜索:= ""
}
Return
创建勾选框:
Gui Add, Text,y+5 xs,%sec%
for k,v in kv
Gui Add, CheckBox, x+5 v%k%,%k%
Return
AEdit(CtrlHwnd, GuiEvent, EventInfo, ErrLevel:=""){
Global MSearch,hEdit
GuiControlGet, var, FocusV
GuiControlGet, val, , % CtrlHwnd
AppendEdit(hedit, MSearch[var][val])
}
AppendEdit(hEdit, text)
{
text .= A_Space
SendMessage, 0xB1, -2, -1,, ahk_id %hEdit% ; EM_SETSEL
SendMessage, 0xC2, 0, &text,, ahk_id %hEdit% ; EM_REPLACESEL
SendMessage, 0x115, 7, 0,, ahk_id %hEdit% ; WM_VSCROLL
}
增加新内容:
gui,Submit,NoHide
Keywords:=RegExReplace(Keywords,"\r\n|\r|\n")
if (RegExMatch(Keywords,"(.+)(=)(.+)",SubPat) and newsec!="")
{
MSearch[newsec][SubPat1]:=SubPat3
MsgBox,添加成功
}
Else
Msgbox An unexpected error occurred.
MSearch.Save()
Return
不错