dumou8343 Posted November 10, 2016 Share Posted November 10, 2016 (edited) Hey guys, I have a little problem, I'm developping this small app to help users make a request. I added a button that allows user to select the path they need. but I can only return the network drive and not the full path EX: E:/somethingsomething/workpath instead of the real network path witch is something like this //server/common/somethingsomething/workpath Now the only workaround I found is EXTREMLY dumb and long, Here is what I have currently working. expandcollapse popupGlobal $Server = "\\server\" Global $A = "A:\" Global $B = "B:\" Global $C = "C:\" Global $D = "D:\" Global $E = "E:\" Global $F = "F:\" Global $G = "G:\" Global $H = "H:\" Global $I = "I:\" Global $J = $Server & "workpath9\" Global $K = $Server & "workpath8\" Global $L = "L:\" Global $M = $Server & "workpath10\" Global $N = $Server & "workpath6\" Global $O = $Server & "workpath7\" Global $P = $Server & "workpath5\" Global $Q = $Server & "workpath4\" Global $R = $Server & "workpath3\" Global $S = $Server & "workpath2\" Global $T = "T:\" Global $U = $Server & "workpath1\" Global $V = "V:\" Global $W = $Server & "workpath\" Global $X = "X:\" Global $Y = "Y:\" Global $Z = "Z:\" Global $Input11 MainGUI_ACCESS() Func MainGUI_ACCESS() #Region ### START Koda GUI section ### Form=c:\users\dumer2\desktop\outlookudf\form1.kxf $Form1_1 = GUICreate("Demande d'accès", 432, 419, 192, 124) GUICtrlCreateLabel("Demande d'accès", 16, 6, 427, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Radio1 = GUICtrlCreateRadio("Lecture*", 16, 36, 105, 17) $Radio2 = GUICtrlCreateRadio("Lecture et Écriture*", 16, 56, 145, 17) GUICtrlCreateLabel("Utilisateurs de la région 10 qui ont besoin d'accès*", 16, 76, 400, 20) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") $Input12 = GUICtrlCreateInput("", 16, 96, 400, 21) $Button4 = GUICtrlCreateButton("Choisir les utilisateurs", 16, 117, 120, 17) If Not FileExists("\\se189c\applic\Support_Info\chkreseau.txt") Then GUICtrlSetState($Button4, $GUI_HIDE) EndIf GUICtrlCreateLabel("Utilisateurs d'autres régions qui ont besoin d'accès", 16, 145, 400, 20) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") $Input15 = GUICtrlCreateInput("", 16, 165, 400, 21) GUICtrlCreateLabel("Endroit demandé pour l'accès*", 16, 195, 330, 20) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") $Input11 = GUICtrlCreateInput("", 16, 215, 400, 21) $Button3 = GUICtrlCreateButton("Parcourir", 16, 237, 81, 17) ;GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $Count2 = 0 $Count1 = 0 $FinalCount = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button3 _FileSelectFolder() Case $GUI_EVENT_CLOSE GUIDelete($Form1_1) _gui() EndSwitch WEnd EndFunc ;==>MainGUI_ACCESS Func _FileSelectFolder() $Folder = FileSelectFolder("Choisi un lien", $Server) $netfolder = StringLeft( $Folder, 2) If $netfolder = "\\" Then GUICtrlSetData($Input11, $Folder) Elseif $netfolder = "A:" Then Local $String = StringReplace($Folder, $netfolder & "\", $A) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "B:" Then Local $String = StringReplace($Folder, $netfolder & "\", &$B) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "C:" Then Local $String = StringReplace($Folder, $netfolder & "\", $C) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "D:" Then Local $String = StringReplace($Folder, $netfolder & "\", $D) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "E:" Then Local $String = StringReplace($Folder, $netfolder & "\", $E) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "F:" Then Local $String = StringReplace($Folder, $netfolder & "\", $F) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "G:" Then Local $String = StringReplace($Folder, $netfolder & "\", $G) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "H:" Then Local $String = StringReplace($Folder, $netfolder & "\", $H) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "I:" Then Local $String = StringReplace($Folder, $netfolder & "\", $I) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "J:" Then Local $String = StringReplace($Folder, $netfolder & "\", $J) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "K:" Then Local $String = StringReplace($Folder, $netfolder & "\", $K) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) Elseif $netfolder = "L:" Then Local $String = StringReplace($Folder, $netfolder & "\", $L) GUICtrlSetData($Input11, $String) MsgBox(0,"",$String) ElseIf $netfolder = "M:" Then Local $String = StringReplace($Folder, $netfolder & "\", $M) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "N:" Then Local $String = StringReplace($Folder, $netfolder & "\", $N) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "O:" Then Local $String = StringReplace($Folder, $netfolder & "\", $O) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "P:" Then Local $String = StringReplace($Folder, $netfolder & "\", $P) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "Q:" Then Local $String = StringReplace($Folder, $netfolder & "\", $Q) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "R:" Then Local $String = StringReplace($Folder, $netfolder & "\", $R) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "S:" Then Local $String = StringReplace($Folder, $netfolder & "\", $S) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "T:" Then Local $String = StringReplace($Folder, $netfolder & "\", $T) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "U:" Then Local $String = StringReplace($Folder, $netfolder & "\", $U) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "V:" Then Local $String = StringReplace($Folder, $netfolder & "\", $V) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "W:" Then Local $String = StringReplace($Folder, $netfolder & "\", $W) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "X:" Then Local $String = StringReplace($Folder, $netfolder & "\", $X) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "Y:" Then Local $String = StringReplace($Folder, $netfolder & "\", $Y) GUICtrlSetData($Input11, $String) ElseIf $netfolder = "Z:" Then Local $String = StringReplace($Folder, $netfolder & "\", $Z) GUICtrlSetData($Input11, $String) Else MsgBox(0,"","Aucun lien selectionné") EndIf EndFunc I take every letter and manually assign it a server path, but all my users have different network shares depending on their jobs So my question is, is there a way to shorten this up and make it universal? like if a user selects a path with the drive letter can I get the full network path instead? Thanks guys! Edited November 10, 2016 by dumou8343 Link to comment Share on other sites More sharing options...
orbs Posted November 10, 2016 Share Posted November 10, 2016 _WinAPI_QueryDosDevice perhaps? dumou8343 1 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
dumou8343 Posted November 10, 2016 Author Share Posted November 10, 2016 1 hour ago, orbs said: _WinAPI_QueryDosDevice perhaps? This is the right path! I can now see my device full path with this code from the example #include <WinAPIFiles.au3> Local $aDrive = DriveGetDrive($DT_NETWORK) If IsArray($aDrive) Then For $i = 1 To $aDrive[0] MsgBox(0, "", StringUpper($aDrive[$i]) & ' => ' &"\\" & StringTrimLeft(_WinAPI_QueryDosDevice($aDrive[$i]), 45) & "\") Next EndIf I added a trim and some \\ before and one after to fit what I need. Now I have a very very limited knowledge of arrays, is there a possibility of using $Folder = FileSelectFolder("Choisi un lien", $Server) and checking $Folder with the array to only find the variable and show me the full path of that? Link to comment Share on other sites More sharing options...
dumou8343 Posted November 10, 2016 Author Share Posted November 10, 2016 I think I got it! thank you a million times! I'm using #include <WinAPIFiles.au3> Local $aDrive = DriveGetDrive($DT_NETWORK) $Folder = FileSelectFolder("Choisi un lien", "$SERVER") If IsArray($aDrive) Then For $i = 1 To $aDrive[0] Select Case StringLeft($Folder, 2) = StringUpper($aDrive[$i]) MsgBox(0, "", "\\" & StringTrimLeft(_WinAPI_QueryDosDevice($aDrive[$i]), 45) & "\" & StringTrimLeft($Folder, 3)) EndSelect Next EndIf Still need to test it out more but I think this is it! Thank you again! 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