ussr Posted July 4, 2011 Share Posted July 4, 2011 HI Is It possible to (run) application from the (inputbox) without filename ?How?? I can open only the folder. Try this one please. expandcollapse popup#include <WindowsConstants.au3> #include <GuiButton.au3> #include <GuiImageList.au3> #include <Array.au3> #region ### START Koda GUI section ### Form=c:\users\el-zaeem\desktop\backup\bacckup form.kxf $Form1_1 = GUICreate("input", 407, 360, 230, 132) $path_source = GUICtrlCreateInput("", 72, 43, 497, 21) $browes_source = GUICtrlCreateButton("", 17, 40, 49, 41, $WS_GROUP) $exit = GUICtrlCreateButton("exit", 17, 160, 49, 41, $WS_GROUP) $shell = GUICtrlCreateButton("shell It", 17, 100, 49, 41, $WS_GROUP) GUICtrlCreateLabel(" press It" , 20, 15) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $browes_source $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4) If @error Then GUICtrlSetData($path_source, "") Else $iconfile_to_use = $file $array = StringSplit($iconfile_to_use, '\', 1) $name = $array[$array[0]] $newname = StringReplace($name, ".exe", "") $hImage = _GUIImageList_Create(32, 32, 5, 3, 6) _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True) _GUICtrlButton_SetImageList($browes_source, $hImage, 4) GUICtrlSetData($path_source, $file) EndIf Case $shell ShellExecute("", "","$path_source","open",@SW_SHOWDEFAULT);This part is my problem.It is opening Just the folder. Case $exit Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 4, 2011 Share Posted July 4, 2011 You had the parameters for ShellExecute in the wrong order. Also, the quotes around $path_source aren't needed (turns it from a variable into a string), and the GUICtrlRead function needed to be used to get the data from that variable. The variable itself contains the Ctrl ID.ShellExecute(GUICtrlRead($path_source), "","","open",@SW_SHOWDEFAULT);This part is my problem.It is opening Just the folder. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 4, 2011 Moderators Share Posted July 4, 2011 (edited) ussr,Look at the first 3 parameters in your ShellExecute line:ShellExecute("", "","$path_source",....You should have:filename - The name of the file to run : You have "" so how does the function know what to run? parameters - [optional] Any parameters for the program. Blank ("") uses none : Here your syntax is correct workingdir - [optional] The working directory. Blank ("") uses the current working directory. : You have a literal string which is not a folder nameBasically AutoIt defaults to opening @WorkingDir (which you set by using FileOpenDialog) in Explorer as it has no idea what you are trying to do! So I recommend that you use the correct parameters - the function will then work. You can get the folder and executable name from the content of the input like this:$sChoice = GUICtrlRead($path_source) ShellExecute($sChoice, "", StringRegExpReplace($sChoice, "(^.*)\\(.*)", "\1"), "open", @SW_SHOWDEFAULT)I hope that helps. M23Edit: Typnig! Edited July 4, 2011 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ussr Posted July 4, 2011 Author Share Posted July 4, 2011 Thank You somdcomputerguy Now It is works. ShellExecute(GUICtrlRead($path_source) & "") However I didnt understand this : "(turns it from a variable into a string)" Should I use string?? Link to comment Share on other sites More sharing options...
ussr Posted July 4, 2011 Author Share Posted July 4, 2011 Thanks Melba23 too. The problem sold. Link to comment Share on other sites More sharing options...
GEOSoft Posted July 4, 2011 Share Posted July 4, 2011 It still isn't quite right. All you needed was ShellExecute(GUICtrlRead($path_source)) The &"" just adds an empty string to the end which will have no effect at all. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 4, 2011 Share Posted July 4, 2011 No, you want the data in the variable, GUICtrlRead($path_source), not the string "$path_source". And let me rephrase my earlier statement, Even if you want to use it as a variable, with quotes around it AutoIt sees it as a string. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
ussr Posted July 5, 2011 Author Share Posted July 5, 2011 One more question.Is It possible to get the ProcessList()from the ShellExecute ??? ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 5, 2011 Moderators Share Posted July 5, 2011 ussr,You can use ProcessExists to get the PID - you can extract the process name from the full path like this:$sProcessName = StringRegExpReplace($GUICtrlRead($path_source), "^.*\\", "")I hope this helps. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ussr Posted July 5, 2011 Author Share Posted July 5, 2011 You are really PRO This solution is going to save me a lot of time . Thanks 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