我正在AutoIT中编写一个程序,让用户输入一个名称,然后搜索我已链接到Active Directory的MSSQL,以获取有关cn类似的用户或用户的信息。问题是我试图在行的末尾添加一个按钮。单击时,将电子邮件地址添加到剪贴板。我无法在线查找代码来帮助完成此操作。我有以下代码:
#include <mssql.au3>
#include <Array.au3>
dim $title = "E-Mail address lookup"
dim $sqlCon = _MSSQL_Con("servername", "password", "Directory3", "directory")
dim $name = InputBox($title,"Please type the name of the person you wish to find")
if StringLen(StringStripWS($name,3)) < 1 then
MsgBox(0, $title, "Name cannot be empty")
Else
local $result = _ArrayDisplay(_MSSQL_GetRecord($sqlCon, "rbc_staff","*", "WHERE cn LIKE '%" & StringStripWS($name,3) & "%'"))
EndIf
答案 0 :(得分:1)
; I don't know, how "_MSSQL_GetRecord" returns its result. I think it should be an 1D array.
; If it is so, try the following. No extra button, but a messagebox with yes/no.
; But it should be better, if you could post a sample of the result array
If StringLen(StringStripWS($name,3)) < 1 then
MsgBox(0, $title, "Name cannot be empty")
Else
; if I've right understand, the sql query gets the mail address
Local $result = _MSSQL_GetRecord($sqlCon, "rbc_staff","*", "WHERE cn LIKE '%" & StringStripWS($name,3) & "%'")
; instead of showing the array
;_ArrayDisplay($result)
; ask the user, if the address should be copied to clipboard
If MsgBox(36, 'Mail', 'You want to copy the mail address' & @CRLF & _
$result[0] & @CRLF & 'to clipboard?') = 6 Then
ClipPut($result[0])
EndIf
EndIf