#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#NoTrayIcon
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("ODBC数据源自动创建-黑白网络科技", 283, 172, 192, 114)
$Group1 = GUICtrlCreateGroup("ODBC数据源自动创建", 0, 0, 281, 169)
$Label1 = GUICtrlCreateLabel("用什么名称来命名数据源?(请选择或者输入)", 8, 16, 246, 17)
$Label2 = GUICtrlCreateLabel("名 称:", 8, 35, 54, 17)
$Combo1 = GUICtrlCreateCombo("", 56, 32, 145, 25)
GUICtrlSetData(-1, "sfydoc|sfy2000|jzkzc", "sfy2000")
$Label3 = GUICtrlCreateLabel("您想连接哪一个SQL Server?(请选择或者输入)", 8, 56, 264, 17)
$Label4 = GUICtrlCreateLabel("服务器:", 8, 75, 52, 17)
$Combo2 = GUICtrlCreateCombo("", 56, 72, 145, 25)
GUICtrlSetData(-1, "DOCSERVER|SQL Server", "SQL Server")
$Label5 = GUICtrlCreateLabel("确认上面的输入无误后,点击确定开始自动创建", 8, 96, 256, 17)
GUICtrlSetColor(-1, 0x0000FF)
$Label6 = GUICtrlCreateLabel("创建过程中请勿对鼠标键盘进行操作,以免出错", 8, 112, 256, 17)
GUICtrlSetColor(-1, 0x0000FF)
$Button1 = GUICtrlCreateButton("关于", 16, 136, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("确定", 104, 136, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("退出", 192, 136, 75, 25, $WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Case $Button2
$name = GUICtrlRead($Combo1)
$server = GUICtrlRead($Combo2)
Run("odbcad32.exe")
WinWait("ODBC 数据源管理器")
ControlClick("ODBC 数据源管理器","添加","Button1")
WinWait("创建新数据源")
Send("SQL Server")
ControlClick("创建新数据源","完成","Button4")
WinWait("创建到 SQL Server 的新数据源")
Send($name,"Edit1")
Send("{TAB}")
Send("{TAB}")
Send($server,"Edit3")
ControlClick("创建到 SQL Server 的新数据源","下一步","Button2")
Send("{ENTER}")
ControlClick("创建到 SQL Server 的新数据源","下一步","Button6")
WinWait("创建到 SQL Server 的新数据源")
ControlClick("创建到 SQL Server 的新数据源","更改默认的数据库为","Button1")
Send("{TAB}")
Send($name,"Edit1")
ControlClick("创建到 SQL Server 的新数据源","下一步","Button14")
ControlClick("创建到 SQL Server 的新数据源","完成","Button23")
WinWait("ODBC Microsoft SQL Server 安装")
ControlClick("ODBC Microsoft SQL Server 安装","确定","Button2")
WinWait("ODBC 数据源管理器")
MsgBox(64,"提示","成功创建数据源:"&$name)
Sleep(5000)
ControlClick("ODBC 数据源管理器","确定","Button5")
Case $Button3
Exit
EndSwitch
WEnd |