#MaxMem 1024 #NoTrayIcon #SingleInstance, force gui, add, button, x0 y0 w300 h42 gget, 复制Excel表格数据后点此分析生成 gui, show, , 维汉语筛选区分工具 Return get: ;转化为数组 ;初始化 ExcelObj := {} ;获取 Clip_now := Clipboard ;转化成数组 if (InStr(Clip_now, "`t")) { StringReplace, Clip_now, Clip_now, `r, , All StringSplit, line, Clip_now, `n Loop % line0 { tmp_line := line%A_Index% y_id := A_Index if tmp_line { StringSplit, var, tmp_line, `t Loop % var0 { tmp_var := var%A_Index% x_id := A_index ExcelObj[y_id,x_id] := tmp_var } } } } InputBox, title, 提示, 请输入一个名称! if title = title = 未命名 if !isobject(ExcelObj) { MsgBox, 48, 错误, 您未粘贴EXCEL数据! Return } ;横向纵向最列数 后面不会用到 x_max := ExcelObj[1].Maxindex() y_max := ExcelObj.Maxindex() outf = id=0 ;生成选择的下拉菜单 for k,v in ExcelObj[1] { id++ outf .= outf ? "|" id "【" v "】" : id "【" v "】" } gui, 2:add, DropDownList, x0 y0 w300 h400 vchoose, %outf% gui, 2:add, button, x0 y20 w300 h20 gok, 确定 gui, 2:show, ,请选择姓名所在字段! Return ok: GuiControlGet, choose if choose = { MsgBox, 48, 错误, 您为选择姓名所在字段! Return } SplashTextOn, 200, 20, 提示, 分析生成中! gui, 2:Destroy ;分割所选 StringSplit, v, choose, 【, ;姓名所在列id ziduan = %v1% goto, goon Return goon: hanyu_data = uyghur_data = idx = 0 ; for k,v in ExcelObj { idx++ key := ExcelObj[idx][ziduan] StringReplace, key, key, %A_Space%, , All key := RegExReplace(key,"(\.|。|·)$","") ;汉字姓氏开头 if RegExMatch(key,"^(赵|钱|孙|李|周|吴|郑|王|冯|陈|褚|卫|蒋|沈|韩|杨|朱|秦|尤|许|何|吕|施|张|孔|曹|严|华|金|魏|陶|姜|戚|谢|邹|喻|柏|水|窦|章|云|苏|潘|葛|奚|范|彭|郎|鲁|韦|昌|马|苗|凤|花|方|俞|任|袁|柳|酆|鲍|史|唐|费|廉|岑|薛|雷|贺|倪|汤|滕|殷|罗|毕|郝|邬|安|常|乐|于|时|傅|皮|卞|齐|康|伍|余|元|卜|顾|孟|平|黄|和|穆|萧|尹|姚|邵|湛|汪|祁|毛|禹|狄|米|贝|明|臧|计|伏|成|戴|谈|宋|茅|庞|熊|纪|舒|屈|项|祝|董|梁|杜|阮|蓝|闵|席|季|麻|强|贾|路|娄|危|江|童|颜|郭|梅|盛|林|刁|钟|徐|邱|骆|高|夏|蔡|田|樊|胡|凌|霍|虞|万|支|柯|咎|管|卢|莫|经|房|裘|缪|干|解|应|宗|宣|丁|贲|邓|郁|单|杭|洪|包|诸|左|石|崔|吉|钮|龚|程|嵇|邢|滑|裴|陆|荣|翁|荀|羊|於|惠|甄|魏|加|封|芮|羿|储|靳|汲|邴|糜|松|井|段|富|巫|乌|焦|巴|弓|牧|隗|山|谷|车|侯|宓|蓬|全|郗|班|仰|秋|仲|伊|宫|宁|仇|栾|暴|甘|钭|厉|戎|祖|武|符|刘|姜|詹|束|龙|叶|幸|司|韶|郜|黎|蓟|薄|印|宿|白|怀|蒲|台|从|鄂|索|咸|籍|赖|卓|蔺|屠|蒙|池|乔|阴|郁|胥|能|苍|双|闻|莘|党|翟|谭|贡|劳|逄|姬|申|扶|堵|冉|宰|郦|雍|却|璩|桑|桂|濮|牛|寿|通|边|扈|燕|冀|郏|浦|尚|农|温|别|庄|晏|柴|瞿|阎|充|慕|连|茹|习|宦|艾|鱼|容|向|古|易|慎|戈|廖|庚|终|暨|居|衡|步|都|耿|满|弘|匡|国|文|寇|广|禄|阙|东|殴|殳|沃|利|蔚|越|夔|隆|师|巩|厍|聂|晁|勾|敖|融|冷|訾|辛|阚|那|简|饶|空|曾|毋|沙|乜|养|鞠|须|丰|巢|关|蒯|相|查|后|江|红|游|竺|权|逯|盖|益|桓|公|万|俟|司马|上官|欧阳|夏侯|诸葛|闻人|东方|赫连|皇甫|尉迟|公羊|澹台|公冶|宗政|濮阳|淳于|仲孙|太叔|申屠|公孙|乐正|轩辕|令狐|钟离|闾丘|长孙|慕容|鲜于|宇文|司徒|司空|亓官|司寇|仉督|子车|颛孙|端木|巫马|公西|漆雕|乐正|壤驷|公良|拓拔|夹谷|宰父|谷粱|晋楚|阎法|汝鄢|涂钦|段干|百里|东郭|南门|呼延|归海|羊舌|微生|岳帅|缑亢|况后|有琴|梁丘|左丘|东门|西门|商牟|佘佴|伯赏|南宫|墨哈|谯笪|年爱|阳佟|第五|言福).*") { tmp_line = for a,b in ExcelObj[idx] tmp_line .= tmp_line ? "," b : b hanyu_data .= hanyu_data ? "`n" tmp_line : tmp_line } ;维语名字关键词 Else if key Contains 阿巴,阿卜,阿不,阿布,阿达,阿迪,阿地,阿尔,阿洪,阿吉,阿勒,阿里,阿力,阿丽,阿曼,阿米,阿娜,阿西,阿依,阿克,努尔,阿依,曼孜,沙吾,喀拉,阿拜,别克,迈尔,迈尔,扎提,艾伟,帕,霍尔,艾伟,阿依,夏姆,阿依,乌力,夏木,阿依,谢姆,阿扎,提,艾尔,艾海,提,艾合,艾科,拜尔,艾克,巴尔,艾拉,艾勒,坎木,艾里,艾力,凯木,艾尼,瓦尔,艾萨,艾散,艾沙,艾山,艾依,艾则,孜,艾孜,安拉,安外,奥斯,巴哈,巴克,巴拉,巴图,巴土,巴依,拜合,亚尔,包尔,布里,布力,布威,布韦,布维,达尼,达瓦,达伍,托科,达吾,迪里,迪丽,热巴,迪亚,额敏,古海,古丽,罕,娜尔,斯坦,苏如,苏茹,扎尔,扎热,古再,古赞,果海,哈迪,哈尔,哈古,哈基,哈克,哈里,哈丽,哈力,哈米,哈热,哈斯,哈孜,海力,且木,海丽,且姆,罕,扎代,赫克,买提,赫克木,赫木热,吉利力,吉乃,斯太,加马力,贾马力,杰力力,居尔,艾提,居玛,居麦,居热,喀迪,喀日,喀斯,喀伍,卡,佧马力,佧米力,开萨尔,凯赛尔,坎吉,坎曼尔,柯日木,柯则,柯孜,克热木,克孜,库尔班,阔其,喀尔,玛斯,买买提,麦尔,麦合,麦吉,麦丽,麦买,买买,买卖,麦麦,麦苏木,毛拉,莫敏,莫明,姆,穆巴,热科,穆巴,热克,穆海,麦提,穆罕,买提,穆合,塔尔,穆坎,妲斯,穆萨,穆台,力甫,穆太,力普,木丽,德尔,穆再,排尔,娜扎,开提,乃比,南比,妮尕尔,妮萨,尼格尔,尼加提,尼鲁,尼露,尼萨,尼莎,尼牙孜,尼亚孜,尼叶蒂,尼扎木,努尔,努斯,热提,则力,帕,孜力,皮达,普拉提,齐曼,奇曼,乔力潘,乔丽番,乔丽潘,冉娜,热合曼,热赫木,热杰普,热介甫,热克甫,热娜,热依罕,热依汉,热扎克,热孜宛,热孜婉,肉索力,肉孜,如苏力,如孜,茹仙,萨阿,代提,萨巴,海提,萨比尔,萨比提,萨迪克,萨拉,买提,萨拉,麦提,萨拉木,萨吾提,萨依提,赛尔旦,赛福鼎,赛娜瓦尔,赛乃姆,赛乃木,赛排尔,赛皮丁,赛依提,色提,瓦力迪,色依提,沙巴海提,沙比尔,沙比提,沙拉买提,沙吾提,沙依提,司的克,斯拉木,苏里唐,苏力坦,苏皮,塔吉古丽,塔里甫,塔力甫,塔力普,塔西布拉克,塔依,坦吾皮克,提拉,提力瓦力迪,铁木尔,图尔,吐,托合提,瓦力斯,瓦热斯,维力,乌齐坤,乌图克,吾,吾守尔,吾吐克,吴尔凯西,西力甫,西热甫,西仁,希林,希仁,夏热拜提,仙拜,鲜拜,肖开特,肖开提,谢力甫,谢木斯,谢热甫,秀库尔,许库尔,雪合,拉提,来提,牙力昆,雅库甫,亚库,亚里坤,亚力坤,尧乐,博斯,尧勒,巴斯,伊巴,代提,伊禅,伊盖,伊里,哈木,依力,伊力,伊马木,伊敏,伊纳耶提,伊排提,伊善,伊斯拉哈提,伊斯拉木,依干拜尔迪,依明,吐尔,尤丽吐孜,玉丽吐孜,玉素甫,玉孜,叶尔,约麦尔,约日耶提,哈斯德尔,再乃甫,再乃普,扎伊提,罗提,布拉,孜,孜巴,孜亚,祖合热,祖姆,祖木,佐合热 { tmp_line = for a,b in ExcelObj[idx] tmp_line .= tmp_line ? "," b : b uyghur_data .= uyghur_data ? "`n" tmp_line : tmp_line } ;中间带点 Else if RegExMatch(key,".*(\.|。|·).*") { tmp_line = for a,b in ExcelObj[idx] tmp_line .= tmp_line ? "," b : b uyghur_data .= uyghur_data ? "`n" tmp_line : tmp_line } Else { { tmp_line = for a,b in ExcelObj[idx] tmp_line .= tmp_line ? "," b : b hanyu_data .= hanyu_data ? "`n" tmp_line : tmp_line } } } FileCreateDir, %A_ScriptDir%\%title%\ FileAppend, %uyghur_data%, %A_ScriptDir%\%title%\%title%_维语_%A_Now%.csv FileAppend, %hanyu_data%, %A_ScriptDir%\%title%\%title%_汉语_%A_Now%.csv SplashTextOff MsgBox, 64, 提示, 已经分析生成完成!将会为您打开所在文件夹! content = run, %A_ScriptDir%\%title%\ Return GuiClose: ExitApp
因工作需要使用Asterisk AMI接口,是套接字连接方式的,用php单线程不好用,所以找了一下资料,改动下成后台静默模式,当然你也可以自己改有界面的。
服务器Server:
;thinkai@2014-11-08 ;Based on http://www.autohotkey.com/board/topic/29650-tcpip-serverclient-chat-script-w-features #singleinstance force OnExit, exit ;创建窗口以接收数据 Gui, add, Edit gui, hide ;ip和端口 Network_Address = 0.0.0.0 Network_Port = 1000 ;准备传入连接 socket := PrepareForIncomingConnection(Network_Address, Network_Port) if socket = -1 ExitApp Process, Exist ;获取窗口句柄 DetectHiddenWindows On ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel) DetectHiddenWindows Off NotificationMsg = 0x5555 ;设置接收消息的函数 OnMessage(NotificationMsg, "ReceiveData") FD_READ = 1 FD_CLOSE = 32 FD_CONNECT = 20 if DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, "UInt", ScriptMainWindowId, "UInt", NotificationMsg, "Int", FD_READ|FD_CONNECT) { MsgBox % "WSAAsyncSelect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") ExitApp } ;循环获取新连入客户端 i=1 Loop { VarSetCapacity(SocketAddress, SizeOfSocketAddress:=16) ;Socket连接 conectioncheck%i% := DllCall("Ws2_32\accept", "UInt", socket, "UInt", &SocketAddress, "Int*", SizeOfSocketAddress) if conectioncheck%i% != -1 { ;该客户端连接对象为conectioncheck%i% 发送数据时需要 ;客户端IP:端口 xxx.xxx.xxx.xxx:xxxx peername := DllCall("Ws2_32\inet_ntoa", "uint", NumGet(SocketAddress,4), "str") . ":" NumGet(SocketAddress,2,"ushort") ;发送欢迎信息 SendData(conectioncheck%i%,"欢迎" peername) i++ } sleep 500 } return ;给所有客户端发消息 sendall: Loop %i% { SendData(conectioncheck%A_Index%,SendText) } SendText= return ;准备传入连接函数 PrepareForIncomingConnection(IPAddress, Port) { VarSetCapacity(wsaData, 32) result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", &wsaData) ; Request Winsock 2.0 (0x0002) if ErrorLevel { MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required. return -1 } if result { MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") return -1 } AF_INET = 2 SOCK_STREAM = 1 IPPROTO_TCP = 6 socket := DllCall("Ws2_32\socket", "Int", AF_INET, "Int", SOCK_STREAM, "Int", IPPROTO_TCP) if socket = -1 { MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") return -1 } SizeOfSocketAddress = 16 VarSetCapacity(SocketAddress, SizeOfSocketAddress) InsertInteger(2, SocketAddress, 0, AF_INET) ; sin_family InsertInteger(DllCall("Ws2_32\htons", "UShort", Port), SocketAddress, 2, 2) ; sin_port InsertInteger(DllCall("Ws2_32\inet_addr", "Str", IPAddress), SocketAddress, 4, 4) ; sin_addr.s_addr if DllCall("Ws2_32\bind", "UInt", socket, "UInt", &SocketAddress, "Int", SizeOfSocketAddress) { MsgBox % "bind() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?" return -1 } if DllCall("Ws2_32\listen", "UInt", socket, "UInt", "SOMAXCONN") { MsgBox % "LISTEN() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?" return -1 } return socket } ;接收消息函数 ReceiveData(wParam, lParam) { Critical global ShowRecieved socket := wParam ReceivedDataSize = 4096 Loop { VarSetCapacity(ReceivedData, ReceivedDataSize, 0) ReceivedDataLength := DllCall("Ws2_32\recv", "UInt", socket, "Str", ReceivedData, "Int", ReceivedDataSize, "Int", 0) if ReceivedDataLength = -1 { WinsockError := DllCall("Ws2_32\WSAGetLastError") if WinsockError = 10035 return 1 if WinsockError <> 10054 MsgBox % "recv() indicated Winsock error " . WinsockError ExitApp } ;addmsg(ReceivedData) ;此处已获取到消息 MsgBox % ReceivedData } return 1 } ;发送消息函数 SendData(wParam,SendData) { socket := wParam SendDataSize := VarSetCapacity(SendData) SendDataSize += 1 sendret := DllCall("Ws2_32\send", "UInt", socket, "Str", SendData, "Int", SendDatasize, "Int", 0) } InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) { Loop %pSize% DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) } CloseSocket(Socket) { Result := DllCall("Ws2_32\closesocket" , "UInt", Socket) Return result } exit: ;清除连接 Loop %i% { CloseSocket(conectioncheck%A_Index%) } DllCall("Ws2_32\WSACleanup") ExitApp
客户端Client:
;thinkai@2014-11-08 ;Based on http://www.autohotkey.com/board/topic/29650-tcpip-serverclient-chat-script-w-features #singleinstance force OnExit, exit ;创建窗口以接收数据 Gui, add, Edit Gui, hide ;客户端名称 服务器地址 端口 ClientName=%A_Computername% Network_Address = 135.230.71.250 Network_Port = 1000 ;连接到服务器 socket := ConnectToAddress(Network_Address, Network_Port) if socket = -1 ExitApp ;获取窗口句柄 Process, Exist DetectHiddenWindows On ScriptMainWindowId := WinExist("ahk_class AutoHotkey ahk_pid " . ErrorLevel) DetectHiddenWindows Off ;获取窗口句柄 NotificationMsg = 0x5555 ; An arbitrary message number, but should be greater than 0x1000. OnMessage(NotificationMsg, "ReceiveData") FD_READ = 1 ; Received when data is available to be read. FD_CLOSE = 32 ; Received when connection has been closed. if DllCall("Ws2_32\WSAAsyncSelect", "UInt", socket, "UInt", ScriptMainWindowId, "UInt", NotificationMsg, "Int", FD_READ|FD_CLOSE) { MsgBox % "WSAAsyncSelect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") ExitApp } ;发送连接好消息 SendData(socket,ClientName " Login!") return ;发送消息 send: SendData(socket,SendText) SendText = return ;连接服务器函数 ConnectToAddress(IPAddress, Port) { VarSetCapacity(wsaData, 32) result := DllCall("Ws2_32\WSAStartup", "UShort", 0x0002, "UInt", &wsaData) if ErrorLevel { MsgBox WSAStartup() could not be called due to error %ErrorLevel%. Winsock 2.0 or higher is required. return -1 } if result { MsgBox % "WSAStartup() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") return -1 } AF_INET = 2 SOCK_STREAM = 1 IPPROTO_TCP = 6 socket := DllCall("Ws2_32\socket", "Int", AF_INET, "Int", SOCK_STREAM, "Int", IPPROTO_TCP) if socket = -1 { MsgBox % "socket() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") return -1 } SizeOfSocketAddress = 16 VarSetCapacity(SocketAddress, SizeOfSocketAddress) InsertInteger(2, SocketAddress, 0, AF_INET) InsertInteger(DllCall("Ws2_32\htons", "UShort", Port), SocketAddress, 2, 2) InsertInteger(DllCall("Ws2_32\inet_addr", "Str", IPAddress), SocketAddress, 4, 4) if DllCall("Ws2_32\connect", "UInt", socket, "UInt", &SocketAddress, "Int", SizeOfSocketAddress) { MsgBox % "connect() indicated Winsock error " . DllCall("Ws2_32\WSAGetLastError") . "?" return -1 } return socket } ;接收函数 ReceiveData(wParam, lParam) { Critical global ShowRecieved socket := wParam ReceivedDataSize = 4096 Loop { VarSetCapacity(ReceivedData, ReceivedDataSize, 0) ReceivedDataLength := DllCall("Ws2_32\recv", "UInt", socket, "Str", ReceivedData, "Int", ReceivedDataSize, "Int", 0) if ReceivedDataLength = 0 ExitApp if ReceivedDataLength = -1 { WinsockError := DllCall("Ws2_32\WSAGetLastError") if WinsockError = 10035 return 1 if WinsockError <> 10054 MsgBox % "recv() indicated Winsock error " . WinsockError ExitApp } ;ReceivedData } return 1 } ;发送函数 SendData(wParam,SendData) { socket := wParam SendDataSize := VarSetCapacity(SendData) SendDataSize += 1 sendret := DllCall("Ws2_32\send", "UInt", socket, "Str", SendData, "Int", SendDatasize, "Int", 0) } InsertInteger(pInteger, ByRef pDest, pOffset = 0, pSize = 4) { Loop %pSize% DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) } CloseSocket(Socket) { Result := DllCall("Ws2_32\closesocket" , "UInt", Socket) Return result } GuiClose: exit: ;清除连接 CloseSocket(socket) DllCall("Ws2_32\WSACleanup") ExitApp
想学习autohotkey和sqlite数据库配合的使用,从ahk论坛找了相应资料,并使用QC归属地第三方2014年10月的最新归属地数据,做成了一个ahk离线查询归属地的函数。实际下载代码已经内置了Class_SQLiteDB
#NoEnv #Include Class_SQLiteDB.ahk ;初始化连接数据库 以便反复查询 DBFileName := A_ScriptDir . "\areacode.db" DB := new SQLiteDB If !DB.OpenDB(DBFileName) { MsgBox, 16, SQLite错误, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode ExitApp } ;示例 ;start := A_TickCount ;MsgBox % "号码:01012345678 归属地:"get_area("01012345678") " 查询耗时:" A_TickCount - start "毫秒" ;MsgBox % get_area("95533") ;MsgBox % get_area("02340820000") ;MsgBox % c := get_area("13800138000") InputBox, phone, 归属地查询, 请输入号码 if phone { start := A_TickCount MsgBox % "号码:" phone " 归属地:"get_area(phone) " 查询耗时:" A_TickCount - start "毫秒" } ExitApp get_area(phone){ global DB ;全局 ;去国家代码 phone := RegExReplace(phone,"^\+86","") phone := RegExReplace(phone,"^0086","") ;去长途代码 phone := RegExReplace(phone,"^0","") ;组织查询语句 SQL := "SELECT * FROM area where code='" SubStr(phone,1,7) "' or code='" SubStr(phone,1,6) "' or code='" SubStr(phone,1,5) "' or code='" SubStr(phone,1,4) "' or code='" SubStr(phone,1,3) "' or code='" SubStr(phone,1,2) "' order by code desc LIMIT 1" If !DB.GetTable(SQL, Result) MsgBox, 16, SQLite错误: 获取结果, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode Result.Next(Row) If (Result.HasRows) { Return Row[2] "-" Row[3] } }
pcname = PC-%A_Now% ;计算机名 ip = 192.168.1.2 mask = 255.255.255.0 ;子网掩码 gateway = 192.168.1.1 ;默认网关 dns = 114.114.114.114 ;DNS ;计算机名部分 RegWrite, REG_SZ, HKLM, SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName, ComputerName, %pcname% RegWrite, REG_SZ, HKLM, SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName, ActiveComputerName, %pcname% RegWrite, REG_SZ, HKLM, ControlSet002\Control\ComputerName\ComputerName, ComputerName, %pcname% RegWrite, REG_SZ, HKLM, SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, NV Hostname, %pcname% RegWrite, REG_SZ, HKLM, SYSTEM\CurrentControlSet\Services\Tcpip\Parameters, Hostname, %pcname% RegWrite, REG_SZ, HKU, S-1-5-18\Software\Microsoft\Windows\ShellNoRoam, , %pcname% RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Control\ComputerName\ActiveComputerName, ActiveComputerName, %pcname% RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Services\Tcpip\Parameters, Hostname, %pcname% RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Services\Tcpip\Parameters, NV Hostname, %pcname% RegWrite, REG_SZ, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon, DefaultDomainName, %pcname% RegWrite, REG_SZ, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon, AltDefaultDomainName, %pcname% ;IP部分 runwait, %ComSpec% /c netsh interface ip set address name=`"本地连接`" source=static addr=%ip% mask=%mask% gateway=%gateway% gwmetric=10, , Hide RunWait, %ComSpec% /c netsh interface ip set dns name=`"本地连接`" source=static addr=%dns% , ,Hide MsgBox, Ok
run, explorer.exe /e`,/select`,`"a:\`" ;你的路径
if 0 > 0 { Loop %0% { line = % %A_index% SplitPath, line, , dir, , name FileGetTime, time, %line%, ;获取文件时间 if RegExMatch(name,".*(昌吉|巴州|和田|阿勒泰|塔城|奎屯|克州|博州|伊犁|哈密|喀什|克拉玛依|乌鲁木齐|石河子|阿克苏|吐鲁番).*")>0 ;包含指定词 { area := RegExReplace(name,".*(昌吉|巴州|和田|阿勒泰|塔城|奎屯|克州|博州|伊犁|哈密|喀什|克拉玛依|乌鲁木齐|石河子|阿克苏|吐鲁番).*","$1") } Else area = 未知地区 if RegExMatch(name,".*(动彩|天翼阅读|爱音乐|爱游戏|民语高级会员|环球时报|天翼视讯|彩铃|交通秘书).*")>0 { business := RegExReplace(name,".*(动彩|天翼阅读|爱音乐|爱游戏|民语高级会员|环球时报|天翼视讯|彩铃|交通秘书).*","$1") } Else business = 未知地区 Loop { IfExist, %dir%\%area%_%business%_%time%.xls time+=1 Else { FileMove, %line%, %dir%\%area%_%business%_%time%.xls Break } } } } MsgBox, 64, 提示, 完成!
变量版:
Gui, Add, MonthCal, x0 y0 w230 h180 vMyCalendar Gui, Add, MonthCal, x230 y0 w230 h180 vMyCalendar2 gui, add, button, x0 y180 w230 h20 gcalc, 计算 Gui, Show m01=31 m02=28 m03=31 m04=30 m05=31 m06=30 m07=31 m08=31 m09=30 m10=31 m11=30 m12=31 Return calc: GuiControlGet, MyCalendar GuiControlGet, MyCalendar2 formattime, date1, %MyCalendar%, yyyyMMdd formattime, date2, %MyCalendar2%, yyyyMMdd diff := date1-date2 if diff = 0 { datediff_year := 0 datediff_month := 0 datediff_day := 0 goto, show } Else { if diff < 0 { newdate := date2 olddate := date1 } Else { newdate := date1 olddate := date2 } formattime, newyear, %newdate%, yyyy formattime, newmonth, %newdate%, MM formattime, newday, %newdate%, dd formattime, oldyear, %olddate%, yyyy formattime, oldmonth, %olddate%, MM formattime, oldday, %olddate%, dd datediff_year := newyear-oldyear newmd = %newmonth%%newday% oldmd = %oldmonth%%oldday% testmd := newmd-oldmd if testmd < 1 datediff_year := datediff_year-1 datediff_month := newmonth-oldmonth if newmonth < %newmonth% datediff_month := 12-datediff_month if newmonth = %newmonth% { if testmd < 1 datediff_month := 11 } testd := newday-oldday if testd < 0 { if newmonth > %oldmonth% datediff_month := datediff_month-1 } testoldmonthdays = % m%oldmonth% if oldmonth = 02 { testoldyunyear := oldyear/4 IfInString, testoldyunyear, .000000 testoldmonthdays += 1 } if testd < 0 datediff_day := newday+(testoldmonthdays-oldday) if testd >= 0 datediff_day := newday-oldday goto, show } return show: MsgBox, %datediff_year%年%datediff_month%月%datediff_day%日 Return GuiClose: ExitApp
数组版(差不多):
Gui, Add, MonthCal, x0 y0 w230 h180 vMyCalendar Gui, Add, MonthCal, x230 y0 w230 h180 vMyCalendar2 gui, add, button, x0 y180 w230 h20 gcalc, 计算 Gui, Show m01=31 m02=28 m03=31 m04=30 m05=31 m06=30 m07=31 m08=31 m09=30 m10=31 m11=30 m12=31 Return calc: datediff := object() GuiControlGet, MyCalendar GuiControlGet, MyCalendar2 formattime, date1, %MyCalendar%, yyyyMMdd formattime, date2, %MyCalendar2%, yyyyMMdd diff := date1-date2 if diff = 0 { datediff["year"] := 0 datediff["month"] := 0 datediff["day"] := 0 goto, show } Else { if diff < 0 { newdate := date2 olddate := date1 } Else { newdate := date1 olddate := date2 } formattime, newyear, %newdate%, yyyy formattime, newmonth, %newdate%, MM formattime, newday, %newdate%, dd formattime, oldyear, %olddate%, yyyy formattime, oldmonth, %olddate%, MM formattime, oldday, %olddate%, dd datediff["year"] := newyear-oldyear newmd = %newmonth%%newday% oldmd = %oldmonth%%oldday% testmd := newmd-oldmd if testmd < 1 datediff["year"] := datediff["year"]-1 datediff["month"] := newmonth-oldmonth if newmonth < %newmonth% datediff["month"] := 12-datediff["month"] if newmonth = %newmonth% { if testmd < 1 datediff["month"] := 11 } testd := newday-oldday if testd < 0 { if newmonth > %oldmonth% datediff["month"] := datediff["month"]-1 } testoldmonthdays = % m%oldmonth% if oldmonth = 02 { testoldyunyear := oldyear/4 IfInString, testoldyunyear, .000000 testoldmonthdays += 1 } if testd < 0 datediff["day"] := newday+(testoldmonthdays-oldday) if testd >= 0 datediff["day"] := newday-oldday goto, show } return show: year := datediff["year"] month := datediff["month"] day := datediff["day"] MsgBox, %year%年%month%月%day%日 Return GuiClose: ExitApp
业务需求,人工分太慢,素以写了这么一个简单的小脚本。
;创建图形界面 gui, add, text, x0 y0 w600 h20, 在下方粘贴数据 gui, add, edit, x0 y20 w600 h340 vsj, gui, add, text, x0 y360 w600 h20, 在下方输入分数据人数 gui, add, edit, x0 y380 w600 h20 vrs, gui, add, button, x0 y400 w600 h20 gok, 从excel或其他粘贴数据到上方并点此 gui, show, , 分数据 Return ok: ;获取GUI数据且不隐藏界面 Gui, Submit, NoHide if !sj { MsgBox, 64, 提示, 无数据,请粘贴! Return } if !rs { MsgBox, 64, 提示, 无人数,请输入! Return } ;替换excel粘贴过来的制表符 StringReplace, sj, sj, `t, `,, All ;分割成伪数组 StringSplit, line, sj, `n FileCreateDir, %A_Desktop%\分数据%A_MM%-%A_DD% Loop % rs ;循环人数/次 { ;上一个人的最后一项id idx := (A_index-1)*floor(line0/rs) ;floor向下取整 content = loop % floor(line0/rs) ;循环每个人的数据量/次 { idx += 1 content .= line%idx% "`n" ;表达式形式追加 } FileDelete, %A_Desktop%\分数据%A_MM%-%A_DD%\%A_Index%.csv FileAppend, %content%, %A_Desktop%\分数据%A_MM%-%A_DD%\%A_Index%.csv } ;多出来的 idx := rs*floor(line0/rs) content = loop % line0-floor(line0/rs)*rs { idx += 1 content .= line%idx% "`n" } FileDelete, %A_Desktop%\分数据%A_MM%-%A_DD%\多的.csv FileAppend, %content%, %A_Desktop%\分数据%A_MM%-%A_DD%\多的.csv Run, %A_Desktop%\分数据%A_MM%-%A_DD%\ Return GuiClose: ExitApp
#NoTrayIcon ;读取安装好的jdk版本 RegRead, version, HKLM, SOFTWARE\JavaSoft\Java Development Kit, CurrentVersion if !Errorlevel { ;读取安装好的jdk路径 RegRead, JavaHome, HKLM, SOFTWARE\JavaSoft\Java Development Kit\%version%, JavaHome ;写入环境变量 RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Control\Session Manager\Environment, JAVA_HOME, %JavaHome% RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Control\Session Manager\Environment, CLASSPATH, .;`%JAVA_HOME`%\lib\dt.jar;`%JAVA_HOME`%\lib\tools.jar; ;添加path RegRead, oldpath, HKLM, SYSTEM\ControlSet001\Control\Session Manager\Environment, Path RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Control\Session Manager\Environment, Path, %oldpath%;%JavaHome%\bin ;立即生效 SendMessage, 0x1A, 0,"Environment",, ahk_id 0xFFFF if 1 = ;带参数cmd执行exe不显示提示 MsgBox, 64, 提示, 设置完成! }
addpath = d:\ ;你要添加的 RegRead, oldpath, HKLM, SYSTEM\ControlSet001\Control\Session Manager\Environment, Path ;读取原有 RegWrite, REG_SZ, HKLM, SYSTEM\ControlSet001\Control\Session Manager\Environment, Path, %oldpath%;%addpath% ;添加至注册表 RegWrite, REG_SZ, HKLM, SYSTEM\CurrentControlSet\Control\Session Manager\Environment, Path, %oldpath%;%addpath% SendMessage, 0x1A, 0,"Environment",, ahk_id 0xFFFF ;立即生效
50 queries in 1.379 seconds |