【发布时间】:2016-11-07 13:38:44
【问题描述】:
我正在编写的代码有问题。我有一张列出工作人员详细信息的表格。当您选择记录并右键单击时,我正在尝试将电子邮件地址复制到剪贴板。我有以下代码:
#include <GUIConstantsEx.au3>
#include <mssql.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <AutoItConstants.au3>
global $title = "E-Mail address lookup"
global $name = InputBox($title,"Please type the name of the person you wish to find")
global $sqlCon = _MSSQL_Con("server", "username", "password", "directory-plus")
global $result = _MSSQL_GetRecord($sqlCon, "autoit_view","*", "WHERE cn LIKE '%" & StringStripWS($name,3) & "%'")
if StringLen(StringStripWS($name,3)) < 1 then
MsgBox(0, $title, "Name cannot be empty")
Else
Global $rset = UBound($result) - 1
Global $ControlID = GUICreate($title, 500, 150)
Global $idListview = GUICtrlCreateListView("Deparment|E-Mail Address|Name|Telephone Number", 10, 10, 480, 150)
for $count = 1 to $rset step 1
GUICtrlCreateListViewItem($result[$count][0] & "|" & $result[$count][2] & "|" & $result[$count][1] & "|" & $result[$count][2], $idListview)
if MouseClick($MOUSE_CLICK_RIGHT)==1 Then
ClipPut($result[$count][2])
EndIf
Next
GUISetState(@SW_SHOW)
GUISetState()
While 1
Global $Msg = GUIGetMsg()
Switch $Msg
Case -3, $ControlID
Exit
EndSwitch
WEnd
EndIf
我原以为我在 for 循环中的 IF 语句可以解决问题,但是,当我运行我的代码时,它只会复制最后一行电子邮件地址列中的任何内容,而实际上我希望它复制电子邮件地址当您右键单击特定行但我不知道该怎么做时。
【问题讨论】:
标签: autoit