source := "src.xls" ;源文件 target := "[a].[dbo].[test_table]" ;数据库目标表 has_create_tab := 0 ;是否已创建表 xlsdb := new exceldb() ;创建excel adodb连接,获取数据表信息 xlsdb.open(source) sheet := xlsdb.GetTableInfo() ;数据库连接 conn := ComObjCreate("ADODB.connection") conn.Open("driver={SQL Server};server=192.168.8.2;uid=thinkai;pwd=02EdDd68F5CC83__;database=a") ;打开连接 ;遍历有效sheet for k,v in sheet { fields := v if !has_create_tab ;尝试创建表 { f := "" for x,y in v f .= f ? ",[" y "] nvarchar(255) NULL" : "[" y "] nvarchar(255) NULL" try conn.Execute("CREATE TABLE " target " (" f ");") } field := "" ;生成字段串 注意表格里面的字段名称应和数据库中的字段一致 for x,y in v field .= field ? ",[" y "]" : "[" y "]" tmp_result := xlsdb.GetTable("SELECT * FROM [" (InStr(k,"$") ? k : k "$") "];") ;获取单个sheet的全部数据 for row,vaules in tmp_result { tmp_str := "" for k,v in vaules tmp_str .= tmp_str ? ",'" v "'" : "'" v "'" conn.Execute("INSERT INTO " target " VALUES (" tmp_str ")") ;插入语句 } } MsgBox, OK getto(str){ o := [] Loop, Parse, str, `n, `r { IfInString, A_LoopField, `t { t := StrSplit(A_LoopField,"`t") o[t[1]] := t[2] } } return o } class exceldb { ;static conn __New() ;新建 { this.conn:= ComObjCreate("ADODB.connection") ;初始化COM } open(file) ;打开文件 { IfExist % file this.conn.Open("Provider=Microsoft.Ace.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" file) ;打开连接 ;this.conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=Yes';Data Source=" file) ;打开连接 2003方式 } close() ;关闭文件 { this.conn.Close() } GetTableInfo() ;获取所有Sheet及字段信息 { ;通过OpenSchema方法获取表信息 rs := this.conn.OpenSchema(20) ;SchemaEnum 参考 http://www.w3school.com.cn/ado/app_schemaenum.asp t := [] rs.MoveFirst() while !rs.EOF { t_name := RegExReplace(rs.("TABLE_NAME").value,"^'*(.*)\$'*$","$1") q := this.conn.Execute("select top 1 * from [" t_name "$]") if (q.Fields(0).Name="F1" && q.Fields.Count=1) ;排除空表格 { rs.MoveNext() continue } t[t_name] := [] for field in q.Fields ;获取按顺序排列的字段 t[t_name].insert(field.Name) q.close() rs.MoveNext() } return t } GetTable(sql) { t := [] query := this.conn.Execute(sql) if RegExMatch(sql,"i)^select*") { fetchedArray := query.GetRows() ;取出数据(二维数组) colSize := fetchedArray.MaxIndex(1) + 1 ;列最大值 tips:从0开始 所以要+1 rowSize := fetchedArray.MaxIndex(2) + 1 ;行最大值 tips:从0开始 所以要+1 loop, % rowSize { i := (y := A_index) - 1 t[y] := [] loop, % colSize { j := (x := A_index) - 1 t[y][x] := fetchedArray[j,i] ;取出二维数组内值 } } query.Close() return t } } }
exe_file := "test.exe" Gui, Add, text, x0 y0 w60 h20, 源文件 Gui, Add, Edit, x60 y0 w200 h20 vsource_file Gui, Add, text, x0 y20 w60 h20, 进程数 Gui, Add, Edit, x60 y20 w200 h20 vmax, 10 Gui, Add, Button, x0 y40 w160 h20 gstart vstart, 开始 gui, Add, text, x0 y60 w160 h100 vshow Gui, Show, x0 y0, 多进程示例 return start: GuiControl, Disable, start Gui, Submit, nohide FileRead, content, % source_file Loop, Parse, content, `n, `r { while(!check_idle()) Sleep, 1000 info := StrSplit(res,",") GuiControl, , show, % "信息:" info[1] " " info[2] "`n本次运行数量:" A_index "`n当前线程数:" p.maxindex()+1 Run, % exe_file " " info[1] " " info[2], , , pid ;传参方式传递数据 p.Push(pid) } return GuiClose: ExitApp check_idle(){ global p,max for k,v in p { Process, Exist, % v if !ErrorLevel p.RemoveAt(k) } return (p.maxindex()<max) }
xml = ( <?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><commonUtil xmlns="http://wtp"><value xmlns:SOAPSDK4="http://wtp">data</value></commonUtil></SOAP-ENV:Body> ) ;请求头根据实际需求修改,注意Content-Type。 result := URLDownloadToVar("http://yourwebsite.com", "UTF-8","POST",xml,{"SOAPAction":"""urn:commonUtil""","Content-Type":"text/xml; charset=""UTF-8""","User-Agent":"SOAP Toolkit 3.0","Host":"0.0.0.0","Content-Length":strlen(xml),"Connection":"Keep-Alive","Cache-Control":"no-cache","Pragma":"no-cache"}) MsgBox % result URLDownloadToVar(url, Encoding = "",Method="GET",postData="",headers:=""){ ;网址,编码,请求方式,post数据,请求头 hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1") if Method = GET { Try { ;hObject.SetTimeouts(500,2000,2000,5000) hObject.Open("GET",url) hObject.Send() } catch e return -1 } else if Method = POST { Try { hObject.SetTimeouts(30000,30000,300000,300000) hObject.Open("POST",url,True) if IsObject(headers) { for k,v in headers hObject.SetRequestHeader(k, v) } hObject.Send(postData) hObject.WaitForResponse(-1) } catch e { FileAppend, % "`n" var_dump(e), error.txt return -1 } } if (Encoding && hObject.ResponseBody) { oADO := ComObjCreate("adodb.stream") oADO.Type := 1 oADO.Mode := 3 oADO.Open() oADO.Write(hObject.ResponseBody) oADO.Position := 0 oADO.Type := 2 oADO.Charset := Encoding return oADO.ReadText(), oADO.Close() } return hObject.ResponseText }
使用方法:拖拽单个图片文件到脚本上。截图软件源自:AHK截图命令行工具
if 0>0 ;判断命令行 { pic = %1% ;转存第一个命令行参数 arr := [[330,516],[330,426],[330,400],[300,300],[200,160],[720,460]] ;图片尺寸数组 Gui, Color, White Gui +ToolWindow -Caption +AlwaysOnTop Gui, Add, Picture, vpctrl, % pic for k,v in arr { if (v.1>v.2) ;横版 { GuiControl, Move, pctrl, % "x" ceil((v.1-v.2)/2) " y0" ; w" v.2 " h" v.2 GuiControl, , pctrl, % "*w" v.2 " *h" v.2 " " pic } else ;正方或竖版 { GuiControl, Move, pctrl, % "x0 y" ceil((v.2-v.1)/2) ;" w" v.1 " h" v.1 GuiControl, , pctrl, % "*w" v.1 " *h" v.1 " " pic } Gui, Show, % "x0 y0 w " v.1 " h" v.2 ;重设图片大小 Sleep, 200 RunWait, % "CaptureScreen.exe 5 0 " k "_" v.1 "x" v.2 ".jpg 90 Aqua 0 0 " v.1 " " v.2 ;截图 } Gui, Destroy ExitApp }
;SetLocalTime("20100101123000000") ;SetLocalTime("20100101123000") SetLocalTime(YYYYMMDDHH24MISS) { VarSetCapacity(newtime, 16, 0) For i, n in [ [0,1,4],[2,5,2],[6,7,2],[8,9,2],[10,11,2],[12,13,2],[14,15,3] ] NumPut( SubStr(YYYYMMDDHH24MISS, n.2, n.3), newtime, n.1, "UShort" ) DllCall("SetLocalTime", "Ptr", &newtime) }
首先,我们需要找一个引导,用安装光盘进入恢复模式可能有些问题,所以这次我们用U盘Grub4DOS的方式直接进入系统再修复。
插入U盘到电脑,打开BOOTICE,格式化成FAT格式,然后设置主引导记录:
把下载的grub4dos解压,复制grldr和grub.exe到U盘,创建menu.lst,内容如下(具体的启动内核可能不一样):
default=0 timeout=5 title hd1_371 root (hd1,0) kernel /boot/vmlinuz-2.6.18-371.1.2.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-371.1.2.el5.img title hd1_406 root (hd1,0) kernel /boot/vmlinuz-2.6.18-406.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-406.el5.img title hd0_371 root (hd0,0) kernel /boot/vmlinuz-2.6.18-371.1.2.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-371.1.2.el5.img title hd0_406 root (hd0,0) kernel /boot/vmlinuz-2.6.18-406.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-406.el5.img title hd2_371 root (hd2,0) kernel /boot/vmlinuz-2.6.18-371.1.2.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-371.1.2.el5.img title hd2_406 root (hd2,0) kernel /boot/vmlinuz-2.6.18-406.el5 ro root=LABEL=/ initrd /boot/initrd-2.6.18-406.el5.img
设置服务器从U盘启动,尝试启动到系统,进入之后进行修复grub操作
grub-install --root-directory=/boot /dev/hda
这就大功告成了!
#Persistent IfNotExist, hotkey.ini { ie := "F8" folder := "F9" } else { IniRead, ie, hotkey.ini, key, ie IniRead, folder, hotkey.ini, key, folder } Hotkey, % ie, ie Hotkey, % folder, folder Menu, Tray, Add, 设置快捷键, set return ie: Run, iexplore.exe www.baidu.com return folder: Run, explorer.exe /e`,d:\ return set: Hotkey, % ie, Off Hotkey, % folder, Off Gui, set:Destroy Gui, set:Add, text, x0 y0 w100 h20, 浏览器 Gui, set:Add, Hotkey, x100 y0 w100 h20 vie Gui, set:Add, text, x0 y20 w100 h20, 文件夹 Gui, set:Add, Hotkey, x100 y20 w100 h20 vfolder Gui, set:Add, Button, x0 y40 w200 h20 gsubset, 确定 Gui, set:Show GuiControl, set:, folder, % folder GuiControl, set:, ie, % ie return subset: Gui, set:Submit, NoHide Iniwrite, % ie, hotkey.ini, key, ie Iniwrite, % folder, hotkey.ini, key, folder Hotkey, % ie, ie Hotkey, % folder, folder Gui, set:Destroy return
urlencode(string,encoding:="UTF-8"){ VarSetCapacity(pstr,ceil(strlen(string)*1.5+10),0) StrPut(string,&pstr,,encoding) int := "1" while (int){ int := ToBase(NumGet(&pstr,(A_index-1)*4,"Uint"),16) RegExMatch(int,"(.{2})(.{2})(.{2})(.{2})",m) loop 4 { i := 4-A_index+1 hex := % m%i% if hex { hex2 := "0x" hex If (hex2==33 || (hex2>=39 && hex2 <=42) || hex2==45 || hex2 ==46 || (hex2>=48 && hex2<=57) || (hex2>=65 && hex2<=90) || hex2==95 || (hex2>=97 && hex2<=122) || hex2==126) out .= chr("0x" hex) else out .= "%" hex } } } Return out } ToBase(n,b){ return (n < b ? "" : ToBase(n//b,b)) . ((d:=Mod(n,b)) < 10 ? d : Chr(d+55)) }
49 queries in 1.935 seconds |