xinx Posted September 11, 2012 Share Posted September 11, 2012 (edited) I'm have a working program that displays the users in Active Directory. When a user's name is clicked on it displays their details (profile folder, work folder, etc). However, what I'd really like to do is be able to eliminate using the mouse as much as possible, so instead of having to click on each user's name, you can use the UP and DOWN arrows and it will act as though their name has been clicked on (if that makes any sense?). Here's some of the code so far: $ADListView = GUICtrlCreateListView("Login Name|Display Name", 140, 60, 220, 280);A ListView to display the users ; Adjust the ADListView column headers _GUICtrlListView_SetColumnWidth($ADListView, 0, 100) _GUICtrlListView_SetColumnWidth($ADListView, 1, 116) Func UpdateUserList() _AD_Open() $SelectedUserType = GUICtrlRead($UserTypeCombo) ;Get the base OU for the user type $SelectedUserTypeBaseOU = IniRead("iniUsers.ini", $SelectedUserType, "BaseOU", "NotFound") ;Get the filtered results from the AD using base OU $ADData = _AD_GetObjectsInOU($SelectedUserTypeBaseOU, "(&(objectclass=user)(name=*))", 2, "sAMAccountName,distinguishedName,displayname", "displayname") GUICtrlSetData($ADListView, $ADData) _GUICtrlListView_DeleteAllItems($ADListView) GUICtrlSetData($UserPropertiesEditBox, "Properties of Selected User") $SelectedUser = "" ;For each AD user, add an item in in the ListView For $i = 1 To UBound($ADData) - 1 GUICtrlCreateListViewItem($ADData[$i][0] & "|" & $ADData[$i][2], $ADListView) GUICtrlSetOnEvent(-1, "ListClicked") ; For each item, add the required event Next _AD_Close() EndFunc ;==>UpdateUserList Func ListClicked() $ItemString = GUICtrlRead(@GUI_CtrlId) $ItemArray = StringSplit($ItemString, "|") $SelectedUser = $ItemArray[1] _AD_Open() $givenName = _AD_GetObjectAttribute($SelectedUser, "givenName") $SN = _AD_GetObjectAttribute($SelectedUser, "SN") $displayName = _AD_GetObjectAttribute($SelectedUser, "displayName") $profilePath = _AD_GetObjectAttribute($SelectedUser, "profilePath") $homeDirectory = _AD_GetObjectAttribute($SelectedUser, "homeDirectory") $homeDrive = _AD_GetObjectAttribute($SelectedUser, "homeDrive") $GroupArray = _AD_GetUserGroups($SelectedUser) GUICtrlSetData($UserPropertiesEditBox, "") _GUICtrlEdit_AppendText($UserPropertiesEditBox, "Properties of Selected User") _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "First Name: " & $givenName) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Last Name: " & $SN) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Login Name: " & $SelectedUser) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Profile Directory: " & $profilePath) _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Home Directory: " & $homeDirectory & " (" & $homeDrive & ")") _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & @CRLF & "Group Membership:") For $i = 1 To UBound($GroupArray) - 1 _GUICtrlEdit_AppendText($UserPropertiesEditBox, @CRLF & _AD_FQDNToDisplayname($GroupArray[$i])) Next _AD_Close() EndFunc ;==>ListClicked Any help would be great, thank you! Edited September 12, 2012 by xinx Link to comment Share on other sites More sharing options...
xinx Posted September 11, 2012 Author Share Posted September 11, 2012 (edited) P.s. I suspect it needs to be something in the;For each AD user, add an item in in the ListView For $i = 1 To UBound($ADData) - 1 GUICtrlCreateListViewItem($ADData[$i][0] & "|" & $ADData[$i][2], $ADListView) GUICtrlSetOnEvent(-1, "ListClicked") ; For each item, add the required event NextSo that when the UP or DOWN arrows are used they GUICtrlSetOnEvent(-1, "ListClicked") - I just can't seem to find out how. Edited September 12, 2012 by xinx Link to comment Share on other sites More sharing options...
xinx Posted September 12, 2012 Author Share Posted September 12, 2012 Any suggestions welcome - also if I have missed out anything that anyone needs in order to help then please let me know! Link to comment Share on other sites More sharing options...
abberration Posted September 13, 2012 Share Posted September 13, 2012 Hello, xinix. Today, I have been trying to do the same thing you are doing. It doesn't appear to be an easy thing to do. The closest I have come so far has been using _GUICtrlListView_GetSelectionMark to find the zero based index of the selected row. Then, you can use _GUICtrlListView_InsertItem to insert an item. Note that it does not insert multiple columns. Using the separator "|" does not split your data. Lastly, you can use _GUICtrlListView_DeleteItemsSelected to delete any unwanted rows. I'm not very hopeful of an easy solution. Looking at previous solutions to small problems like editing a second column, I have seen dozens of lines of code with things I don't fully understand yet (like creating structures, calling DLLs and $WM_NOTIFY). As easy as AutoIt is on most things, I thought there would be a _RowMoveUP and _RowMoveDown kind of function. Maybe there's some technical reason why it can't be done so easily. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
xinx Posted September 14, 2012 Author Share Posted September 14, 2012 Hi abberration Thank you - I thought I was missing something obvious but at least I know it's not and that others have had similar issues. Sad though :-( All the best xinx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now