//打开数据连接 https://www.newasp.net/soft/110660.html 下载 组件
Function connOpen()
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=localhost;" & "UID=root; PWD=root; OPTION=3; DATABASE=demo;stmt=SET NAMES GB2312"
'注意ODBC驱动版本号,现在最新的 MySQL 5.4 + ODBC 5.1
'另外可以有 DATABASE=XX,或者在程序里使用 use database 语句
'OPTION是什么作用不知道,我这里可以不写
conn.Open
Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = adOpenKeyset'游标位置(数据集存在服务器内存还是客户端内存)//有警告信息可以突略 adOpenKeyset adUseNone https://blog.csdn.net/xzsfg6825/article/details/80047946
End Function
//执行记录
Function mysql_query(sql)
Call connOpen()
conn.Execute sql
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Function
//获取数据列表
Function mysql_list(sql)
Call connOpen()
rs.Open sql, conn
While rs.EOF = False '如果EOF为真,则表示"游标"已经在最后一条记录后面。
MsgBox ("user_name:" & rs("neirong") & "||password:" & rs("time"))
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Function
//写入
Call mysql_query("INSERT INTO anjian_mysql(`id`,`neirong`) values('3','参数保存的不错就是有提示错误')")
//读取
Call mysql_list("select * from anjian_mysql")
Sub 按时进行
Do
NowTime = Time
TracePrint NowTime
SWTime = "19:45:20"//你要的设置的时间,也可作为变量随意
If Hour(SWTime) = Hour(NowTime) and Minute(SWTime) = Minute(NowTime) and Second(SWTime) = Second(NowTime) Then
Exit Do
End If
Delay 1000
Loop
MessageBox "开始执行了"
RunApp "www.ajjl.cn"
//或者用 RunApp "IEXPLORE.EXE"
Delay 1000
Rem 选择窗口
Hwnd = Plugin.Window.Foreground()
stemp=Plugin.Window.GetClass(Hwnd)
If stemp="IEFrame" then
MessageBox "接下来演示关闭网页"
Call Plugin.Window.CloseEx(Hwnd)
Else
Delay 300
Goto 选择窗口
End If
//或者用以下简单方法
Delay 2000
Call Plugin.Web.Bind("WQM.exe")
Call Plugin.Web.Go("www.ajjl.cn")
Delay 2000
MessageBox "接下来演示关闭网页"
Hwnd=Plugin.Web.GetHwnd()
Call Plugin.Window.Close(Hwnd)
End Sub