surreal Posted January 21, 2010 Posted January 21, 2010 (edited) i have a function that list all the local systems mapped drives or the mapped drives on a remote system. the drive letter and share will display in a GUICtrlCreateListView with checkboxes. i would like to be able to select a checkbox or checkboxes and then click the button to map the drives locally. below is the function and it seems that my first problem will be that when i use MsgBox as a test it displays with the pipe |. so it is making it hard to import the selected data into a drivemapadd. thanks for your help all...expandcollapse popupFunc Drives() $List_Drives = GUICreate("Mapped Drives (" & $masset & ")", 320, 250, 350, 250, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) GUISetBkColor(0xD4D0C8) $View = GUICtrlCreateListView("Drive | Path", 0, 0, 320, 200, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_CHECKBOXES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250) GUISetState() $MDButton = GUICtrlCreateButton("Map Drive(s)", 120, 210, 75, 30, $WS_GROUP) EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") GUICtrlCreateListViewItem(" " & $b[$j][1] & " | " & $Path[1][1] & "", $View) EndIf Next If $iProdm <> 0 Then ExitLoop Next GUISetState(@SW_SHOW) While 1 $mdmsg = GUIGetMsg() Select Case $mdmsg = $MDButton Local $item_count = _GUICtrlListView_GetItemCount($View) Local $is_checked, $items_checked, $file_array[1] For $i = 0 To $item_count - 1 $is_checked = _GUICtrlListView_GetItemChecked($View, $i) If Not @error Then $items_checked += $is_checked If ($is_checked) Then If ($items_checked = 1) Then _ArrayInsert($file_array, 0, _GUICtrlListView_GetItemTextString($View, $i)) _ArrayDelete($file_array, 1) Else _ArrayAdd($file_array, _GUICtrlListView_GetItemTextString($View, $i)) EndIf EndIf EndIf Next If ($items_checked <> 0) Then If Not @error Then For $i = 0 To $items_checked - 1 MsgBox(0, "Mapped Drive", $file_array[$i]) Next EndIf Else MsgBox(0, "Mapped Drive", "ERROR") EndIf Case $mdmsg = $GUI_EVENT_CLOSE GUIDelete($List_Drives) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFuncif you need the full code i have zipped it with all the #includes download Edited January 22, 2010 by surreal
surreal Posted January 22, 2010 Author Posted January 22, 2010 (edited) im getting alot closer, i had to remove the checkboxes. the below code works but only lets me do one at a time. any help with how to do this with the checkboxs and be able to map multi mappings would be great, im so close. expandcollapse popup;===Function For Mapped Drives===================================================================== Func Drives() $List_Drives = GUICreate("Mapped Drives (" & $masset & ")", 320, 250, -1, -1, -1) GUISetBkColor(0xD4D0C8) $View = GUICtrlCreateListView("Drive | Path", 0, 0, 320, 200, -1) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 250) GUISetState() $MDButton = GUICtrlCreateButton("Map Drive(s)", 120, 210, 75, 30, $WS_GROUP) EndIf For $i = 1 To 25 $b = _HKCU_EnumKey("\\\" & $masset & "\Network", $i) $iProdm = 1 For $j = 1 To $b[0][0] $iProdm *= $b[$j][2] If $b[$j][2] = 0 Then $Path = _HKCU_Read("\\\" & $masset & "\\" & $b[$j][0] & "\Network\" & $b[$j][1], "RemotePath") GUICtrlCreateListViewItem("" & $b[$j][1] & "|" & $Path[1][1] & "", $View) EndIf Next If $iProdm <> 0 Then ExitLoop Next GUISetState(@SW_SHOW) While 1 $mdmsg = GUIGetMsg() Select Case $mdmsg = $MDButton $Column1 = _GUICtrlListView_GetItemTextArray($View, -1) ConsoleWrite("Column 1 Text = " & $Column1[1] & ":" & @CRLF) $Column2 = _GUICtrlListView_GetItemTextArray($View, -1) ConsoleWrite("Column 2 Text = " & $Column2[2] & @CRLF) SplashTextOn($sTitle, "Mapping Drive", 165, 40, -1, -1, 2, "", 9) DriveMapAdd($Column1[1] & ":", $Column2[2]) Sleep(1000) SplashOff() Case $mdmsg = $GUI_EVENT_CLOSE GUIDelete($List_Drives) ExitLoop GUISwitch($ParentWin) GUISetState(@SW_SHOW, $ParentWin) EndSelect WEnd EndFunc ;==>Drives thanks d@ve Edited January 22, 2010 by surreal
OregonJohn Posted June 12, 2012 Posted June 12, 2012 I know this is an old thread, but surreal's questions and sample code helped me. I was working on a script to list the folders in XP's Application Data directory, select them and then eventually copy and transfer them to Win7. Here's a snip of my solution, I don't use all of it in my final code but I sampled some possibilities. If $msg = $btnAppData Then Local $item_count = _GUICtrlListView_GetItemCount($lstvAppData) Local $is_checked For $i = 0 To $item_count - 1 If _GUICtrlListView_GetItemChecked($lstvAppData, $i) = True Then If $is_checked = "" Then $is_checked = _GUICtrlListView_GetItemText($lstvAppData, $i) Else $is_checked = $is_checked & @CRLF & _GUICtrlListView_GetItemText($lstvAppData, $i) EndIf EndIf Next If MsgBox(1,"","You have selected:" & @CRLF & @CRLF & $is_checked) = 2 Then Exit $is_checked = StringSplit($is_checked,@CRLF) _ArrayDisplay($is_checked) EndIf
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