madmorgan Posted February 6, 2010 Posted February 6, 2010 hello all, i need help i want to use the file open dialogbox to just get the file name stored in to a varabule example below #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 306, 151, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 32, 40, 121, 21) $Button1 = GUICtrlCreateButton("Button1", 168, 40, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 88, 88, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $FILENAME = FileOpenDialog("", @UserName, "images (*.JPG)") $PATH = ("") MsgBox(0,"",$file) EndSwitch WEnd i want $FILENAME to have the name of the file eg test.jpg also from the fileopen box i want the $PATH to hold the path to the file as well. the only reason i want this like this i want the file name is one var to add to some othere code lator on and the path for somthing else. if some one can hepl me to do this semmy easy thing then i will be gratefull. thanks
FuryCell Posted February 6, 2010 Posted February 6, 2010 _PathSplit() is useful for this. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 306, 151, 192, 124) $Input1 = GUICtrlCreateInput("Input1", 32, 40, 121, 21) $Button1 = GUICtrlCreateButton("Button1", 168, 40, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 88, 88, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Open = FileOpenDialog("", @UserName, "images (*.JPG)") Dim $Drive,$Dir,$Name,$Ext _PathSplit($Open,$Drive,$Dir,$Name,$Ext) $Name=$Name&$Ext $Path=$Drive&$Dir MsgBox(0,"",$Name) MsgBox(0,"",$Path) EndSwitch WEnd HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Hawkwing Posted February 6, 2010 Posted February 6, 2010 (edited) This should work. $PATH = FileOpenDialog("", @UserName, "images (*.JPG)") $temp = StringSplit($PATH, "\") $FILENAME = $temp[UBound($temp) - 1] MsgBox(0, "", $FILENAME & @CRLF & $PATH) Edit: Beat me to it. Didn't know about _pathsplit though, looks useful. Edited February 6, 2010 by Hawkwing The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.
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