mr-es335 Posted Wednesday at 01:42 PM Posted Wednesday at 01:42 PM Good day, I hope that the day finds you well! I have the following script: expandcollapse popup; ----------------------------------------------- #include <FileConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- CopyDocData() CopyImgData() ExitFolders() ExitText() LaunchProcedureText() LaunchMainFolder() LaunchImagesFolder() ; ----------------------------------------------- Func CopyDocData() Local $sSrcPath = "E:\~About\Word\Examples\src\Example 1.doc" ; ----------------- Local $sDstPath = "E:\~About\Word\Examples\dst" ; ----------------------------------------------- FileCopy($sSrcPath, $sDstPath, $FC_OVERWRITE) EndFunc ;==>CopyDocData ; ----------------------------------------------- Func CopyImgData() Local $sSrcPath = "E:\~About\Word\Examples\src\Images\1.png" ; ----------------- Local $sDstPath = "E:\~About\Word\Examples\dst\Images\" ;~ Local $sDstPath = "E:\~About\Word\Examples\dst\Images\1a.png" ; ----------------------------------------------- FileCopy($sSrcPath, $sDstPath, $FC_OVERWRITE) EndFunc ;==>CopyImgData ; ----------------------------------------------- Func ExitFolders() Local $sSrcPath1 = "E:\~About\Word\Examples\src\Images" Local $sSrcPath2 = "E:\~About\Word\Examples\src" Local $iFileExists1 = FileExists($sSrcPath1) Local $iFileExists2 = FileExists($sSrcPath2) ; ----------------------------------------------- If $iFileExists1 Then WinClose($sSrcPath1) EndIf ; ----------------- If $iFileExists2 Then WinClose($sSrcPath2) EndIf EndFunc ;==>ExitFolders ; ----------------------------------------------- Func ExitText() Local $sSrcPath = "E:\~About\Word\Examples\src\Procedure.txt" ; ----------------------------------------------- WinClose($sSrcPath, "") EndFunc ;==>ExitText ; ----------------------------------------------- Func LaunchProcedureText() Local $sSrcPath = "E:\~About\Word\Examples\dst\Procedure.txt" ; ----------------------------------------------- ShellExecute($sSrcPath) WinWaitActive($sSrcPath, "") WinMove($sSrcPath, "", 1950, 25, 550, 1000) EndFunc ;==>LaunchProcedureText ; ----------------------------------------------- Func LaunchMainFolder() Local $sSrcPath = "E:\~About\Word\Examples\dst" ; ----------------------------------------------- ShellExecute($sSrcPath) WinWait($sSrcPath, "") WinMove($sSrcPath, "", 2520, 25, 500, 440) EndFunc ;==>LaunchMainFolder ; ----------------------------------------------- Func LaunchImagesFolder() Local $sSrcPath = "E:\~About\Word\Examples\dst\Images" ; ----------------------------------------------- ShellExecute($sSrcPath) WinWait($sSrcPath, "") WinMove($sSrcPath, "", 2520, 475, 500, 440) EndFunc ;==>LaunchImagesFolder ; ----------------------------------------------- My "issue" is regarding the ExitFolders() section. It would appear that I am unable to exist a folder where the script actually reside!! • I know that I can move the script elsewhere, but I really do need to keep the script where it is located! Any ideas....suggestions? Thank you for your time...appreciated! mr-es335 Sentinel Music Studios
Numeric1 Posted Wednesday at 07:21 PM Posted Wednesday at 07:21 PM (edited) Hi, The issue comes from the fact that WinClose() expects a window title, not a path. Also, trying to close a folder where the script itself is running can cause it to fail. A more reliable approach is to use WinList() to find and close any Explorer windows with matching titles: Func ExitFolders() Local $aList = WinList("[CLASS:CabinetWClass]") For $i = 1 To $aList[0][0] If StringInStr($aList[$i][0], "src\Images") Or _ StringInStr($aList[$i][0], "src") Then WinClose($aList[$i][1]) EndIf Next EndFunc Edited Wednesday at 07:22 PM by Numeric1
ioa747 Posted 5 hours ago Posted 5 hours ago and of course this approach assumes that the full title is visible in the explorer window Func ExitFolders() Local $sSrcPath1 = "E:\~About\Word\Examples\src\Images" Local $sSrcPath2 = "E:\~About\Word\Examples\src" Local $Info ; optional and temporary to see what happens ; ----------------------------------------------- If WinExists("[CLASS:CabinetWClass; TITLE:" & $sSrcPath1 & "]") Then $Info = WinClose("[CLASS:CabinetWClass; TITLE:" & $sSrcPath1 & "]") ConsoleWrite("SrcPath1 found, WinClose=" & $Info & @CRLF) EndIf ; ----------------- If WinExists("[CLASS:CabinetWClass; TITLE:" & $sSrcPath2 & "]") Then $Info = WinClose("[CLASS:CabinetWClass; TITLE:" & $sSrcPath2 & "]") ConsoleWrite("SrcPath2 found, WinClose=" & $Info & @CRLF) EndIf EndFunc ;==>ExitFolders I know that I know nothing
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