应网友小古要求写的,这里仅贴出最终版
功能:
1、可以按照自己的查询语句执行
2、自适应显示内容和上传图片
3、可以编辑可插入内容(屏蔽包含“id”字段)
4、点击图片保存图片
5、保存数据库信息方便下次使用
6、兼容SQL SERVER 2000/2005/2008/2012/2014各版本 采用ADO连接方式



程序下载:
;2.2版本改进
;1、修复无图片列上传图片后回显失败问题
;2、修复addmsg()显示消息记录函数
;3、修复编辑、插入后手动执行问题
;2.1版本改进
;1、修复“修改”、“插入”gui重复问题
;2、修复无图片项目显示问题并内置图片到脚本
;注意事项:部分 SQL Sever远程连接会有明显延迟情况,这可能是ADO连接方式的问题。建议在服务器所属环境下运行或者在本地上传完再生成sql执行
;By Thinkai
;字符化图片预置
nopic = 424dfe2b[6_00]3e[3_00]28[3_00]fa[3_00]5e01[2_00]010001[5_00]c02b[2_00]415c[2_00]415c[14_00][3_ff]00[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[11_ff]1f[10_ff]fd[3_ff]e1[4_ff]c0[5_ff]9f[3_ff]3fff1fffc007ffc3[4_ff]c7f8[3_ff]e1[4_ff]c0[4_ff]7f03[2_ff]f81fff1fffc003ffc3[4_ff]c7f07f[2_ff]e1[4_ff]c0[3_ff]f87f00[2_ff]e01fff1fffc001ffc0[4_00]07f07f[2_ff]e1[4_ff]c0[3_ff]f87e001fff000fff1fffc000ffc0[4_00]07f03f[2_ff]e1[4_ff]c0[3_ff]f83fc007fc007fff1f[2_ff]e0ffc0[4_00]07f81f[2_ff]e1[4_ff]c0[3_ff]fc3ff801f803[2_ff]1f[2_ff]f0ffc0[4_00]07fc1f[2_ff]e1[4_ff]c0[3_ff]fc3fff00601f[2_ff]1f[2_ff]f0ffc3[4_ff]c7fc0f[2_ff]e1[4_ff]c0[3_ff]fc1fffc0007f[2_ff]1f[2_ff]f0ffc3[3_ff]9fc7fe0f[2_ff]e1[4_ff]c0[3_ff]fe1ffff001[3_ff]1f[2_ff]f0ffc3[2_ff]f81fc7ff07[2_ff]e1[4_ff]c0[3_ff]fe1ffffc03[3_ff]1f[2_ff]f0ffc3[2_ff]801fc7ff07[2_ff]e1[4_ff]c0[3_ff]fe0ffffc03[3_ff]1f[2_ff]f0ffc3fff0000fc7ff87[2_ff]e1[4_ff]c0[4_ff]0ffff801[3_ff][4_00]ffc3fe[2_00]ffc7ff83[2_ff]e1[4_ff]c0[4_ff]0ffff000[3_ff][4_00]ffc3e0001fffc7ff83[2_ff]e1[4_ff]c0[4_ff]07fff0607f[2_ff][4_00]ffc3f007[2_ff]c7ffc3[2_ff]e1[4_ff]c0[4_ff]87ffe0f83f[2_ff]1f[2_ff]f0ffc3f3[3_ff]c7ffc3[2_ff]e1[4_ff]c0[4_ff]87ffc1fc1f[2_ff]1f[2_ff]f0ffc3[2_ff]fdffc7ffc3[2_ff]e1[4_ff]c0[4_ff]83ff83fe1f[2_ff]1f[2_ff]f0ffc3[2_ff]80ffc7ffc1[2_ff]e1[4_ff]c0[4_ff]c3ff87fe0f[2_ff]1f[2_ff]f0ffc3fff000ffc7ffc0[2_00]01[4_ff]c0[4_ff]c3ff0fff07fe7f1f[2_ff]f0ffc3ff8007ffc7ffe0[2_00]01[4_ff]c0[4_ff]c3ff0fff87fc3f1f[2_ff]f0ffc33f80[2_ff]c7ffe0[2_00]01[4_ff]c0[4_ff]effe1fff83fc1f[4_00]ffc3079ffffdc7ffe0[2_00]01[4_ff]c0[5_ff]fe1fffc3fc0f[4_00]ffc200[2_ff]c0c7ffe1[7_ff]c0[5_ff]fc3fffe1ff07[4_00]ffc3c01ffe00c7ffe1[7_ff]c0[5_ff]f0[2_00]01ff831f[2_ff]f0ffc3f807f000c7ffe1[7_ff]c0[5_ff]f0[2_00]01ffc11f[2_ff]f0ffc3ff01c007c7ffe1[7_ff]c0[5_ff]f0[2_00]01ffe01f[2_ff]f0ffc3ffc000ffc7ffe1[7_ff]c0[4_ff]c7e7[4_ff]f01f[2_ff]f0ffc3fff007ffc7ffe1[7_ff]c0[4_ff]83c3[4_ff]f81f[2_ff]f0ffc3fff007ffc7ffe1[7_ff]c0[4_ff]0181[4_ff]fc1f[2_ff]f0ffc3dfe003ffc7ffe1[7_ff]c0[3_ff]fe07c0[2_ff]e00ffc1f[2_ff]f0ffc38fc1c0ffc7ffe0[4_00]3f[2_ff]c0[3_ff]fc0ff07fffc00ffe[4_00]ffc30787f07fc7ffe0[4_00]3f[2_ff]c0[3_ff]f01ff83fff800fff[4_00]ffc3830ff83fc7ffe0[4_00]3f[2_ff]c0[3_ff]f03ffc1fff800fff80[3_00]ffc3c01ffc1fc7ffe0[4_00]3f[2_ff]c0[3_ff]f8fffe1fff87[2_ff]83[4_ff]c3f03ffe0fc7ffe1[2_ff]87[4_ff]c0[3_ff]fdfffe1fff87[2_ff]c3[4_ff]c3f87fff07c7ffe1[2_ff]87[4_ff]c0[6_ff]0fff87[2_ff]e1[4_ff]c3fc[2_00]07c7ffe1[2_ff]87[4_ff]c0[6_ff]0fff87[2_ff]e0[4_ff]c3fe[2_00]07c7ffe1[2_ff]87[4_ff]c0[4_ff]fbff0fff87[2_ff]f0[4_ff]c3fe[2_00]07c7ffe1[2_ff]87[4_ff]c0[4_ff]f1ff0fff87fe[5_00]03c3ff0f[2_ff]c7ffe1[2_ff]87[4_ff]c0[4_ff]e0ff0fff87fe[5_00]03c3ff87[2_ff]c7ffe1[2_ff]87[4_ff]c0[4_ff]c0ff0fff87fe[5_00]03c3ffc3[2_ff]c7ffe1[2_ff]87[4_ff]c0[4_ff]81ff[2_00]07fe[5_00]03c3ffcf[2_ff]c7ffe1[2_ff]87[4_ff]c0[4_ff]03ff[2_00]07[2_ff]fc1f[3_ff]c0[4_00]07ffe1[2_ff]87[4_ff]c0[3_ff]fe0fff[2_00]07[2_ff]fe1f[3_ff]c0[4_00]07ffe1[2_ff]87[4_ff]c0[3_ff]fc1fff[2_00]07[2_ff]fe1f[3_ff]c0[4_00]07ffe1[2_ff]87[4_ff]c0[3_ff]fe3f[7_ff]0f[3_ff]c0[4_00]07ffe1[2_ff]87[4_ff]c0[4_ff]7f[7_ff]0f[13_ff]87[4_ff]c0[12_ff]3f[18_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0[31_ff]c0
;创建界面
;加main限定
gui, main:add, text, x10 y10 w60 h20, 查询SQL:
gui, main:add, edit, x70 y10 w630 h20 vsql, select * from test
gui, main:add, button, x700 y10 w100 h20 Default gexec, 执行
gui, main:add, listview, x10 y40 w530 h350 vlv glv
gui, main:add, edit, x10 y400 w530 h100 vmsg ReadOnly,
gui, main:add, picture, x550 y40 w250 h359 vpic gpic
gui, main:add, button, x550 y410 w120 h20 gedit, 修改
gui, main:add, button, x680 y410 w120 h20 ginsert, 插入
gui, main:add, button, x550 y440 w250 h30 gupload, 上传图片
gui, main:add, button, x550 y480 w250 h20 gsetserver, 修改数据库信息
gui, main:show, ,上传图片到数据库
gui, main:default
addmsg("初始化配置文件")
IfExist, server.ini
{
IniRead, host, server.ini, server, host
IniRead, user, server.ini, server, user
IniRead, pass, server.ini, server, pass
IniRead, db, server.ini, server, db
}
Else
goto, setserver
Return
;获取数据并显示图片函数
showpic(){
FileDelete, %A_Temp%\show.jpg ;删除已存在临时文件
;函数内全局变量
global pic_id
global row_id
;获取image列文本
LV_GetText(text,row_id,pic_id)
IfInString, text, image_ ;显示图片
{
key = % %text%
file = %A_Temp%\show.jpg
blob2file(key,file)
GuiControl, main:, pic, %file%
}
Else ;显示“没有图片”
{
global nopic
picdata := unzip(nopic)
file = %A_Temp%\show.jpg
blob2file(picdata,file)
GuiControl, main:, pic, %file%
}
LV_GetText(id,row_id,1)
Return id
}
;HEX字符解压函数
unzip(a){
StringSplit, var, a, ]
Loop % var0-1
{
tmp_var = % var%A_Index%
StringSplit, key, tmp_var, [
StringSplit, xx, key2, _
unzip_var =
Loop % xx1
{
unzip_var = % unzip_var xx2
}
out = % out key1 unzip_var
}
out := out var%var0%
Return out
}
;variant Objiect 写入文件函数 加入了上传图片后直接赋值字符的处理
blob2file(blob,file){
if (IsObject(blob))
{
blob_string =
;枚举
tmp_file := FileOpen(file, "w")
SetFormat, IntegerFast, hex
For key in blob
tmp_file.WriteUChar(key)
SetFormat, IntegerFast, d
}
Else ;字符
{
tmp_file := FileOpen(file, "w")
StringLen, len, blob
loop % len/2
{
if blob =
break
StringLeft, tmp_hex, blob, 2
StringTrimLeft, blob, blob, 2
tmp_hex := "0x" tmp_hex
tmp_file.WriteUChar(tmp_hex)
}
}
tmp_file.Close()
tmp_file =
}
;追加消息
addmsg(message){
GuiControlGet, msg
;针对多GUI的bug
if !msg
{
ControlGetText, msg, Edit2, 上传图片到数据库
}
msg = %msg%%A_Hour%:%A_Min%:%A_Sec%.%A_MSec%->%message%`n
msg := RegExReplace(msg,".*\n(.*\n.*\n.*\n.*\n.*\n.*)","$1")
GuiControl, main:, msg, %msg%
}
;文件转HEX函数
file2hex(file){
tmp_file := FileOpen(file, "r")
while not tmp_file.AtEOF {
tmp_file.RawRead(Data, 1)
SetFormat, IntegerFast, hex
tmp_hex := asc(Data)
StringReplace, tmp_hex, tmp_hex, 0x, , All
SetFormat, IntegerFast, d
if StrLen(tmp_hex) = 1
tmp_hex = 0%tmp_hex%
hex = % hex tmp_hex
}
tmp_file.Close()
Return hex
}
exec:
pic_id=
pic_name=
addmsg("获取SQL")
GuiControlGet, sql
conn := ComObjCreate("ADODB.connection") ;初始化COM
conn.Open("driver={SQL Server};server=" host ";uid=" user ";pwd=" pass ";database=" db) ;打开连接
addmsg("打开数据库连接")
connected = 1
query := conn.Execute(sql) ;执行
addmsg(sql)
;判断sql类型
StringLower, lower_sql, sql
IfInString, lower_sql, select
{
lower_sql = %lower_sql% `n ;添加结束标志
table := RegExReplace(lower_sql,"select.*from\s+(\w+)\s+.*\n", "$1") ;截取table名
;删除原有lv信息
LV_Delete()
Loop, % LV_GetCount("Column")
LV_DeleteCol(1)
;枚举对象内所有字段名称
for field in query.Fields
fields := fields field.Name "|"
fields := fields "`n" ;添加结尾
StringReplace, fields, fields, |`n, , All ;去掉末尾|
StringSplit, names, fields, | ;分割字段
update_string =
Loop % names0 ;添加到ListView 保存到update特征语句
{
tmp_name = % names%A_index% ;取出变量
LV_InsertCol(A_Index, , tmp_name)
}
fetchedArray := query.GetRows() ;取出数据(二维数组)
colSize := fetchedArray.MaxIndex(1) + 1 ;列最大值 tips:从0开始 所以要+1
rowSize := fetchedArray.MaxIndex(2) + 1 ;行最大值 tips:从0开始 所以要+1
addmsg("查询到" rowSize "个结果")
loop, % rowSize
{
i := A_index - 1
y := A_index
loop, % colSize
{
j := A_index - 1
x := A_index
tmp_var := fetchedArray[j,i] ;取出二维数组内值
if (IsObject(tmp_var)) ;variant Objiect 改变显示名称为变量名
{
pic_id := x
pic_name = % names%x%
image_%y% := tmp_var
data_%y%_%x% = image_%y%
}
Else ;字符值直接显示
{
data_%y%_%x% := tmp_var
}
}
;自适应添加,超过失效
LV_Add("",data_%y%_1,data_%y%_2,data_%y%_3,data_%y%_4,data_%y%_5,data_%y%_6,data_%y%_7,data_%y%_8,data_%y%_9,data_%y%_10,data_%y%_11,data_%y%_12,data_%y%_13,data_%y%_14,data_%y%_15,data_%y%_16,data_%y%_17,data_%y%_18,data_%y%_19,data_%y%_20,data_%y%_21,data_%y%_22,data_%y%_23,data_%y%_24,data_%y%_25,data_%y%_26,data_%y%_27,data_%y%_28,data_%y%_29,data_%y%_30) ;添加到列表
}
;清空变量
fields =
blob_hex =
blob_string =
query =
;自动调整列宽
LV_ModifyCol()
addmsg("为您显示第一条内容")
;自动显示第一张图
row_id = 1
id := showpic()
}
Else
{
addmsg(conn.Errors)
}
Return
lv:
update_string=
row_id := A_EventInfo
addmsg("选中并显示第" row_id "行")
id := showpic()
Return
upload:
Gui +OwnDialogs
if pic_id=
{
MsgBox, 64, 提示, 您没有任何现有图片数据的列,请先定义字段类型或上传一个!
Return
}
update_string=
if row_id > 0
{
FileSelectFile, file, , , 请选择要上传的图片, 图片文件(*.jpg;*.png;*.gif;*.bmp)
if file <>
{
GuiControl, , pic, %file%
addmsg("读取" file)
hex := file2hex(file)
;Clipboard := hex
addmsg("上传" file)
loop % names0
{
LV_GetText(tmp_value,row_id,A_index)
if A_index <> %pic_id%
{
if tmp_value <>
update_string := update_string "[" names%A_index% "]='" tmp_value "' and "
}
}
update_string = %update_string%`n
StringReplace, update_string, update_string, %A_Space%and `n
sql = % "update " table " set " pic_name "=0x" hex " where " update_string ;查询语句
query := conn.Execute(sql)
sql =
addmsg("上传完成!请稍等···")
LV_GetText(text,row_id,pic_id)
if text <>
%text% := hex
Else
goto, exec
hex =
id := showpic()
addmsg("回显图片修改完成!")
}
}
Else
MsgBox, 64, 提示, 请先双击一列!
Return
set:GuiClose:
Gui set:+OwnDialogs
addmsg("保存配置信息")
GuiControlGet, host
if host =
{
MsgBox, 64, 错误, 您未填写内容!
Return
}
Else
{
gui, set:Submit
IniWrite, %host%, server.ini, server, host
IniWrite, %user%, server.ini, server, user
IniWrite, %pass%, server.ini, server, pass
IniWrite, %db%, server.ini, server, db
}
Return
subset:
Gui set:+OwnDialogs
addmsg("保存配置信息")
gui, set:Submit
gui, set:Destroy
IniWrite, %host%, server.ini, server, host
IniWrite, %user%, server.ini, server, user
IniWrite, %pass%, server.ini, server, pass
IniWrite, %db%, server.ini, server, db
Return
edit:
Gui edit:+OwnDialogs
update_string2=
if row_id > 0
{
tmp_y = 0
IfWinExist, 编辑信息
gui, edit:Destroy
loop % names0
{
if A_index <> %pic_id%
{
tmp_name = % names%A_index%
IfNotInString, tmp_name, id ;排除各种id字段
{
Gui,edit:Add,Text,x0 y%tmp_y% w80 h20, % names%A_index% ":"
Gui,edit:Add,Edit,x70 y%tmp_y% w200 h20 vedit_%A_Index%,
tmp_y += 20
}
}
}
Gui,edit:Add,Button,x0 y%tmp_y% w270 h20 gsubedit, 确定
Gui,edit:Show, , 编辑信息
gui, edit:+AlwaysOnTop
loop % names0
{
if A_index <> %pic_id%
{
LV_GetText(tmp_value,row_id,A_index)
IfNotInString, tmp_name, id ;排除各种id字段
{
GuiControl, edit:, edit_%A_Index%, %tmp_value%
update_string2 := update_string2 "[" names%A_index% "]='" tmp_value "' and "
}
}
}
update_string2 = %update_string2%`n
StringReplace, update_string2, update_string2, %A_Space%and `n
}
Else
MsgBox, 64, 提示, 请先双击一列!
Return
subedit:
Gui edit:+OwnDialogs
set_string=
addmsg("保存编辑信息")
gui, edit:Submit
gui, edit:Destroy
loop % names0
{
if A_index <> %pic_id%
{
tmp_name = % names%A_index%
IfNotInString, tmp_name, id
{
;LV_Modify(row_id, Col%A_index%, edit_%A_index%) 无效 请手动执行刷新
set_string := set_string "[" names%A_index% "]='" edit_%A_index% "',"
}
}
}
set_string = %set_string%`n
StringReplace, set_string, set_string, `,`n
sql = % "update " table " set " set_string " where " update_string2 ;查询语句
addmsg(sql)
query := conn.Execute(sql)
sql =
addmsg("修改完成!")
ControlClick, Button1, 上传图片到数据库, , Left
Return
insert:
Gui insert:+OwnDialogs
if row_id > 0
{
tmp_y = 0
IfWinExist, 插入信息
gui, insert:Destroy
loop % names0
{
if A_index <> %pic_id%
{
tmp_name = % names%A_index%
IfNotInString, tmp_name, id ;排除各种id字段
{
Gui,insert:Add,Text,x0 y%tmp_y% w80 h20, % names%A_index% ":"
Gui,insert:Add,Edit,x70 y%tmp_y% w200 h20 vedit_%A_Index%,
tmp_y += 20
}
}
}
Gui,insert:Add,Button,x0 y%tmp_y% w270 h20 gsubinsert, 确定
Gui,insert:Show, , 插入信息
gui, insert:+AlwaysOnTop
}
Else
MsgBox, 64, 提示, 请先双击一列!
Return
subinsert:
Gui insert:+OwnDialogs
key_string=
value_string=
addmsg("保存新增信息")
gui, insert:Submit
gui, insert:Destroy
loop % names0
{
if A_index <> %pic_id%
{
tmp_name = % names%A_index%
IfNotInString, tmp_name, id
{
key_string := key_string "[" names%A_index% "],"
value_string := value_string "'" edit_%A_index% "',"
}
}
}
key_string = %key_string%`n
StringReplace, key_string, key_string, `,`n
value_string = %value_string%`n
StringReplace, value_string, value_string, `,`n
sql = % "insert into " table " (" key_string ")values(" value_string ")" ;查询语句
addmsg(sql)
query := conn.Execute(sql)
sql =
addmsg("插入完成!")
ControlClick, Button1, 上传图片到数据库, , Left
Return
setserver:
Gui,set:Add,Text,x0 y0 w80 h20,服务器地址:
Gui,set:Add,Edit,x70 y0 w200 h20 vhost,
Gui,set:Add,Text,x0 y20 w70 h20,用户名:
Gui,set:Add,Edit,x70 y20 w200 h20 vuser,
Gui,set:Add,Text,x0 y40 w70 h20,密码:
Gui,set:Add,Edit,x70 y40 w200 h20 Password vpass,
Gui,set:Add,Text,x0 y60 w70 h20,数据库:
Gui,set:Add,Edit,x70 y60 w200 h20 vdb,
Gui,set:Add,Button,x0 y80 w270 h20 gsubset, 确定
Gui,set:Show, , 设置数据库信息
gui, set:+AlwaysOnTop
GuiControl, set:, host, %host%
GuiControl, set:, user, %user%
GuiControl, set:, pass, %pass%
GuiControl, set:, db, %db%
Return
pic: ;保存当前图片
FileSelectFile, file, S, , 请选择图片保存路径, 图片文件(*.jpg;*.png;*.gif;*.bmp)
FileCopy, %A_Temp%\show.jpg, %file%, 1
addmsg("另存图片为" file "完成!")
Return
editGuiClose:
gui, edit:Destroy
Return
insertGuiClose:
gui, insert:Destroy
Return
mainGuiClose:
addmsg("退出")
conn.Close()
ExitApp
z::
ex = 0
Loop
{
if ex = 1
Break
MouseGetPos, x, y
do:
MouseClick, Right, %x%, %y%,
sleep, 250
Send, s
WinWaitActive, ahk_class #32770, , 1
if Errorlevel
goto, do
Send, %A_Now%
Send, {Enter}
sleep, 100
Send, {Left}
}
Return
x::
ex = 1
Return
z开始 x中断
49 queries in 2.017 seconds |