ileandros Posted February 21, 2012 Posted February 21, 2012 Hello, I made a simple script with a list, a menu/menuitem that adds item to the list and a button that executes it. It adds All (*.*) . When they are displayed at the list they are item with the Path. How can i make it generete them as they are for example if its a .txt or .mp3 or image. Is it possible the execute button to execute them as they are for example if it is a mp3 run it as a mp3 if its a .txt run it as .txt if its an image run it as an image. Can i make the program recognize them and execute with the right way??? This is the proggram. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Example() Func Example() Local $filemenu, $fileitem Local $helpmenu, $infoitem, $exititem, $recentfilesmenu Local $viewmenu, $viewstatusitem, $cancelbutton Local $statuslabel, $msg, $file GUICreate("My GUI menu", 300, 200) $List1 = GUICtrlCreateList("", 0,0,299, 150) GUICtrlSetData(-1, "") $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu("?") GUICtrlCreateMenuItem("Save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $infoitem = GUICtrlCreateMenuItem("Info", $helpmenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState(-1, $GUI_CHECKED) $executebutton = GUICtrlCreateButton("Execute", 50, 150, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("Exit", 180, 150, 70, 20) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $fileitem Then $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") GUICtrlSetData($List1, $file) If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu) EndIf Switch $msg Case $executebutton $read = GUICtrlRead($List1) if $read = true Then MsgBox(0,"test", "test") EndIf EndSwitch If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop If $msg = $infoitem Then MsgBox(0, "Info", "Only a test...") WEnd GUIDelete() EndFunc ;==>Example I feel nothing.It feels great.
BrewManNH Posted February 21, 2012 Posted February 21, 2012 Use ShellExecute to run the files/programs, they'll be run by whatever progams they're set to be run by. For instance, .txt would probably open Notepad with the text file opened in it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
ileandros Posted February 21, 2012 Author Posted February 21, 2012 That did Is there a way the list to display the files as they are and not as their Path??? I feel nothing.It feels great.
BrewManNH Posted February 21, 2012 Posted February 21, 2012 You could use _PathSplit to get the path components of the files. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
ileandros Posted February 21, 2012 Author Posted February 21, 2012 that is true but with _PathSplit you have to check all like _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt) What i want to manage is when the item is added at the list to be displayed as one of these ($szName) I feel nothing.It feels great.
AdamUL Posted February 21, 2012 Posted February 21, 2012 (edited) Try this; File name w/0 ext Local $sFilenameExExt = StringRegExpReplace($sFile, "^.*|..*$", "")from this Adam Edited February 21, 2012 by AdamUL
BrewManNH Posted February 21, 2012 Posted February 21, 2012 So? What's stopping you from using "$szFName & $szExt"? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
ileandros Posted February 21, 2012 Author Posted February 21, 2012 So? What's stopping you from using "$szFName & $szExt"?I dont know im getting error.I didn't manage to make the item be displayed with the name and not with the path.I got confused :/ I feel nothing.It feels great.
ileandros Posted February 21, 2012 Author Posted February 21, 2012 Ouf i made it!!! Can i make the programm when i run it to generete all the files (.mp3, .txt, img etc) in the computer and load them at the list box?? Or make it generate spesific type of files ??? I feel nothing.It feels great.
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