此脚本为单机绿色小软件,着重突出自定义日期提醒规则,方便与客户高效的进行联系和记录。
注意事项:
1、此脚本所内置的sqlite3.dll为Navicat11自带版本,部分函数其他版本dll没有,请注意不要搞混(编译exe不用考虑此项)。
2、姓名和产品型号可以快速输入,只要你输入部分字词,会自动检索相关项目并添加到下拉框中。
3、16项字段里面有3个日期规则,销售日期匹配提醒规则模板的内容,专属提醒则为指定一次性日期,生日每年当天提醒。
4、标记有6种状态,在刷选的时候注意按提示输入数字而不是汉字。
5、导出的列表为csv格式,如果日期格式有问题可以改后缀为.txt再用Excel手动打开,类型选择”文本“。
#NoEnv #SingleInstance froce #Include SQLiteDB.ahk OnExit, ExitScript ;DIY项目 ;主标题 maintitle = 售后定时客户关怀提醒 ;预置文件 FileCreateDir, % A_ScriptDir "\ico\" FileInstall, 1.ico, % A_ScriptDir "\ico\1.ico" FileInstall, 2.ico, % A_ScriptDir "\ico\2.ico" FileInstall, 3.ico, % A_ScriptDir "\ico\3.ico" FileInstall, 4.ico, % A_ScriptDir "\ico\4.ico" FileInstall, 5.ico, % A_ScriptDir "\ico\5.ico" FileInstall, 6.ico, % A_ScriptDir "\ico\6.ico" FileInstall, sqlite3.dll, sqlite3.dll ;初始化连接数据库 以便反复查询 DBFileName := A_ScriptDir . "\after_sales_noti.db" DB := new SQLiteDB if !DB.OpenDB(DBFileName) { MsgBox, 16, SQLite错误, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode ExitApp } ;首先检查初始化 if !IsObject(Query("select 1 from sqlite_master where name='noti'")) ;检查提醒模板表 Exec("CREATE TABLE ""noti"" ( ""noti_level"" TEXT(50), ""noti_rules"" TEXT(255), ""id"" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, CONSTRAINT ""noti_level"" UNIQUE (""noti_level"") ON CONFLICT REPLACE )") if !IsObject(Query("select 1 from sqlite_master where name='detail'")) ;检查提醒清单表 Exec("CREATE TABLE ""detail"" (""name"" TEXT(50),""phone"" TEXT(15),""cell"" TEXT(15),""birthday"" TEXT(50),""product_model"" TEXT(255),""product_info"" TEXT(255),""sale_date"" TEXT(20),""qq"" TEXT(50),""mail"" TEXT(100),""address"" TEXT(255),""note"" TEXT(255),""noti_level"" TEXT(50),""timer"" TEXT(50),""state"" INTEGER,""create_date"" TEXT(50),""id"" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)") if !IsObject(Query("select 1 from sqlite_master where name='setting'")) ;检查设置表 Exec("CREATE TABLE ""setting"" (""name"" TEXT(50),""value"" TEXT(255),""id"" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL)") if !IsObject(Query("select 1 from setting")) ;如果没有设置项 Exec("Insert INTO setting (""name"", ""value"") select 'last_login',date('" thisday "');Insert INTO setting (""name"", ""value"") select 'viewed',0;") if !IsObject(Query("select 1 from noti")) ;如果没有提醒模板 Exec("Insert INTO noti (""noti_level"", ""noti_rules"") VALUES ('普通用户', '+7|+15');Insert INTO noti (""noti_level"", ""noti_rules"") VALUES ('VIP', '+3|+7|+15');") ;刷选预设 search_options := {"姓名":{"real":"name","method":"等于|包含"} ,"电话":{"real":"phone","method":"等于|包含"} ,"手机":{"real":"cell","method":"等于|包含"} ,"生日":{"real":"date(birthday)","method":"等于|介于|不等于|包含|大于|小于","example1":"1949-10-01","example2":"1959-10-01"} ,"产品型号":{"real":"product_model","method":"等于|包含"} ,"产品信息":{"real":"product_info","method":"等于|包含"} ,"QQ":{"real":"qq","method":"等于|介于|包含|大于|小于"} ,"邮箱":{"real":"mail","method":"等于|包含"} ,"地址":{"real":"address","method":"等于|包含"} ,"备注":{"real":"note","method":"等于|包含"} ,"提醒规则模板":{"real":"noti_level","method":"等于|包含"} ,"专属提醒时间":{"real":"date(timer)","method":"等于|介于|大于|小于","example1":"1949-10-01","example2":"1959-10-01"} ,"标记状态":{"real":"state","method":"等于|不等于","example1":"1"} ,"创建时间":{"real":"date(create_date)","method":"等于|介于|不等于|包含|大于|小于","example1":"1949-10-01","example2":"1959-10-01"}} ;创建托盘菜单 menu, Tray, NoStandard Menu, tray, Add, 主界面 Menu, tray, Add, 提醒规则管理 Menu, tray, Add, 开机启动 Menu, tray, Add, 退出 Menu, tray, Default, 主界面 ;图标列表 ImageListID := IL_Create(6) Loop 6 IL_Add(ImageListID, A_ScriptDir "\ico\" A_Index ".ico") gosub, 主界面 return 主界面: ;提醒模板 noti := Query("select * from noti") noti_para = for k,v in noti noti_para .= noti_para ? "|" v[1] : v[1] If main_gui_showed { Gui, main:show ControlGet, l, List, Count, ComboBox3, % maintitle Loop % (StrSplit(l,"`n")).MaxIndex() Control, Delete, 1, ComboBox3, % maintitle GuiControl, main:, noti_level, % noti_para } else { Gui, main:Add, Text, x0 y0 w60 h20, 姓 名 Gui, main:Add, ComboBox, x40 y0 w170 vname gname Gui, main:Add, Text, x0 y20 w60 h20, 电 话 Gui, main:Add, Edit, x40 y20 w170 h20 -Multi vphone Gui, main:Add, Text, x0 y40 w60 h20, 手 机 Gui, main:Add, Edit, x40 y40 w170 h20 -Multi vcell Gui, main:Add, Text, x0 y60 w60 h20, Q Q Gui, main:Add, Edit, x40 y60 w170 h20 -Multi vqq Gui, main:Add, Text, x0 y80 w60 h20, 邮 箱 Gui, main:Add, Edit, x40 y80 w170 h20 -Multi vmail Gui, main:Add, Text, x0 y120 w60 h20, 地 址 Gui, main:Add, Edit, x40 y100 w170 h60 vaddress Gui, main:Add, Text, x210 y0 w60, 产品型号 Gui, main:Add, ComboBox, x260 y0 w170 h20 vproduct_model gproduct_model Gui, main:Add, Text, x210 y20 w60 h20, 产品信息 Gui, main:Add, Edit, x260 y20 w170 h40 vproduct_info Gui, main:Add, Text, x210 y60 w60 h20, 销售日期 Gui, main:Add, DateTime, x260 y60 w170 h20 vsale_date Gui, main:Add, Text, x210 y80 w60 h20, 专属提醒 Gui, main:Add, DateTime, x260 y80 w170 h20 vtimer Gui, main:Add, Text, x210 y100 w60 h20, 用户生日 Gui, main:Add, DateTime, x260 y100 w170 h20 vbirthday Gui, main:Add, Text, x210 y120 w60 h20, 备 注 Gui, main:Add, Edit, x260 y120 w170 h40 vnote Gui, main:Add, GroupBox, x440 y0 w200 h120, 标记状态 Gui, main:Add, Radio, x450 y26 w60 h20 gr1 vr1, 1初始化 Gui, main:Add, Picture, x510 y20 w32 h32 gp1, %A_ScriptDir%\ico\1.ico Gui, main:Add, Radio, x542 y26 w60 h20 gr2 vr2, 2再联系 Gui, main:Add, Picture, x602 y20 w32 h32 gp2, %A_ScriptDir%\ico\2.ico Gui, main:Add, Radio, x450 y58 w60 h20 gr3 vr3, 3已完成 Gui, main:Add, Picture, x510 y52 w32 h32 gp3, %A_ScriptDir%\ico\3.ico Gui, main:Add, Radio, x542 y58 w60 h20 gr4 vr4, 4失败 Gui, main:Add, Picture, x602 y52 w32 h32 gp4, %A_ScriptDir%\ico\4.ico Gui, main:Add, Radio, x450 y90 w60 h20 gr5 vr5, 5黑名单 Gui, main:Add, Picture, x510 y84 w32 h32 gp5, %A_ScriptDir%\ico\5.ico Gui, main:Add, Radio, x542 y90 w60 h20 gr6 vr6, 6要上心 Gui, main:Add, Picture, x602 y84 w32 h32 gp6, %A_ScriptDir%\ico\6.ico Gui, main:Add, Text, x440 y120 w200 h20, 客户提醒规则模板 Gui, main:Add, DDL, x440 y140 w200 R20 vnoti_level, % noti_para Gui, main:Add, Button, x0 y170 w100 h20 gnew, 新建资料 Gui, main:Add, Button, x108 y170 w100 h20 gsave vsave, 保存资料 Gui, main:Add, Button, x216 y170 w100 h20 gdelete, 删除资料 Gui, main:Add, Button, x324 y170 w100 h20 gexport, 导出下方列表 Gui, main:Add, DateTime, x432 y170 w110 h20 vsearch_date, Gui, main:Add, Button, x542 y170 w100 h20 gview_thisday, 查看此日提醒 Gui, main:Add, Text, x20 y203 w100 h20, 查询销售日期从 Gui, main:Add, DateTime, x120 y200 w200 h20 vsearch_startdate, Gui, main:Add, Text, x320 y203 w20 h20, 到 Gui, main:Add, DateTime, x340 y200 w200 h20 vsearch_enddate, Gui, main:Add, Text, x540 y203 w90 h20, 的清单数据 Gui, main:Add, Text, x20 y223 w30 h20, 筛选 Gui, main:Add, DropDownList, x50 y220 w150 h20 R20 vsearch_key gsearch_key, 无|姓名|电话|手机|生日|产品型号|产品信息|QQ|邮箱|地址|备注|提醒规则模板|专属提醒时间|标记状态|创建时间 Gui, main:Add, DropDownList, x200 y220 w50 h20 R10 vsearch_method gsearch_method, 等于|介于|不等于|包含|大于|小于 Gui, main:Add, Edit, x250 y220 w150 h20 -Multi vsearch_value1, Gui, main:Add, Edit, x400 y220 w150 h20 -Multi vsearch_value2, Gui, main:Add, Button, x550 y220 w80 h20 gsearch, 查询 Gui, main:Add, ListView, x0 y240 w640 h200 vmylv gmylv, 姓名|电话|手机|生日|产品型号|产品信息|销售日期|QQ|邮箱|地址|备注|提醒规则模板|专属提醒时间|标记状态|创建时间|ID Gui, main:Add, StatusBar, x0 y440 w640 h20, Gui, main:Show, , % maintitle Gui, main:Default LV_SetImageList(ImageListID) ;OnMessage(0x201, "WM_LButtonDOWN") GuiControl, main:, r1, 1 GuiControl, main:, timer, 19000101 GuiControl, main:, birthday, 19000101 main_gui_showed = 1 } gosub, view_thisday return ;姓名快速提示 name: GuiControlGet, name result := append2obj(Query("select name from detail where name like '" name "%' group by name"),Query("select name from detail where name like '%" name "%' and name not like '" name "%' group by name")) if IsObject(result) { name_para = ControlGet, l, List, Count, ComboBox1, % maintitle Loop % (StrSplit(l,"`n")).MaxIndex() Control, Delete, 1, ComboBox1, % maintitle for k,v in result name_para .= name_para ? "|" v[1] : v[1] GuiControl, main:, name, % name_para SB_SetText("下拉【姓名】可点击待选快速输入!") } return ;产品型号快速提示 product_model: GuiControlGet, product_model result := append2obj(Query("select product_model from detail where product_model like '" product_model "%' group by product_model"),Query("select product_model from detail where product_model like '%" product_model "%' and product_model not like '" product_model "%' group by product_model")) if IsObject(result) { product_model_para = ControlGet, l, List, Count, ComboBox2, % maintitle Loop % (StrSplit(l,"`n")).MaxIndex() Control, Delete, 1, ComboBox2, % maintitle for k,v in result product_model_para .= product_model_para ? "|" v[1] : v[1] GuiControl, main:, product_model, % product_model_para SB_SetText("下拉【产品型号】点击待选可快速输入!") } return ;新建 new: SB_SetText("新建") change= GuiControl, main:, save, 保存资料 for k,v in ["phone","cell","qq","mail","address","product_info","note"] GuiControl, main:, % v, for k,v in ["name","product_model","noti_level"] GuiControl, main:Choose, % v, 0 GuiControl, main:, sale_date, % A_Now GuiControl, main:, timer, 19000101 GuiControl, main:, birthday, 19000101 GuiControl, main:, r1, 1 gosub, r1 return ;保存 save: Gui, main:Submit, NoHide if (!noti_level) { MsgBox, 4112, 错误, 您未选择客户提醒规则模板,请核对! return } if (!name && !phone && !cell) { MsgBox, 4112, 错误, 您未填写用户姓名或电话,请至少填一项有效信息! return } Loop, 6 { if (r%A_Index%=1) { state := A_index break } } FormatTime, sale_date, % sale_date, yyyy-MM-dd HH:mm:ss FormatTime, timer, % timer, yyyy-MM-dd HH:mm:ss FormatTime, birthday, % birthday, yyyy-MM-dd HH:mm:ss address := RegExReplace(RegExReplace(address,"`r","\r"),"`n","\n") note := RegExReplace(RegExReplace(note,"`r","\r"),"`n","\n") if !change result := Exec("Insert into detail ('name','phone','cell','qq','mail','address','product_model','product_info','sale_date','timer','birthday','note','noti_level','state','create_date') select '" name "','" phone "','" cell "','" qq "','" mail "','" address "','" product_model "','" product_info "','" sale_date "','" timer "','" birthday "','" note "','" noti_level "'," state ",date('" thisday "')") else result := Exec("update detail set name='" name "',phone='" phone "',cell='" cell "',qq='" qq "',mail='" mail "',address='" address "',product_model='" product_model "',product_info='" product_info "',sale_date='" sale_date "',timer='" timer "',birthday='" birthday "',note='" note "',noti_level='" noti_level "',state=" state " where id=" change_id) if result { SB_SetText("已保存!") if issearch gosub, refresh else gosub, view_thisday gosub, new } return ;查询 search: issearch = 1 Gui, main:Submit, NoHide FormatTime, search_startdate, % search_startdate, yyyy-MM-dd FormatTime, search_enddate, % search_enddate, yyyy-MM-dd SQL = select * from detail condition := {} conditions = condition.Insert("date(sale_date) between '" search_startdate "' and '" search_enddate "'") if (search_key && search_method) { if search_method = 等于 condition.Insert(search_options[search_key]["real"] "='" search_value1 "'") else if search_method = 介于 condition.Insert(search_options[search_key]["real"] " between '" search_value1 "' and '" search_value2 "'") else if search_method = 不等于 condition.Insert(search_options[search_key]["real"] "<>'" search_value1 "'") else if search_method = 包含 condition.Insert(search_options[search_key]["real"] " like '%" search_value1 "%'") else if search_method = 大于 condition.Insert(search_options[search_key]["real"] ">'" search_value1 "'") else if search_method = 小于 condition.Insert(search_options[search_key]["real"] "<'" search_value1 "'") } for k,v in condition conditions .= conditions ? " and " v : " where " v gosub, refresh return ;查看指定日期按规则生成的提醒 view_thisday: GuiControlGet, search_date if search_date FormatTime, thisday, % search_date, yyyy-MM-dd if !thisday FormatTime, thisday, % A_Now, yyyy-MM-dd lv_result= issearch= ;获取提醒规则模板 levels := Query("select noti_level,noti_rules from noti") ;枚举循环规则 for i,r in levels { level := r[1],rule_c:=r[2] rules := StrSplit(rule_c,"|") for i,rule in rules { if RegExMatch(rule,"\+(\d{1,5})$",m) ;+xx天 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE julianday(date('" thisday "'))-julianday(date(sale_date))=" m1 " and noti_level='" level "'")) if RegExMatch(rule,"E(\d{1,5})$",m) ;每隔xx天 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE (Floor(julianday(date('" thisday "'))-julianday(sale_date))-Floor(Floor(julianday(date('" thisday "'))-julianday(sale_date))/" m1 ")*" m1 ")<1 AND julianday(date('" thisday "'))-julianday(date(sale_date))>=1 and noti_level='" level "'")) if RegExMatch(rule,"EW$",m) ;按周重复 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE strftime('%w',sale_date)=strftime('%w',date('" thisday "')) AND julianday(date('" thisday "'))-julianday(date(sale_date))>=1 and noti_level='" level "'")) if RegExMatch(rule,"EM$",m) ;按月重复 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE strftime('%d',sale_date)=strftime('%d',date('" thisday "')) AND julianday(date('" thisday "'))-julianday(date(sale_date))>=1 and noti_level='" level "'")) if RegExMatch(rule,"EY$",m) ;按年重复 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE strftime('%m-%d',sale_date)=strftime('%m-%d',date('" thisday "')) AND julianday(date('" thisday "'))-julianday(date(sale_date))>=1 and noti_level='" level "'")) if RegExMatch(rule,"EW(\d{1})$",m) ;每周X { if (A_WDay=(m1+1>7 ? 1 : a+m1)) lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE noti_level='" level "'")) } if RegExMatch(rule,"EM(\d{1,2})$",m) ;每月XX { if (A_DD=m1) lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE noti_level='" level "'")) } if RegExMatch(rule,"EM(\d{1,2})$",m) ;每月XX { if (A_DD=m1) lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE noti_level='" level "'")) } } } ;定时提醒 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE date(timer)='" A_YYYY "-" A_MM "-" A_DD "'")) ;生日提醒 lv_result := append2obj(lv_result,Query("SELECT * FROM detail WHERE strftime('%m-%d',birthday)='" A_MM "-" A_DD "' AND date(birthday)<>'1900-01-01'")) gosub, refresh return ;筛选方式 search_method: GuiControlGet, search_method if search_method { if search_method in 等于,不等于,包含,大于,小于 { GuiControl, main:Enable, search_value1 GuiControl, main:Disable, search_value2 } else if search_method = 介于 { GuiControl, main:Enable, search_value1 GuiControl, main:Enable, search_value2 } } else { GuiControl, main:Disable, search_value1 GuiControl, main:Disable, search_value2 } return ;筛选项 search_key: GuiControlGet, search_key if (search_key<>"无" && search_key) GuiControl, main:Enable, search_method else GuiControl, main:Disable, search_method GuiControl, main:Disable, search_value1 GuiControl, main:Disable, search_value2 ;search_options ControlGet, l, List, Count, ComboBox5, % maintitle Loop % (StrSplit(l,"`n")).MaxIndex() Control, Delete, 1, ComboBox5, % maintitle GuiControl, main:, search_method, % search_options[search_key]["method"] GuiControl, main:, search_value1, % search_options[search_key]["example1"] GuiControl, main:, search_value2, % search_options[search_key]["example2"] return ;列表 mylv: show_detail: change := 1 GuiControl, main:, save, 保存修改 FocusedRowNumber := LV_GetNext(0, "F") if not FocusedRowNumber return SB_SetText("显示列表中第" FocusedRowNumber "行详细信息,可修改保存") Loop 16 { LV_GetText(var%A_Index%, FocusedRowNumber,A_Index) } change_id := var16 for k,v in {"phone":var2,"cell":var3,"product_info":var6,"qq":var8,"mail":var9} GuiControl, main:, % k, % v for k,v in {"address":var10,"note":var11} GuiControl, main:, % k, % RegExReplace(RegExReplace(v,"\\n","`n"),"\\r","`r") for k,v in {"Edit1":var1,"Edit7":var5} ControlSetText, % k, % v, % maintitle for k,v in noti { if (var12=v[1]) { GuiControl, main:Choose, noti_level, % k break } } for k,v in {"birthday":var4,"sale_date":var7,"timer":var13} GuiControl, main:, % k, % RegExReplace(RegExReplace(RegExReplace(v,"\s",""),"-",""),":","") gosub, % "r" var14 return delete: FocusedRowNumber := LV_GetNext(0, "F") if not FocusedRowNumber return LV_GetText(Delete_id, FocusedRowNumber,16) result := Exec("Delete from detail where id=" Delete_id) if result { MsgBox, 64, 提示, 已删除选中项! gosub, refresh } return ;刷新 refresh: LV_Delete() if issearch lv_result := Query(SQL conditions) if (IsObject(lv_result) && ObjKeyCount(lv_result)) { for k,v in lv_result { LV_Add("Icon" . v[14],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],v[10],v[11],v[12],v[13],v[14],v[15],v[16]) } LV_ModifyCol() SB_SetText(k "项结果,双击指定行查看、修改") } else SB_SetText("无结果") return ;导出 export: FileSelectFile, file, S, , 请选择保存位置, CSV文件(*.csv) if file { content = `"姓名`",`"电话`",`"手机`",`"生日`",`"产品型号`",`"产品信息`",`"销售日期`",`"QQ`",`"邮箱`",`"地址`",`"备注`",`"提醒规则模板`",`"专属提醒时间`",`"标记状态`",`"创建时间`",`"ID`" for k,v in lv_result { line = for x,y in v { line .= line ? ",""" y """" : """" y """" } content .= "`n" line } file := InStr(file,".csv") ? file : file ".csv" FileDelete, % file FileAppend, % content, % file Run, % file } return 提醒规则管理: for k,v in Query("select * from noti") notis .= notis ? "|" v[1] : v[1] Gui, noti:Destroy Gui, noti:Add, Text, x0 y0 w400 h20, 规则模板名称: Gui, noti:Add, ComboBox, x0 y20 w400 R20 vnotilevelname gnotilevelname, % notis Gui, noti:Add, Text, x0 y40 w400 h20, 规则 Gui, noti:Add, Edit, x0 y60 w400 h20 -Multi vnotilevelvalue, Gui, noti:Add, Button, x0 y80 w130 h20 gnotisubmit, 提交 Gui, noti:Add, Button, x135 y80 w130 h20 gnotidelete, 删除 Gui, noti:Add, Button, x270 y80 w130 h20 gnotihelp, 帮助 Gui, noti:Show, , 提醒规则管理 Gui, noti:+AlwaysOnTop return notilevelname: GuiControlGet, notilevelname if IsObject(t := Query("select noti_rules from noti where noti_level='" notilevelname "'")) GuiControl, noti:, notilevelvalue, % t[1][1] return notisubmit: Gui, noti:Submit, NoHide if (Exec("Replace INTO noti (""noti_level"", ""noti_rules"") VALUES ('" notilevelname "', '" notilevelvalue "')")) MsgBox, 4160, 提示, 添加/修改成功! return notidelete: Gui, noti:Submit, NoHide if (Exec("Delete from noti where noti_level='" notilevelname "'")) MsgBox, 4160, 提示, 删除成功! return notihelp: MsgBox, 64, 规则帮助, 规则(n代表数值):`n+nn 延后nn天`nEnn 每隔nn天`nEW 每周`nEWn 每周星期n`nEM 每月`nEMnn 每月nn日`nEY 每年`n多项以“|”分隔`n参照日期以销售日期为准。 return 开机启动: RegRead, var, HKCU, Software\Microsoft\Windows\CurrentVersion\Run, after_sales_noti last := A_LastError if last=2 { RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows\CurrentVersion\Run, after_sales_noti, %A_ScriptFullPath% if Errorlevel MsgBox, 16, 错误, 没有权限或者被安全软件拦截了,请下次再试! else Menu, Tray, Check, 开机启动 } if last=0 { RegDelete, HKCU, Software\Microsoft\Windows\CurrentVersion\Run, after_sales_noti if Errorlevel MsgBox, 16, 错误, 没有权限或者被安全软件拦截了,请下次再试! else Menu, Tray, UnCheck, 开机启动 } return GuiClose: Gui, main:Hide return notiGuiClose: Gui, noti:Destroy return 退出: viewGuiClose: ExitScript: DB.Close ExitApp r1: p1: r2: p2: r3: p3: r4: p4: r5: p5: r6: p6: lst := [1,2,3,4,5,6] Loop % lst.MaxIndex() { if (RegExReplace(A_ThisLabel,"^\w(\d)$","$1")=A_Index) GuiControl, main:, % "r" A_Index, 1 else GuiControl, main:, % "r" lst[A_Index], 0 } return ;WM_LButtonDOWN(wParam, lParam) ;{ ; ControlGetFocus, Focus, % maintitle ; if Focus = SysListView321 ; { ; change := 1 ; gosub, show_detail ; } ;} ;合并结果 append2obj(mainobj,obj){ if !IsObject(mainobj) mainobj := Object() id := [] for a,b in mainobj id[b[16]]:=1 for k,v in obj { if !id[v[16]] mainobj.Insert(v) } return mainobj } ;获取数组项目数 ObjKeyCount(obj){ for k in obj i++ return i } ;构造查询SQL函数 Query(SQL){ ;返回数组 global DB ;全局 if !DB.GetTable(SQL, Result) MsgBox, 16, SQLite错误: 获取结果, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode if (Result.HasRows) { return Result.Rows } } ;构造执行SQL函数 Exec(SQL){ ;返回执行影响行数 global DB ;全局 if !DB.Exec(SQL) MsgBox, 16, SQLite错误: 获取结果, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode return DB._Changes() }
;定时备份 old_hour = %A_Hour% ;源路径 source = D:\1 ;目标路径 dest = E:\1 Loop { new_hour = %A_Hour% ;定义新旧小时 if new_hour <> %old_hour% ;如果不等 { RunWait,%ComSpec% /c dir `"%source%`" /A-D /b /s >files.tmp,,Hide ;CMD dir命令获取文件列表 RunWait,%ComSpec% /c dir `"%source%`" /AD /b /s >folders.tmp,,Hide ;CMD dir命令获取文件夹列表 Loop ;创建不存在的文件夹 { FileReadLine,tmpfolder,folders.tmp,%A_Index% If ErrorLevel Break if tmpfolder <> { StringReplace,tmpdestfolder,tmpfolder,%source%,%dest% ;替换路径 FileCreateDir,%tmpdestfolder% ;创建文件夹 } } Loop ;复制不存在的或更新的文件 { FileReadLine,tmpfile,files.tmp,%A_Index% If ErrorLevel Break if tmpfile <> { StringReplace,tmpdestfile,tmpfile,%source%,%dest% ;替换路径 IfNotExist,%tmpdestfile% ;不存在 FileCopy,%tmpfile%,%tmpdestfile%,1 Else { FileGetTime,sourcetime,%tmpfile% ;获取源文件修改时间 FileGetTime,desttime,%tmpdestfile% ;获取目标文件修改时间 if sourcetime > %desttime% ;如果源文件更新 FileCopy,%tmpfile%,%tmpdestfile%,1 } } } } Sleep,60000 ;等待1分钟 }
49 queries in 1.452 seconds |