求ACCESS连接实例,找到的都不能用[已解决]
本帖最后由 左手2018 于 2019-5-28 15:35 编辑我电脑 win7 64位, SciTE3.6.1
我在论坛搜索了很多access的实例, 下载下来后都无法使用. 准确的说, 从一开始就无法生成*.mdb文件.
请给一个最简单的连接access的例子, 还是au3不再支持access了?
[问题已解决]
总结:
au3调用access的话, access.au3目前不建议大家使用,总是我试了半天都没试出来.
如果你的系统是64位(一般都是了), 代码前面请加: #AutoIt3Wrapper_UseX64=n ;
access软件附在office里,在win7以上版本, 插入office安装光盘(或虚拟光盘)后,请不要傻瓜安装. 请进入光盘目录, 右键setup.exe, 然后选择以管理员身份运行. 新版本的office其实可以选择64位或32位的office版本setup.exe .在光盘的office目录里可以选.(根目录里的setup.exe是32位的,留给懒人和小白的)
感谢论坛的w60711兄弟, 如果不是他我本来已经放弃access了.
我Win10
可以使用mdb的 建立 新增 修改 查询(范围列出) 删除
代码很乱,因为是临时修改手上的一份code出来给你参考用
所以没有很多时间做整理,将就看吧...
(代码结合了许ˋ多大神的例子,在此先感谢了~)
請將2份代碼合成一份,超出系統限制了...
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 载入Fuction |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <GUIConstants.au3>
#Include <GuiEdit.au3>
#include <GDIPlus.au3>
#include <MsgBoxConstants.au3>
#include <Crypt.au3>
#include <GuiMenu.au3>
#include <InetConstants.au3>
#include <WinAPIFiles.au3>
#include <TrayConstants.au3>
#include <Winapi.au3>
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 宣告变数 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Global $GUIWidth = 800 ;;介面宽
Global $GUILength = 600 ;;介面高
Global $fontsize=13, $font_xing=300, $font_var=Default, $font_name='Microsoft JhengHei' ;;全局字体及大小(备用字体:'Comic Sans Ms'、'YaHei Consolas Hybrid')
Global Const $Title = 'MDB示例' ;;软体名称
Global Const $Author = 'ACN Ex' ;;作者名称
Global Const $ver = '1.0.0.0' ;;版本号码
Global Const $Copyright = 'Copyright © ACN' ;;版权宣告
Global Const $mdb_data_pwd = '7eWQon8' ;;资料库密码
Global Const $AES_pwd = '9414IPx' ;;储存于资料库中之密码 加解密用金钥
Global Const $DBName = "db.mdb" ;;资料库档案名称
Global Const $DBData = "appData" ;;资料库中储存 本软体登入用帐密 之资料表
Global Const $DBEnterpriseTable = "Login" ;;资料库中储存 人物帐号密码 之资料表
Global Const $Clog = "Clog" ;;资料库中储存 纪录关闭前列出范围的选项 之资料表
Global Const $Other = "OtherSetting" ;;资料库中储存 杂项 之资料表
Global Const $text = '01.........................' & @CRLF & @CRLF & _ ;;帮助说明裡的文字
'02.........................................' & @CRLF & @CRLF & _
'03..........................................' & @CRLF & _
'........................................................'
Global $OSVOutput
Dim $label ;;钟隐 Fuction 相关变数
Dim $about_gui, $cPass_gui ;;关于视窗,变更密码视窗,捐赠作者视窗
Dim $EID ;;此为资料表中 每笔资料之 id
Dim $OldPassword,$NewPassword,$ConfirmPasswordAgain ;;本软体登入之密码修改视窗的Input:旧密码,新密码,新密码确认
;;第一次使用,游戏帐号密码的资料表是否为空,手动检查更新,完整视窗大小(判断上次使用纪录)
Dim $FirstUse = 0 , $EmptyDatabase = 0, $GuiFullSize
Global $iExStyle = ""
Global $MouseNotInListView
Global Const $TME_HOVER = 0x00000001
Global Const $TME_LEAVE = 0x00000002
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 资料库 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;假如没有资料库就建立资料库(mdb)
If Not FileExists ($DBName) Then
$newMdb = ObjCreate("ADOX.Catalog")
$newMdb.Create("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$newmdb.ActiveConnection.Close
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd) ;;建立mdb
;;建立 "表"
$addTbl.Execute("CREATE TABLE " & $DBData)
$addTbl.Execute("CREATE TABLE " & $DBEnterpriseTable)
$addTbl.Execute("CREATE TABLE " & $Clog)
$addTbl.Execute("CREATE TABLE " & $Other)
$addtbl.Close
;;建立 "栏名"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.Execute("ALTER TABLE " & $DBData & " ADD id identity(1, 1) primary key,name text(255) ,pass text(255) ,nickname text(255) ,Permission text(255)")
$addfld.Execute("ALTER TABLE " & $DBEnterpriseTable & " ADD id identity(1, 1) primary key,whos text(255) ,userid text(255) ,pass text(255) ,deputation text(255)" )
$addfld.Execute("ALTER TABLE " & $Clog & " ADD id identity(1, 1) primary key,whos text(255)" )
$addfld.Execute("ALTER TABLE " & $Other & " ADD id identity(1, 1) primary key,itemname text(255) ,ivalue text(255)" )
;;建立列出范围的预设值:All
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.Execute("insert into " & $Clog & " (whos) values('"&'All'&"')")
;;建立更新询问、视窗大小预设值
$addfld.Execute("insert into " & $Other & " (itemname,ivalue) values('"&'askUpadte'&"','"&'1'&"')")
$addfld.Execute("insert into " & $Other & " (itemname,ivalue) values('"&'getBeta'&"','"&'0'&"')")
$addfld.Execute("insert into " & $Other & " (itemname,ivalue) values('"&'guiSize'&"','"&'0'&"')")
;;首次登入时自动建立帐号Admin,密码为空
$FirstUse = 1
$SetName = 'admin'
$SetPass = ''
$a=StringSplit($SetPass,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$addfld.Execute("insert into " & $DBData & " (name,pass) values('"&$SetName&"','"&$ENCPass&"')")
$addfld.close
_newuseLogin()
Else ;;有资料库,检查后来追加表、栏位
;;
EndIf
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 登入验证视窗 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Opt("GUIOnEventMode",0);;使用消息模式
_login()
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| LIST样式 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE);<<<<<<<<<+++
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_DOUBLEBUFFER);<<<<<<<<<+++
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 判断是否有帐号资料 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If FileExists($DBName) Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From " & $DBEnterpriseTable )
$EmptyDatabase = 0
If $RS.eof And $RS.bof Then $EmptyDatabase = 1
EndIf
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 判断上次视窗是否展开 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $Other & " WHERE " & 'itemname' & " ='"&'guiSize'&"'") ;;完整查询语法
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
$GuiFullSize = $RS.Fields (2).value
$rs.movenext
WEnd
$rs.close
$addfld.Close
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 主UI |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Opt("TrayMenuMode",1);:启用选单
Opt("GUIOnEventMode",1);;使用事件模式
$Form1 = GUICreate($Title & ' v' & $ver,$GUIWidth,$GUILength,-1,-1) ;;帐号资料表有资料
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
GUISetBkColor(0xF0F0F0) ; 将变更背景色彩
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")
$menuFile = GUICtrlCreateMenu ( "档案 (&F)")
$cPassInMenuTab = GUICtrlCreateMenuItem("变更密码 (&P)", $menuFile)
GUICtrlSetOnEvent(-1, "_cPass")
$itemExitInMenuFile = GUICtrlCreateMenuItem("结束 (&X)", $menuFile)
GUICtrlSetOnEvent(-1, "AForm1Close")
$menuEdit2 = GUICtrlCreateMenu ( "编辑 (&E)")
$EditInMenuTab = GUICtrlCreateMenuItem("汇入资料 (&I)", $menuEdit2)
GUICtrlSetOnEvent(-1, "ImportWorkerTable")
$EditInMenuTab = GUICtrlCreateMenuItem("汇出资料 (&S)", $menuEdit2)
GUICtrlSetOnEvent(-1, "SaveCurrentWorkerTable")
$EditInMenuTab = GUICtrlCreateMenuItem("删除人员资料 (&N)", $menuEdit2)
GUICtrlSetOnEvent(-1, "Button6Click")
$menu2 = GUICtrlCreateMenu ( "悬浮 (&S)")
$menu2item1 = GUICtrlCreateMenuItem("开启 (&T)", $menu2,0,1)
GUICtrlSetOnEvent(-1, "_Topping")
$menu2item2 = GUICtrlCreateMenuItem("关闭 (&N)", $menu2,1,1)
GUICtrlSetOnEvent(-1, "_Topping")
$menuTab = GUICtrlCreateMenu ( "帮助 (&H)")
$DonateInMenuTab = GUICtrlCreateMenuItem("捐赠作者 (&D)", $menuTab)
$HelpInMenuTab = GUICtrlCreateMenuItem("说明 (&R)", $menuTab)
GUICtrlSetOnEvent(-1, "Readme")
$AboutInMenuTab = GUICtrlCreateMenuItem("关于 (&A)", $menuTab)
GUICtrlSetOnEvent(-1, "about")
;;---------- Start 关于本软体和下方资讯列 ----------
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$hStatus = _GUICtrlStatusBar_Create($Form1)
Local $a_PartsRightEdge =
_GUICtrlStatusBar_SetParts($hStatus, $a_PartsRightEdge)
_GUICtrlStatusBar_SetText($hStatus, $Title)
_GUICtrlStatusBar_SetText($hStatus, "Author:" & $Author, 1)
_GUICtrlStatusBar_SetText($hStatus, "Version:" & $ver, 2)
;~ 系统菜单添加
$nItem1 = CreateSystemMenuItem($Form1, "关于本软体(&A)", -1, False, 0)
;~ 移除菜单
RemoveMenu($Form1, $SC_SIZE)
RemoveMenu($Form1, $SC_MAXIMIZE)
RemoveMenu($Form1, $SC_RESTORE)
;~ 结束
;;---------- End 关于本软体和下方资讯列 ----------
Global $GUI1,$GUI2,$MainGUI,$ListView1,$ListView2
Global $Menu1, $menu2
Global Enum $MenuAdd = 1000, $MenuEdit, $MenuDel
$Menu1=_GUICtrlMenu_CreatePopup()
_GUICtrlMenu_InsertMenuItem($Menu1, 0, "新增 (Add)", $MenuAdd)
_GUICtrlMenu_SetItemBmp($Menu1, 0, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\imageres.dll', 246, 16, 16))
_GUICtrlMenu_InsertMenuItem($Menu1, 1, "编辑 (Edit)", $MenuEdit)
_GUICtrlMenu_SetItemBmp($Menu1, 1, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\imageres.dll', 289, 16, 16))
_GUICtrlMenu_InsertMenuItem($Menu1, 2, "删除 (Del)", $MenuDel)
_GUICtrlMenu_SetItemBmp($Menu1, 2, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\imageres.dll', 49, 16, 16))
GUICtrlCreateLabel('Edit',800,0,405,35,$SS_CENTER+$SS_SUNKEN)
GUICtrlSetBkColor(-1,0xDFDFDF)
GUICtrlSetFont(-1,$fontsize+5,700,$font_var,$font_name)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
Global $guitext1 = GUICtrlCreateLabel('范围:',815,57,100,30,$SS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
Global $Enterprise = GUICtrlCreateInput('',925,53,230,30,BitOR($SS_CENTER,$ES_AUTOHSCROLL))
GUICtrlSetTip(-1,"请输入您的暱称或名字",'',0,0)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetBkColor(-1,0xF7F7F7)
GUICtrlSetState(-1,$GUI_FOCUS) ;;预设光标所在位置
Global $guitext2 = GUICtrlCreateLabel('帐号:',815,97,100,30,$SS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
Global $Principal = GUICtrlCreateInput('',925,93,230,30,BitOR($SS_CENTER,$ES_AUTOHSCROLL))
GUICtrlSetTip(-1,"请输入您的NC帐号",'',0,0)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetBkColor(-1,0xF7F7F7)
Global $guitext3 = GUICtrlCreateLabel('密码:',815,137,100,30,$SS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
Global $TelPhone1 = GUICtrlCreateInput ('',925,133,230,30,BitOR($SS_CENTER,$ES_AUTOHSCROLL))
GUICtrlSetTip(-1,"请输入您的NC密码(密码明文显示方便阅读,但是以密文方式储存,请放心)",'',0,0)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetBkColor(-1,0xF7F7F7)
Global $guitext4 = GUICtrlCreateLabel('备注:',815,177,100,30,$SS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
Global $FaxPhone1 = GUICtrlCreateInput ('',925,173,230,30,BitOR($SS_CENTER,$ES_AUTOHSCROLL))
GUICtrlSetTip(-1,"请输入该帐号的备注",'',0,0)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetBkColor(-1,0xF7F7F7)
Global $guitext5 = GUICtrlCreateLabel('指定ID:',815,257,100,30,$SS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
Global $WID = GUICtrlCreateCombo('',925,253,100,25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetTip(-1,"如果您曾经删除过单笔资料,此处可以让您新增时,将资料写入空的资料库ID",'',0,0)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetFont( -1, $fontsize-2, $font_xing, $font_var, $font_name)
Global $Button2 = GUICtrlCreateButton('新增资料',885,300,100,35)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'Button2Click')
Global $Button10 = GUICtrlCreateButton('覆写资料',1025,300,100,35)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'Button10Click')
Global $Button1 = GUICtrlCreateButton('查询资料',845,370,80,35)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'Button1Click')
Global $Button3 = GUICtrlCreateButton('清空栏位',975,370,80,35)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'Button3Click')
Global $Button6 = GUICtrlCreateButton('全部删除',1105,370,80,35)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'Button6Click')
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlCreateLabel('列出范围:',2,117,100,30,$SS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
$Range = GUICtrlCreateCombo('All',102,114,150,25,BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
_whos()
GUICtrlSetOnEvent(-1,"_Range")
$Button8 = GUICtrlCreateButton('清除列表',265,114,100,30)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'Button8Click')
$Button9 = GUICtrlCreateLabel('开启编辑窗>',698,125,100,20,$BS_CENTER)
GUICtrlSetFont(-1,$fontsize,700,$font_var,$font_name)
GUICtrlSetColor(-1, 0X0094FF);;蓝色
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GuiCtrlSetCursor(-1, 0)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetOnEvent(-1,'sAdditem')
$ListView1 = GUICtrlCreateListView('',2,155,798,$GUILength-200)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_LV_ALTERNATE) ;;奇数行为listview的背景色,偶数行为listviewitem的背景色
GUICtrlSetBkColor(-1,0xF7F7F7)
GUICtrlSetFont( -1, $fontsize, $font_xing, $font_var, $font_name)
Dim $B_DESCENDING ;<==定义排序数组,必不可少
$iExStyle += $LVS_EX_GRIDLINES ; 项目和子项显示网格.
$iExStyle += $LVS_EX_FULLROWSELECT ; 项目选中时, 该项及其所有子项高亮显示.
_GUICtrlListView_SetExtendedListViewStyle($ListView1,$iExStyle)
GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
_GUICtrlListView_AddColumn($ListView1, '索引号', 75)
_GUICtrlListView_AddColumn($ListView1, '范围', 80)
_GUICtrlListView_AddColumn($ListView1, '帐号', 275)
_GUICtrlListView_AddColumn($ListView1, '备注', 340)
_GUICtrlListView_JustifyColumn($ListView1, 0, 2)
_GUICtrlListView_JustifyColumn($ListView1, 1, 2)
_GUICtrlListView_JustifyColumn($ListView1, 2, 2)
_GUICtrlListView_JustifyColumn($ListView1, 3, 2)
GUICtrlCreateGroup('Info',315,5,480,100)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlCreateLabel($Title,325,30,100,20,$BS_CENTER)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlSetFont(-1,$fontsize-2,700,$font_var,$font_name)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0X0094FF)
$NCLauncher = GUICtrlCreateLabel('',430,33,655,20)
GUICtrlSetFont(-1,$fontsize-4,700,$font_var,$font_name)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0X0094FF)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
_BasicInfo()
GUICtrlCreateLabel($OSVOutput, 325, 65)
GUICtrlSetFont(-1,$fontsize-4,700,$font_var,$font_name)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1,0X0094FF)
GUICtrlSetResizing(-1,$GUI_DOCKALL) ;;防止位移
GUICtrlCreateGroup('',-99,-99,1,1)
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") ;;关于
GUICtrlCreateLabel("", 0, 0, 645, 210, 0x04000000, 0x00100000)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY");<<<<<<<<<+++
;;LIST样式
Global $B_DESCENDING;<<<<<<<<<+++
If $EmptyDatabase = 1 Or $GuiFullSize = 1 Then sAdditem()
_Range()
;;以序号排序,要在读˙取完资料后再执行
_GUICtrlListView_RegisterSortCallBack($ListView1)
_GUICtrlListView_SortItems($ListView1, 0);以序号排序
_GUICtrlListView_UnRegisterSortCallBack($ListView1)
While 1
Sleep(50)
If _Hover($Form1,2,155,798,$GUILength-200) = 0 Then ;;如果鼠标超出了ListView范围,就取消ToolTip
If $MouseNotInListView = 0 Then ToolTip('')
$MouseNotInListView = 1 ;;是,不在ListView范围
Else
$MouseNotInListView = 0 ;;否,有在ListView范围
EndIf
WEnd
Func _Hover($cH_hWin = "", $Pos_X = 0, $Pos_Y = 0, $Pos_W = 0, $Pos_H = 0) ;;判断鼠标是否在ListView范围
$cH_Data = GUIGetCursorInfo($cH_hWin)
;~ TrayTip($cH_Data & " " & $cH_Data, $Pos_X & " + " & $Pos_X + $Pos_W & " " & $Pos_Y & " + " & $Pos_Y + $Pos_H,5)
If Not IsArray($cH_Data) Then Return SetError(10086)
If $cH_Data > $Pos_X And $cH_Data < $Pos_X + $Pos_W And $cH_Data > $Pos_Y And $cH_Data < $Pos_Y + $Pos_H Then
Return 1
Else
Return 0
EndIf
EndFunc
Func _BasicInfo()
;;---------- Start 取得系统版号 ----------
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", 0x30)
If IsObj($colItems) then
For $objItem In $colItems
$OSVOutput = $objItem.Caption & @CRLF & $objItem.Version & @CRLF
Next
Else
$OSVOutput = 'N/A'
Endif
;;---------- End 取得系统版号 ----------
EndFunc
Func sAdditem()
$ViewErrButtonText=GUICtrlRead($Button9)
$XY=WinGetPos($Form1) ;;取得Form1大小
if $ViewErrButtonText="<关闭编辑窗" Then
GUICtrlSetData($Button9, "开启编辑窗>")
GUICtrlSetColor ($Button9, 0X0094FF);;蓝色
$newX=$XY-405 ;;原始尺寸
WinMove($Form1,"",$XY,$XY,$newX,$XY) ;;改变视窗大小
$POS = WinGetPos($Form1) ;;取得改变后窗口大小
WinMove($Form1,'',(@DesktopWidth-$POS)/2,$XY) ;;将窗口水平置中
;;重置下方资讯栏
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$hStatus = _GUICtrlStatusBar_Create($Form1)
Local $a_PartsRightEdge =
_GUICtrlStatusBar_SetParts($hStatus, $a_PartsRightEdge)
_GUICtrlStatusBar_SetText($hStatus, $Title)
_GUICtrlStatusBar_SetText($hStatus, "Author:" & $Author, 1)
_GUICtrlStatusBar_SetText($hStatus, "Version:" & $ver, 2)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $Other & " setivalue='"&'0'&"' WHERE itemname" & " = '" & 'guiSize' & "'")
$addfld.close
Else
GUICtrlSetData($Button9, "<关闭编辑窗")
GUICtrlSetColor ($Button9, 0xFF0000);;红色
$newX=$XY+405 ;;延展视窗
WinMove($Form1,"",$XY,$XY,$newX,$XY) ;;改变视窗大小
$POS = WinGetPos($Form1) ;;取得改变后窗口大小
WinMove($Form1,'',(@DesktopWidth-$POS)/2,$XY) ;;将窗口水平置中
;;重置下方资讯栏
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
$hStatus = _GUICtrlStatusBar_Create($Form1)
Local $a_PartsRightEdge =
_GUICtrlStatusBar_SetParts($hStatus, $a_PartsRightEdge)
_GUICtrlStatusBar_SetText($hStatus, $Title)
_GUICtrlStatusBar_SetText($hStatus, "Author:" & $Author, 1)
_GUICtrlStatusBar_SetText($hStatus, "Version:" & $ver, 2)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $Other & " setivalue='"&'1'&"' WHERE itemname" & " = '" & 'guiSize' & "'")
$addfld.close
EndIf
EndFunc
Func Readme()
MsgBox(262144+64,'使用说明',$text)
EndFunc
呈上
Func _AES128($mode,$way,$data,$pass);;使用AES 256 加密解密
Switch $mode
Case 0;;加密
_Crypt_Startup()
Return_Crypt_EncryptData($data,$pass, $way)
Case 1;;解密
_Crypt_Startup()
Return_Crypt_DecryptData($data,$pass, $way)
EndSwitch
EndFunc
Func _whos();;找出有谁,放进选单
Dim $ClogID
Dim $YN = 'N'
$addfld = ObjCreate("ADODB.Connection");;<<++++++从DB取得上一次浏览范围
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $Clog )
while Not $RS.eof And Not $RS.bof
$ClogID = $RS.Fields (1).value
$rs.movenext
WEnd
$rs.close
$addfld.Close;;<<++++++从DB取得上一次浏览范围
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBEnterpriseTable )
GUICtrlSetData($Range,'All','All');;介面显示为All
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If StringInStr($RS.Fields (1).value,$ClogID) = 1 Then $YN = 'Y'
If $RS.Fields (1).value <> '' Then $str = $RS.Fields (1).value
If $RS.Fields (1).value = '' Then $str = 'N/A'
GUICtrlSetData($Range,$str,$ClogID)
$rs.movenext
WEnd
If $YN = 'Y' Then GUICtrlSetData($Range,$ClogID,$ClogID)
If $YN = 'N' Then GUICtrlSetData($Range,'All','All')
$rs.close
$addfld.Close
EndFunc
Func _Range()
$ReadRange = GUICtrlRead($Range)
$SerchItem = "whos"
$CValue = '1'
$addfld = ObjCreate("ADODB.Connection");;<<+++++++纪录选择的范围到DB
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $Clog & " setwhos='"&$ReadRange&"' WHERE id" & " = " & $CValue)
$addfld.close;;<<+++++++纪录选择的范围到DB
GUICtrlSendMsg($ListView1,$LVM_DELETEALLITEMS,0,0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
If $ReadRange = "All" Then;;列出全部
$RS.Open ("Select * From " & $DBEnterpriseTable )
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If $RS.Fields (2).value = '' Or $RS.Fields (2).value = Null Or $RS.Fields (2).value = False Then
;;
Else
GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1 )
GUICtrlSetBkColor (-1,0xE9E9E9) ;;设置 偶数行项目背景颜色
EndIf
$rs.movenext
WEnd
Else;;列出指定主人
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & $SerchItem & " ='"&$ReadRange&"'") ;;完整查询语法
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1)
GUICtrlSetBkColor (-1,0xE9E9E9) ;;设置 偶数行项目背景颜色
$rs.movenext
WEnd
EndIf
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
EndFunc
Func _Password();变更密码
$ROldPass = GUICtrlRead($OldPassword)
$RNewPass = GUICtrlRead($NewPassword)
$RCNewPass = GUICtrlRead($ConfirmPasswordAgain)
$Value = '1' ;;密码 所在的 ID
If $FirstUse = 0 Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBData )
$DBTEXT = $RS.Fields (2).value
$rs.close
$addfld.Close
EndIf
If $FirstUse = 0 Then
$a=StringSplit($ROldPass,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
EndIf
If $FirstUse = 0 Then
If $ENCPass <> $DBTEXT Then
MsgBox(262144+48,'错误','输入的原始密码错误!请重新再试一次。',$MB_OK)
Return
EndIf
EndIf
If $RNewPass <> $RCNewPass Then
MsgBox(262144+48,'错误','输入的两次新密码不相符!请确认后重试。',$MB_OK)
Return
EndIf
$a=StringSplit($RNewPass,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$addfld = ObjCreate("ADODB.Connection");;<<+++++++纪录选择的范围到DB
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $DBData & " setpass='"&$ENCPass&"' WHERE id" & " = " & $Value)
$addfld.close;;<<+++++++纪录选择的范围到DB
If $FirstUse = 0 Then
MsgBox(262144+64,'完成','已更新密码!请以新密码重新登入。',5,$MB_OK)
Exit
Else
$FirstUse = 0
EndIf
EndFunc
Func AForm1Close() ;;关闭本程序
If WinExists("关于 "&$Title & ' v' & $ver) Then
GUIDelete($About_gui)
Return 0
Else
If MsgBox(262144+36, "", "确定要退出吗?") = 6 Then
Exit
EndIf
EndIf
EndFunc
Func Button1Click();;查询资料
GUICtrlSetState($Button1,$GUI_DISABLE)
Serch()
GUICtrlSetState($Button1,@SW_ENABLE)
EndFunc
Func Button3Click();;清空栏位
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
GUICtrlSetData($WID,'')
GUICtrlSetState($Enterprise,$GUI_FOCUS) ;;预设光标所在位置
EndFunc
Func Button6Click();;全部删除(删除资料表,可用做索引号重置)
GUICtrlSetState($Button6,$GUI_DISABLE)
$MSGCheck = MsgBox(32+4,'警告','您确定要删除所有帐号资料吗?' & @CRLF & @CRLF & "此操作不能回復,请谨慎使用。" )
If $MSGCheck = 6 Then
DeleteWorkerTable()
Else
Return
EndIf
GUICtrlSetState($Button6,@SW_ENABLE)
Return
EndFunc
Func _runL2()
MsgBox(0,0,'run')
EndFunc
Func Button8Click();;清除列表
GUICtrlSetState($Button8,$GUI_DISABLE)
Clear()
GUICtrlSetState($Button8,@SW_ENABLE)
EndFunc
Func Button9Click ();;复製资料
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
If $Strnspin='0' Then
MsgBox(48,'错误','您没有选择任一项目!')
Return
Else
dataup()
EndIf
EndFunc
Func Button10Click ();;覆写资料
$ReadPrincipal = GUICtrlRead($Principal)
$ReadTelPhone1 = GUICtrlRead($TelPhone1)
GUICtrlSetState($Button10,$GUI_DISABLE)
$RWID = GUICtrlRead($WID)
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
If $ReadPrincipal = '' Then
MsgBox(48,'错误','NC帐号为必填项目!')
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
If StringIsDigit($RWID) = 1 Then;;是否仅包含数字
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & " ID = " & $RWID)
$MSGCheck = MsgBox(32+4,'[编辑] - 警告','您确定将资料写入此ID位置吗?' & @CRLF & @CRLF & "索引号:" & $RS.Fields (0).value & @CRLF & "帐号:" & $RS.Fields (2).value & @CRLF & "备注:" & $RS.Fields (2).value )
$rs.close
$addfld.Close
If $MSGCheck = 6 Then
back()
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
ElseIf $Strnspin='0' Then
MsgBox(48,'错误','您没有选择任一项目!')
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
If $EID = Null Then
$MSGCheck = MsgBox(32+4,'[覆写] - 警告','您确定要覆写到该笔资料吗?' & @CRLF & @CRLF & "索引号:" & $Strnspin & @CRLF & "帐号:" & $Strnspin & @CRLF & "备注:" & $Strnspin )
If $MSGCheck = 6 Then
back()
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
EndIf
If $EID <> Null Then
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & " ID = " & $EID) ;;模煳查询语法
$MSGCheck = MsgBox(32+4,'[编辑] - 警告','您确定要完成编辑本笔资料吗?' & @CRLF & @CRLF & "索引号:" & $RS.Fields (0).value & @CRLF & "帐号:" & $RS.Fields (2).value & @CRLF & "备注:" & $RS.Fields (4).value )
$rs.close
$addfld.Close
If $MSGCheck = 6 Then
back()
$EID = Null
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
$MSGCheckA = MsgBox(32+4,'[编辑] - 警告','那您要更新资料到所选项吗?' & @CRLF & @CRLF & "索引号:" & $Strnspin & @CRLF & "帐号:" & $Strnspin & @CRLF & "备注:" & $Strnspin)
If $MSGCheckA = 6 Then
$EID = Null
back()
GUICtrlSetState($Button10,@SW_ENABLE)
Return
Else
GUICtrlSetState($Button10,@SW_ENABLE)
Return
EndIf
EndIf
EndIf
EndIf
EndFunc
Func Button11Click ();;删除所选项目
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$MSGCheck = MsgBox(32+4,'警告','您定要删除该笔资料吗?' & @CRLF & @CRLF & "索引号:" & $Strnspin & @CRLF & "帐号:" & $Strnspin & @CRLF & "备注:" & $Strnspin )
If $MSGCheck = 6 Then
del()
Else
Return
EndIf
EndFunc
Func read();;读取资料到LIST
GUICtrlSendMsg($ListView1, $LVM_DELETEALLITEMS, 0, 0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBEnterpriseTable )
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
If $RS.Fields (2).value = '' Or $RS.Fields (2).value = Null Or $RS.Fields (2).value = False Then
;;
Else
GUICtrlCreateListViewItem ( $RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1 )
EndIf
$rs.movenext
WEnd
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
$EID = Null
_whos()
_SerchNull()
EndFunc
Func _SerchNull();;搜索没有资料的ID
Local $L
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & 'userid IS NULL OR' & " userid = ''")
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
$L = $L & '|' & $RS.Fields (0).value
$rs.movenext
WEnd
GUICtrlSetData($WID,'' & '|'& $L,'')
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
EndFunc
Func del();;删除项目(屏蔽/保留索引号)
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$NULL = ''
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.execute("update " & $DBEnterpriseTable & " setwhos='"&$NULL&"',userid='"&$NULL&"',pass='"&$NULL&"',deputation='"&$NULL&"' WHERE id" & " = " & $Strnspin)
$addfld.close
read()
EndFunc
Func dataup();;复製所选资料到编辑窗格
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBEnterpriseTable &" WHERE id" & " = " & $Strnspin)
$a=StringSplit(BinaryToString(_AES128(1,$CALG_AES_128,$RS.Fields (3).value,$AES_pwd)),"|",2);;<<++++++解密DEC
For $i=0 To UBound($a)-1
$a[$i]=ChrW($a[$i])
Next
$UserPass=""
For $i=0 To UBound($a)-1
$UserPass=$UserPass&$a[$i]
Next;;<<++++++解密DEC
GUICtrlSetData($Enterprise,$RS.Fields (1).value)
GUICtrlSetData($Principal,$RS.Fields (2).value)
GUICtrlSetData($TelPhone1,$UserPass)
GUICtrlSetData($FaxPhone1,$RS.Fields (4).value)
$rs.movenext
$rs.close
$addfld.Close
EndFunc
Func back();;复写(更新)所选项目的资料
$ReadEnterprise = GUICtrlRead($Enterprise)
If $ReadEnterprise = '' Then $ReadEnterprise = 'N/A'
$ReadPrincipal = GUICtrlRead($Principal)
$ReadTelPhone1 = GUICtrlRead($TelPhone1);;<<++++++加密ENC
$a=StringSplit($ReadTelPhone1,"",2)
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$UserPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$ReadFaxPhone1 = GUICtrlRead($FaxPhone1)
$RWID = GUICtrlRead($WID)
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
If StringIsDigit($RWID) = 1 Then;;$WID= 指定写入ID,=1 >>> 有数字 非空白
$addfld.execute("update " & $DBEnterpriseTable & " setwhos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $RWID)
ElseIf $EID <> Null Then
$addfld.execute("update " & $DBEnterpriseTable & " setwhos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $EID)
ElseIf $EID = Null Then
$addfld.execute("update " & $DBEnterpriseTable & " setwhos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $Strnspin)
Else
$addfld.execute("update " & $DBEnterpriseTable & " setwhos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $Strnspin)
EndIf
$addfld.close
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
GUICtrlSetData($WID,'')
_Range()
EndFunc
Func Serch();;搜索(支援模煳搜索)
$ReadFaxPhone1 = GUICtrlRead($FaxPhone1);;备注
$ReadEnterprise = GUICtrlRead($Enterprise);;主人
$ReadPrincipal = GUICtrlRead($Principal);;帐号
;;SQL万用字元查询,将单独的特殊字元[]起来,才能不出错,新增*查询。用法:**%%__
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '[' Then $ReadEnterprise = '[[]'
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '_' Then $ReadEnterprise = ''
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '%' Then $ReadEnterprise = '[%]'
If StringLen($ReadEnterprise) = 1 And $ReadEnterprise = '*' Then $ReadEnterprise = '[%]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '[' Then $ReadPrincipal = '[[]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '_' Then $ReadPrincipal = ''
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '%' Then $ReadPrincipal = '[%]'
If StringLen($ReadPrincipal) = 1 And $ReadPrincipal = '*' Then $ReadPrincipal = '[%]'
;;文字内包含万用字元查询,字串裡含有万用字元,且长度不等于1,进行替换
If StringRegExp($ReadEnterprise,'[') = 0 And StringLen($ReadEnterprise) <> 1 Then $ReadEnterprise = StringReplace($ReadEnterprise,'[','[[]')
If StringRegExp($ReadEnterprise,'*') = 0 And StringLen($ReadEnterprise) <> 1 Then $ReadEnterprise = StringReplace($ReadEnterprise,'*','%')
If StringRegExp($ReadPrincipal,'[') = 0 And StringLen($ReadPrincipal) <> 1 Then $ReadPrincipal = StringReplace($ReadPrincipal,'[','[[]')
If StringRegExp($ReadPrincipal,'*') = 0 And StringLen($ReadPrincipal) <> 1 Then $ReadPrincipal = StringReplace($ReadPrincipal,'*','%')
If $ReadFaxPhone1 = "" And $ReadEnterprise = "" And $ReadPrincipal = "" Then
MsgBox( 48 , "错误" , "您无输入搜寻条件!" )
Return
ElseIf $ReadEnterprise = "" And $ReadPrincipal = "" Then
$SerchItem = "deputation"
$InputItem = $ReadFaxPhone1
ElseIf $ReadFaxPhone1 = "" And $ReadPrincipal = "" Then
$SerchItem = "whos"
$InputItem = $ReadEnterprise
ElseIf $ReadFaxPhone1 = "" And $ReadEnterprise = "" Then
$SerchItem = "userid"
$InputItem = $ReadPrincipal
Else
MsgBox( 48 , "错误" , "搜寻条件一次只能为一个!" )
Return
EndIf
GUICtrlSendMsg($ListView1,$LVM_DELETEALLITEMS,0,0)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection =$addfld
$RS.Open ("Select * From "& $DBEnterpriseTable & " WHERE " & $SerchItem & " like'%"&$InputItem&"%'") ;;模煳查询语法
GUISetState(@SW_LOCK,$Form1);;锁定,可让TAB裡的LIST读取较快较不闪烁
while Not $RS.eof And Not $RS.bof
if @error =1 Then ExitLoop
GUICtrlCreateListViewItem($RS.Fields (0).value&"|"& $RS.Fields (1).value&"|"& $RS.Fields (2).value&"|"& $RS.Fields (4).value,$ListView1)
$rs.movenext
WEnd
GUISetState(@SW_UNLOCK,$Form1);;解除锁定
$rs.close
$addfld.Close
EndFunc
Func Clear();;清空列表
GUICtrlSendMsg($ListView1,$LVM_DeleteALLITEMS,0,0) ;;清空列表
EndFunc
Func DeleteWorkerTable();;删除并重建帐号资料表
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.Execute("DROP TABLE " & $DBEnterpriseTable);;删除帐号记录的表
$addtbl = ObjCreate("ADODB.Connection")
$addTbl.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
;;建立 "表"
$addTbl.Execute("CREATE TABLE " & $DBEnterpriseTable);;建立帐号记录的表
;;建立 "栏(位)名"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$addfld.Execute("ALTER TABLE " & $DBEnterpriseTable & " ADD id identity(1, 1) primary key,whos text(255) ,userid text(255) ,pass text(255) ,deputation text(255)" )
$addfld.Close
read()
MsgBox(64,"完成","已成功删除并重建帐号资料表!")
Return
EndFunc
Func Button2Click() ;;将资料写入(新增进)资料库
$ReadPrincipal = GUICtrlRead($Principal)
$ReadTelPhone1 = GUICtrlRead($TelPhone1)
GUICtrlSetState($Button2,$GUI_DISABLE)
;;读取输入的值
$ReadEnterprise = GUICtrlRead($Enterprise)
If $ReadEnterprise = '' Then $ReadEnterprise = 'N/A'
$ReadFaxPhone1 = GUICtrlRead($FaxPhone1)
$RWID = GUICtrlRead($WID)
$a=StringSplit($ReadTelPhone1,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$UserPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
;;输出资料至DB
If $ReadPrincipal <> '' Then ;;判断"范围"是否为空
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
If $RWID = '' Then $addfld.Execute("insert into "&$DBEnterpriseTable&" (whos,userid,pass,deputation) values('"&$ReadEnterprise&"','"&$ReadPrincipal&"','"&$UserPass&"','"&$ReadFaxPhone1&"')")
If $RWID <> '' Then
$MSGCheck = MsgBox(32+4,'警告','您确定要新增该笔资料至 索引号:' & $RWID & ' 吗?')
If $MSGCheck = 6 Then
$addfld.execute("update " & $DBEnterpriseTable & " setwhos='"&$ReadEnterprise&"',userid='"&$ReadPrincipal&"',pass='"&$UserPass&"',deputation='"&$ReadFaxPhone1&"' WHERE id" & " = " & $RWID)
Else
GUICtrlSetState($Button2,@SW_ENABLE)
Return
EndIf
EndIf
$addfld.close
_whos()
_Range()
GUICtrlSetData($Enterprise,'')
GUICtrlSetData($Principal,'')
GUICtrlSetData($TelPhone1,'')
GUICtrlSetData($FaxPhone1,'')
GUICtrlSetState($Enterprise,$GUI_FOCUS) ;;预设光标所在位置
Else
MsgBox(48,'错误','范围为必填项目!')
GUICtrlSetState($Enterprise,$GUI_FOCUS)
EndIf
GUICtrlSetState($Button2,@SW_ENABLE)
EndFunc
;登录选项窗体(by Flyself)
Func _login()
Local $errorNumber = 0, $dbuserName, $dbuserPass
Global $NONEAACTIVECOLOR = 0x9898f8
Global $MARK_1 = 0
;登录窗体
Local $Form_login = GUICreate("登入介面", 300, 195,-1,-1,$WS_CAPTION + $WS_POPUP + $WS_SYSMENU)
GUICtrlCreateLabel('欢迎使用 '&$Title, 0, 15, 300, 25, $SS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);;控件透明
GUICtrlSetFont(-1,$fontsize+1,$font_xing,$font_var,$font_name)
GUICtrlSetColor(-1,0x1260FF)
Local $login_Label1 = GUICtrlCreateLabel("帐号", 20, 55, 55, 20, $SS_RIGHT)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_Input1 = GUICtrlCreateInput("admin", 85, 50, 115, 24)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_Label2 = GUICtrlCreateLabel("密码", 20, 100, 55, 20, $SS_RIGHT)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_Input2 = GUICtrlCreateInput("", 85, 95, 115, 24, $ES_PASSWORD)
GUICtrlSetState(-1,$GUI_FOCUS) ;;预设光标所在位置
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
Local $login_ok = GUICtrlCreateButton("登入", 50, 145, 75, 25, $BS_DEFPUSHBUTTON)
Local $login_cancel = GUICtrlCreateButton("取消", 175, 145, 75, 25)
GUICtrlCreateLabel("预设:admin", 210, 55, 120, 17)
GUICtrlSetColor(-1, 0x3399FF)
GUICtrlCreateLabel("预设:空", 210, 100, 120, 17)
GUICtrlSetColor(-1, 0x3399FF)
GUISetState(@SW_SHOW, $Form_login)
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $login_cancel
Exit
Case $login_ok ;登录用户进入主窗体
$puser = GUICtrlRead($login_Input1)
$ppassword = GUICtrlRead($login_Input2)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $DBName & ";Jet Oledb:Database Password="&$mdb_data_pwd)
$RS =ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open ("Select * From " & $DBData )
$a=StringSplit($ppassword,"",2);;<<++++++加密ENC
For $i=0 To UBound($a)-1
$a[$i]=AscW($a[$i])
Next
$b=""
For $i=0 To UBound($a)-1
$b=$b&$a[$i]&"|"
Next
$ENCPass = _AES128(0,$CALG_AES_128,$b,$AES_pwd);;<<++++++加密ENC
$dbuserName = $RS.Fields(1).value
$dbuserPass = $RS.Fields(2).value
$rs.close
$addfld.Close
If $puser = '' Then
$dbuserName = Null
$dbuserPass = Null
MsgBox(48,'错误','请输入帐号!',$MB_OK)
GUICtrlSetData($login_Input2, "")
ElseIf $puser <> $dbuserName And $ENCPass <> $dbuserPass Then
$dbuserName = Null
$dbuserPass = Null
$errorNumber += 1
GUICtrlSetData($login_Input2, "")
If $errorNumber = 3 Then
MsgBox(16,'错误','输入的帐号或密码错误次数过多,将关闭本软体!',$MB_OK)
Exit
Else
MsgBox(48,'错误','输入的帐号或密码错误!请重新再试一次。',$MB_OK)
EndIf
ElseIf $puser = $dbuserName And $ENCPass = $dbuserPass Then
$dbuserName = Null
$dbuserPass = Null
GUISetState(@SW_HIDE, $Form_login)
Return 1
Else
$dbuserName = Null
$dbuserPass = Null
$errorNumber += 1
GUICtrlSetData($login_Input2, "")
If $errorNumber = 3 Then
MsgBox(16,'错误','输入的帐号或密码错误次数过多,将关闭本软体!',$MB_OK)
Exit
Else
MsgBox(48,'错误','输入的帐号或密码错误!请重新再试一次。',$MB_OK)
EndIf
EndIf
EndSwitch
WEnd
EndFunc ;==>_login
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam);<<<<<<<<<+++LISTVIEW
;;右键菜单
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView1,$hWndListView2, $SelectedID, $hWndTab
$hWndListView1 = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView1 = GUICtrlGetHandle($ListView1)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $ListView1
If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
;;双击判断,感谢 "漠北雪~狼"
Case $NM_CLICK ; 左击
;;
Case $NM_DBLCLK ; 双击
$Index = _GUICtrlListView_GetSelectedIndices($ListView1)
If Not StringLen($Index) Then; 这里用以判断是否选定了ListViewItem
;;MsgBox(0, "", "未选定")
Return
EndIf
_runL2()
Case $NM_RCLICK ; 右击
If _GUICtrlListView_GetSelectedIndices($hWndListView1) = "" Then
_GUICtrlMenu_SetItemDisabled($Menu1, 1)
_GUICtrlMenu_SetItemDisabled($Menu1, 2)
Else
_GUICtrlMenu_SetItemEnabled($Menu1, 1)
_GUICtrlMenu_SetItemEnabled($Menu1, 2)
EndIf
$SelectedID = _GUICtrlMenu_TrackPopupMenu($Menu1, $hWndListView1, -1, -1, 1, 1, 2)
If $SelectedID = $MenuAdd Then;;新增
If GUICtrlRead($Button9) = '开启编辑窗>' Then
sAdditem()
If GUICtrlRead($Principal) = '' Then Return
EndIf
Button2Click()
EndIf
If $SelectedID = $MenuEdit Then;;编辑
If GUICtrlRead($Button9) = '开启编辑窗>' Then
sAdditem()
EndIf
$Strn=GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin=StringSplit($Strn,"|")
$EID = $Strnspin
dataup();;复製资料到编辑框
EndIf
If $SelectedID = $MenuDel Then;;删除
Button11Click()
EndIf
Case $LVN_HOTTRACK ;;滑鼠经过事件
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $HotItem = _GUICtrlListView_GetHotItem($ListView1) ;;列
If$HotItem <>-1 Then
$SubItem=DllStructGetData($tInfo, "SubItem")
If $SubItem = 3 Then
ToolTip(_GUICtrlListView_GetItemText ($ListView1,$HotItem,$SubItem))
$MouseNotInListView = 0
Else
If $MouseNotInListView = 0 Then ToolTip("")
$MouseNotInListView = 1
EndIf
Else
If $MouseNotInListView = 0 Then ToolTip("")
$MouseNotInListView = 1
EndIf
Case $NM_DBLCLK
If _GUICtrlListView_GetSelectedIndices($hWndListView1) <> "" Then MsgBox(0,"","您点击了编辑")
Case $LVN_COLUMNCLICK ; A column was clicked
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
_DebugPrint("$LVN_COLUMNCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
_GUICtrlListView_SimpleSort($hWndListView, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
; No return value
Case $LVN_KEYDOWN ; A key has been pressed
$tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
_DebugPrint("$LVN_KEYDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @LF & _
"-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
; No return value
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_KILLFOCUS ; The control has lost the input focus
_DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
;Return 1 ; not to allow the default processing
Return 0 ; allow the default processing
Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
_DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
Case $NM_SETFOCUS ; The control has received the input focus
_DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint
;;----------Start 程式下方的资讯列所用涵式,出自作者:钟隐(mysql查询) ----------
Func CreateSystemMenuItem($hWin, $sText, $hMenu = -1, $bIsPopup = False, $nPos = 0xFFFFFFFF); 0xFFFFFFFF means "insert at the end"
If $hMenu = -1 Then $hMenu = GetSystemMenu($hWin, 0)
Local $nID = GUICtrlCreateDummy()
Local $nFlags = 0
If $sText = "" Then
$nFlags = $MF_SEPARATOR
ElseIf $bIsPopup Then
$nID = CreatePopupMenu()
$nFlags = $MF_POPUP
EndIf
$nFlags = BitOR($MF_BYPOSITION, $nFlags)
$nResult = InsertMenu($hMenu, $nPos, $nFlags, $nID, $sText)
Return $nID
EndFunc ;==>CreateSystemMenuItem
Func RemoveMenu($hWin, $SYSCOMMAND)
$dSysMenu = DllCall("User32.dll", "hwnd", "GetSystemMenu", "hwnd", $hWin, "int", 0)
$hSysMenu = $dSysMenu
DllCall("User32.dll", "int", "RemoveMenu", "hwnd", $hSysMenu, "int", $SYSCOMMAND, "int", 0)
DllCall("User32.dll", "int", "DrawMenuBar", "hwnd", $hWin)
EndFunc
Func CreatePopupMenu()
Local $hMenu = DllCall("user32.dll", "hwnd", "CreatePopupMenu")
Return $hMenu
EndFunc ;==>CreatePopupMenu
Func CheckMenuItem($hMenu, $nID, $nFlags)
DllCall("user32.dll", "int", "CheckMenuItem", _
"hwnd", $hMenu, _
"int", $nID, _
"int", $nFlags)
EndFunc ;==>CheckMenuItem
Func GetSystemMenu($hWnd, $bRevert)
Local $hMenu = DllCall("user32.dll", "hwnd", "GetSystemMenu", _
"hwnd", $hWnd, _
"int", $bRevert)
Return $hMenu
EndFunc ;==>GetSystemMenu
Func InsertMenu($hMenu, $nPosition, $nFlags, $nIDNewItem, $lpNewItem)
Local $nResult = DllCall("user32.dll", "int", "InsertMenu", _
"hwnd", $hMenu, _
"int", $nPosition, _
"int", $nFlags, _
"int", $nIDNewItem, _
"str", $lpNewItem)
Return $nResult
EndFunc ;==>InsertMenu
Func _newuseLogin()
;登录窗体
Local $Form_newuseLogin = GUICreate("密码设定", 470, 260,-1, -1)
GUISetBkColor(0xFFF0F5)
GUICtrlCreateLabel('密码预设为空,建议设定密码,以保护资料安全', 20, 35, 430, 25, $SS_CENTER)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT);;控件透明
GUICtrlSetFont(-1,$fontsize+1,$font_xing,$font_var,$font_name)
GUICtrlSetColor(-1,0x1260FF)
GUICtrlCreateLabel('新用户密码:',40,95,115,25)
$NewPassword = GUICtrlCreateInput('',155,88,250,25,$ES_PASSWORD)
If $FirstUse = 1 Then GUICtrlSetState($NewPassword,$GUI_FOCUS) ;;预设光标所在位置
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
GUICtrlCreateLabel('确认用户密码:',40,140,115,25)
$ConfirmPasswordAgain = GUICtrlCreateInput('',155,133,250,25,$ES_PASSWORD)
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
$login_ok = GUICtrlCreateButton('设定新密码',185,190,100,30,$BS_DEFPUSHBUTTON)
GUICtrlCreateGroup('',-99,-99,1,1)
GUICtrlCreateLabel("", 0, 0, 470, 280, 0x04000000, 0x00100000)
GUISetState(@SW_SHOW, $Form_newuseLogin)
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
GUIDelete($Form_newuseLogin)
Return 1
Case $login_ok
_Password()
GUIDelete($Form_newuseLogin)
Return 1
EndSwitch
WEnd
EndFunc
Func _cPass()
If BitAND(WinGetState($cPass_gui, ""), 2) And IsHWnd($cPass_gui) Then
GUIDelete($cPass_gui)
Return 0
EndIf
$XY=WinGetPos($Form1) ;;取得Form1大小
If BitAND(WinGetState($Form1), 2) Then
$size = WinGetPos($Form1)
$cPass_gui = GUICreate("密码设定", 470, 260, ($XY-470)/2, ($XY-260)/5, -1, 0x00000040 + 0x00000010 + 0x00000080, $Form1)
GUISetBkColor(0xFFF0F5)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
Else
$cPass_gui = GUICreate("密码设定", 470, 260, ($XY-470)/2, ($XY-260)/5, -1, 0x00000040 + 0x00000010 + 0x00000080)
GUISetBkColor(0xFFF0F5)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
EndIf
GUISetOnEvent(-3, "main")
GUICtrlCreateGroup('密码设定',20,20,430,200)
GUICtrlCreateLabel('旧用户密码:',40,50,125,25)
$OldPassword = GUICtrlCreateInput('',180,48,250,25,$ES_PASSWORD)
GUICtrlSetState(-1,$GUI_FOCUS) ;;预设光标所在位置
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
If $FirstUse = 1 Then GUICtrlSetState($OldPassword,@SW_DISABLE)
GUICtrlCreateLabel('新用户密码:',40,90,125,25)
$NewPassword = GUICtrlCreateInput('',180,88,250,25,$ES_PASSWORD)
If $FirstUse = 1 Then GUICtrlSetState($NewPassword,$GUI_FOCUS) ;;预设光标所在位置
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
GUICtrlCreateLabel('确认用户密码:',40,130,125,25)
$ConfirmPasswordAgain = GUICtrlCreateInput('',180,128,250,25,$ES_PASSWORD)
;;GUICtrlSetBkColor(-1,0x00FFFFF5)
GUICtrlCreateButton('变更密码',40,170,100,30,$BS_DEFPUSHBUTTON)
GUICtrlSetOnEvent(-1,'_Password')
GUICtrlCreateGroup('',-99,-99,1,1)
GUICtrlCreateLabel("", 0, 0, 470, 280, 0x04000000, 0x00100000)
GUISetState(@SW_SHOWNOACTIVATE, $cPass_gui)
EndFunc
Func about();关于窗口
If BitAND(WinGetState($About_gui, ""), 2) And IsHWnd($About_gui) Then
GUIDelete($About_gui)
Return 0
EndIf
$XY=WinGetPos($Form1) ;;取得Form1大小
If BitAND(WinGetState($Form1), 2) Then
$size = WinGetPos($Form1)
$About_gui = GUICreate("关于 "&$Title & ' v' & $ver, 670, 220, ($XY-670)/2, ($XY-220)/5, -1, 0x00000040 + 0x00000010 + 0x00000080, $Form1)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
GUISetBkColor(0xFFF0F5)
Else
$About_gui = GUICreate("关于 "&$Title & ' v' & $ver, 670, 220, ($XY-670)/2, ($XY-220)/5, -1, 0x00000040 + 0x00000010 + 0x00000080)
GUISetFont($fontsize,$font_xing,$font_var,$font_name) ;;全局字型
GUISetBkColor(0xFFF0F5)
EndIf
GUISetOnEvent(-3, "main")
Global $guitext6 = GUICtrlCreateLabel("软体名称:"&$Title, 160, 50, 390, 30)
GUICtrlSetFont(-1, 16, 600)
GUICtrlSetColor(-1, 0x800080)
Global $guitext7 = GUICtrlCreateLabel("作者:"&$Author, 160, 90, 390, 20)
GUICtrlSetFont(-1, 10, 300)
GUICtrlSetColor(-1, 0xFF00FF)
Global $guitext8 = GUICtrlCreateLabel("版本:" & $ver, 160, 110, 390, 20)
GUICtrlSetFont(-1, 10, 300)
GUICtrlSetColor(-1, 0x808080)
GUICtrlCreateLabel($Copyright, 160, 130, 505, 20)
GUICtrlSetFont(-1, 10, 300)
GUICtrlSetColor(-1, 0x808080)
GUISetState(@SW_SHOWNOACTIVATE, $About_gui)
EndFunc ;==>about
Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
$nID = BitAND($wParam, 0x0000FFFF)
Switch $nID
Case $nItem1
about()
EndSwitch
EndFunc ;==>WM_SYSCOMMAND
Func main()
Switch @GUI_CtrlId
Case -3
Switch @GUI_WinHandle
Case $about_gui
GUIDelete($about_gui)
Case $cPass_gui
GUIDelete($cPass_gui)
EndSwitch
EndSwitch
EndFunc
;;----------End 程式下方的资讯列所用涵式,出自作者:钟隐(mysql查询) ----------
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| Input浮水说明文字 |
;;| 作者:钟隐(mysql查询) |
;;| 网址: |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Func _CheckInput($hWnd, $ID, $InputDefText, ByRef $DefaultInputData, ByRef $Mark)
If $Mark = 0 And _IsFocused($hWnd, $ID) And $DefaultInputData = $InputDefText Then
$Mark = 1
GUICtrlSetData($ID, "")
GUICtrlSetColor($ID, 0x000000)
$DefaultInputData = ""
ElseIf $Mark = 1 And Not _IsFocused($hWnd, $ID) And $DefaultInputData = "" And GUICtrlRead($ID) = "" Then
$Mark = 0
$DefaultInputData = $InputDefText
GUICtrlSetData($ID, $DefaultInputData)
GUICtrlSetColor($ID, $NONEAACTIVECOLOR)
EndIf
EndFunc ;==>_CheckInput
Func _IsFocused($hWnd, $nCID)
Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc ;==>_IsFocused
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| 使用API将窗体保持最前 |
;;| 作者:健啖客WTohrV |
;;| 网址:http://www.manew.com/blog-166183-23254.html |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Func _SetWindowPos($hWnd,$x,$y,$cX,$cY,$hWndInsertAfter = -1,$wFlags = 1)
;使用API将窗体保持最前 x,y -->>座标 $hWndInsertAfter >> Z位置、深度(3D)
DllCall("user32.dll","long","SetWindowPos","long",$hWnd,"long",$hWndInsertAfter,"long",$x,"long",$y,"long",$cX,"long",$cY,"long",$wFlags)
EndFunc;==>_SetWindowPos
;;Yashied
;;https://www.autoitscript.com/forum/topic/97365-how-to-convert-a-hicon-to-a-32-bit-hbitmap/?do=findComment&comment=700670
Func _CreateBitmapFromIcon($iBackground, $sIcon, $iIndex, $iWidth, $iHeight)
Local $hDC, $hBackDC, $hBackSv, $hIcon, $hBitmap
$hDC = _WinAPI_GetDC(0)
$hBackDC = _WinAPI_CreateCompatibleDC($hDC)
$hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight)
$hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap)
$hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight)
If Not @error Then
_WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL)
_WinAPI_DestroyIcon($hIcon)
EndIf
_WinAPI_SelectObject($hBackDC, $hBackSv)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_DeleteDC($hBackDC)
Return $hBitmap
EndFunc ;==>_CreateBitmapFromIcon
Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight)
Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd')
Local $Ret = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0)
If (@error) Or ($Ret = 0) Then
Return SetError(1, 0, 0)
EndIf
$hIcon = DllStructGetData($tIcon, 1)
If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then
Return SetError(1, 0, 0)
EndIf
Return $hIcon
EndFunc ;==>_WinAPI_PrivateExtractIcon
Func SaveCurrentWorkerTable();;汇出当前资料(感谢autoit3.cn上的chzj589大大)
MsgBox(0,0,'汇出')
EndFunc
Func ImportWorkerTable();;汇入资料
MsgBox(0,0,'汇入')
EndFunc
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;| API视窗置顶 |
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Func _Topping()
If GUICtrlRead($menu2item1) = 65 Then ;;65 = 选中置顶,ini裡的1 = 启用置顶,0则否
_SetWindowPos($Form1,-1,-1,-1,-1,$HWND_TOPMOST,$SWP_NOMOVE+$SWP_NOSIZE);;置顶
EndIf
If GUICtrlRead($menu2item1) = 68 Then ;;68 = 未选中
_SetWindowPos($Form1,-1,-1,-1,-1,$HWND_NOTOPMOST,$SWP_NOMOVE+$SWP_NOSIZE);;取消置顶
EndIf
EndFunc
好长的代码,支持一下。 #AutoIt3Wrapper_UseX64=n
需要禁用64位模式 学习一下,感谢。感谢。 w60711 发表于 2019-5-28 01:16
我Win10
可以使用mdb的 建立 新增 修改 查询(范围列出) 删除
代码很乱,因为是临时修改手上的一份code ...
你的office是什么版本的. 我的office是2016的64位版. 我现在感觉很大的问题是access本身是64位 左手2018 发表于 2019-5-28 11:22
你的office是什么版本的. 我的office是2016的64位版. 我现在感觉很大的问题是access本身是64位
不用装office吗?access不是在office套件里吗??? 左手2018 发表于 2019-5-28 12:23
不用装office吗?access不是在office套件里吗???
Access是Office的套件没错
但是此范例(使用adox)并不需要安装Access
即可直接操作*.mdb
w60711 发表于 2019-5-28 12:54
Access是Office的套件没错
但是此范例(使用adox)并不需要安装Access
即可直接操作*.mdb
但是,有一个弹出框告诉我没有access的权限. 我为此昨天还特地重装了整个office 本帖最后由 w60711 于 2019-5-28 13:32 编辑
左手2018 发表于 2019-5-28 13:00
但是,有一个弹出框告诉我没有access的权限. 我为此昨天还特地重装了整个office
你是用這個代碼嗎?
如果有錯誤訊息麻煩截個圖片
我在Win7 虛擬機上執行(Admin帳戶)
並沒有遇到此情形...
w60711 发表于 2019-5-28 13:07
你是用這個代碼嗎?
如果有錯誤訊息麻煩截個圖片
我在Win7 虛擬機上執行(Admin帳戶)
是不是先在win7上配置好access的odbc? 左手2018 发表于 2019-5-28 13:19
是不是先在win7上配置好access的odbc?
好像也不对啊, 我看配置odbc的话要针对某一个access文件 左手2018 发表于 2019-5-28 13:22
好像也不对啊, 我看配置odbc的话要针对某一个access文件
我只有全新安装好
装个AU3、SoftMaker FreeOffice 2018
就没有动其他的了
你先试一下我给的附件吧...
看有甚麽提示讯息还是错误情况再来说
隔空抓药也不是办法... w60711 发表于 2019-5-28 13:30
我只有全新安装好
装个AU3、SoftMaker FreeOffice 2018
就没有动其他的了
你的示范au3成功了!!!!
我知道是怎么回事了. office里的access软件只是一个数据器管理软件(也就是sql查询器). 确实装不装是无所谓的
页:
[1]
2