Tiboi Posted May 23, 2010 Share Posted May 23, 2010 Hi can anyone help me out with this code please. its not the actual code I'm writing but its a fake clone of the part i need help in. i am new at autoit so please have patients with me thank you. $Browse = GUICreate("Browse", 498, 194, 220, 277) $txtBrowse = GUICtrlCreateInput("", 10, 40, 201, 24) $btnBrowse = GUICtrlCreateButton("...", 356, 40, 27, 22) $btnDeleteTMP = GUICtrlCreateButton("...", 10, 70, 27, 22) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnBrowse OPEN() $btnBrowse = GUICtrlCreateButton("...", 456, 40, 27, 22) EndSwitch WEnd ;open amd select notepad executable and save the path in the InputBox. c:\PARENT\notepad.exe Func OPEN() $message = "Select your notepad exe." $wowPath = FileOpenDialog($message, @DesktopDir, "notepad(*.exe)") If @error Then Else $notepadEXE = StringReplace($notepadPath, "|", @CRLF) GUICtrlSetData($txtBrowse, $notepadEXE) EndIf EndFunc ;delete a subdirectory of the root folder of notepad.exe ;eg. from the path stored in the $txtBrowse, choose the PARENT folder of notepad.exe sub folder named TMP Func DELETE_FOLDER() $TMPPath = DirRemove($TMPPath, 1) EndFunc Link to comment Share on other sites More sharing options...
Developers Jos Posted May 23, 2010 Developers Share Posted May 23, 2010 mmm fake clone ? Maybe post a script that at least was tested and made syntax error free? anyway: what is the DirRemove() statement supposed to remove? Your clone script has a syntax error there at this moment. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Yoriz Posted May 23, 2010 Share Posted May 23, 2010 You can use '_PathSplit' from the 'file' UDF to get the path less the filename. #Include <File.au3> ; with your other includes Func DELETE_FOLDER() Local $szDrive, $szDir, $szFName, $szExt, $szPath = GUICtrlRead($txtBrowse) _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt) $TMPPath = StringTrimRight($szDrive & $szDir, 1) DirRemove($TMPPath, 1) EndFunc GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Tiboi Posted May 23, 2010 Author Share Posted May 23, 2010 here is an example with a better script: the link i have stored in $txtBrowse is "C:\Parent\notepad.exe" +Parent\ ------------notepad.exe <-- the link in $txtBrowse ------------TMP <-- folder i want "DirRemove()" to delete so question is how do i write my code to change "C:\Parent\notepad.exe" to this "C:\Parent\", so that i can then go in and delete the TMP folder. i want the code to always use the exe link stored in the inputbox. expandcollapse popup#include <ButtonConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Browse = GUICreate("Browse", 498, 194, 220, 277) $txtBrowse = GUICtrlCreateInput("", 10, 40, 201, 24) $btnBrowse = GUICtrlCreateButton("...", 356, 40, 27, 22) $btnDeleteTMP = GUICtrlCreateButton("-", 10, 70, 27, 22) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnBrowse OPEN() Case $btnDeleteTMP DELETE_FOLDER() EndSwitch WEnd ;open amd select notepad executable and save the path in the InputBox. c:\PARENT\notepad.exe Func OPEN() $message = "Select your notepad exe." $notepadPath = FileOpenDialog($message, @DesktopDir, "notepad(*.exe)") If @error Then Else $notepadEXE = StringReplace($notepadPath, "|", @CRLF) GUICtrlSetData($txtBrowse, $notepadEXE) EndIf EndFunc ;==>OPEN ;delete a subdirectory of the root folder of notepad.exe ;eg. from the path stored in the $txtBrowse, choose the PARENT folder of notepad.exe sub folder named TMP ;Func DELETE_FOLDER() ;$TMPPath = ;DirRemove($TMPPath, 1) ;EndFunc ;==>DELETE_FOLDER Link to comment Share on other sites More sharing options...
Tiboi Posted May 23, 2010 Author Share Posted May 23, 2010 (edited) You can use '_PathSplit' from the 'file' UDF to get the path less the filename. #Include <File.au3> ; with your other includes Func DELETE_FOLDER() Local $szDrive, $szDir, $szFName, $szExt, $szPath = GUICtrlRead($txtBrowse) _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt) $TMPPath = StringTrimRight($szDrive & $szDir, 1) DirRemove($TMPPath, 1) EndFunc though i don't fully understand it but your code seems like what i want to do. i will try it out thank you. edit: ok the folder i want to delete will be $TMPPath\tmp not $TMPPath, how do i get back to there? Edited May 23, 2010 by Tiboi Link to comment Share on other sites More sharing options...
Tiboi Posted May 23, 2010 Author Share Posted May 23, 2010 (edited) Func DELETE_FOLDER() Local $szDrive, $szDir, $szFName, $szExt, $szPath = GUICtrlRead($txtBrowse) _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt) $TMPPath = StringTrimRight($szDrive & $szDir,1) MsgBox(0,"test",$TMPPath, 1) ;DirRemove($TMPPath, 1) EndFunc this is good so far $TMPPath returns c:\parent. now i would like to add \tmp to it so that it reads c:\parent\tmp. any help on this is appreciated. EDIT: nevermind my good people, $folderToDel = ($TMPPath & "\TMP") seems to give me what i want. Edited May 23, 2010 by Tiboi Link to comment Share on other sites More sharing options...
Yoriz Posted May 23, 2010 Share Posted May 23, 2010 Func DELETE_FOLDER() Local $szDrive, $szDir, $szFName, $szExt, $szPath = GUICtrlRead($txtBrowse) _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt) $TMPPath = $szDrive & $szDir & "tmp" DirRemove($TMPPath, 1) EndFunc GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
Tiboi Posted May 23, 2010 Author Share Posted May 23, 2010 here is the full code it might be useful to someone someday. thanks for all the help. expandcollapse popup#include <ButtonConstants.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #Region ### START Koda GUI section ### Form=Browse.kxf $Browse = GUICreate("Browse", 348, 69, 254, 164) $txtBrowse = GUICtrlCreateInput("", 74, 8, 225, 21) $btnBrowse = GUICtrlCreateButton("...", 316, 8, 27, 22, $WS_GROUP) $btnDeleteTMP = GUICtrlCreateButton("-", 316, 38, 27, 22, $WS_GROUP) $Label1 = GUICtrlCreateLabel("select a exe:", 8, 8, 64, 17) $Label2 = GUICtrlCreateLabel("delete a specific folder within the same dir as the selected exe:", 8, 40, 298, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnBrowse OPEN() Case $btnDeleteTMP DELETE_FOLDER() EndSwitch WEnd Func OPEN() $message = "Select your notepad exe." $notepadPath = FileOpenDialog($message, @DesktopDir, "notepad(*.exe)") If @error Then Else $notepadEXE = StringReplace($notepadPath, "|", @CRLF) GUICtrlSetData($txtBrowse, $notepadEXE) EndIf EndFunc ;==>OPEN Func DELETE_FOLDER() Local $szDrive, $szDir, $szFName, $szExt, $szPath = GUICtrlRead($txtBrowse) _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt) $TMPPath = StringTrimRight($szDrive & $szDir, 1) $folderToDel = ($TMPPath & "\TMP") DirRemove($folderToDel, 1) EndFunc ;==>DELETE_FOLDER Link to comment Share on other sites More sharing options...
Tiboi Posted May 23, 2010 Author Share Posted May 23, 2010 Func DELETE_FOLDER() Local $szDrive, $szDir, $szFName, $szExt, $szPath = GUICtrlRead($txtBrowse) _PathSplit($szPath, $szDrive, $szDir, $szFName, $szExt) $TMPPath = $szDrive & $szDir & "tmp" DirRemove($TMPPath, 1) EndFunc thanks Link to comment Share on other sites More sharing options...
GEOSoft Posted May 23, 2010 Share Posted May 23, 2010 Func DELETE_FOLDER() $TMPPath = StringRegExpReplace(GUICtrlRead($txtBrowse), "^(.+\\).+$", "$1tmp") DirRemove($TMPPath, 1) EndFunc 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...
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