Pauletp Posted April 8, 2008 Share Posted April 8, 2008 I have a problem with the following code. If I run ;------------------Reference: ;----------------- Window open in Explorer is ;-----------------"e:\abc\script_test" ;-----------------"Script_test" contains 5 other folders ;---------- get path of window in Explorer $GetTextString = WinGetText("") ;-------------locate the line break $pos = StringInStr($GetTextString,@LF ) ;-------------take out the first line for the folder path $folderpath = StringLeft($GetTextString, $pos) MsgBox (0,"", $folderpath,2) #Include <File.au3> #Include <Array.au3> ;-------------manual insertion of path string ;$FileList =_FileListToArray("E:\abc\Script_test","*", 2) $FileList =_FileListToArray($folderpath,"*", 2) _ArrayDisplay($FileList,"$FileList") If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf ;---------------- I get the message "No Files\Folders Found." But if I manually insert the "E:\abc\Script_test" I get the array listed as I expected showing the names of the folders. I must be missing something basic here. Anyone see the problem? Thanks for a tip. Link to comment Share on other sites More sharing options...
weaponx Posted April 8, 2008 Share Posted April 8, 2008 Does the msgbox show "E:\abc\Script_test"? Link to comment Share on other sites More sharing options...
someone Posted April 8, 2008 Share Posted April 8, 2008 (edited) Well the first thing to jump out at me is that your if @error is after arraydisplay, so getting that error is actualy saying something went wrong with that(specifically, error 1 means what you are trying to display isn't an array). What is the error code coming off filelisttoarray? EDIT cause grammer is my friend.... Edited April 8, 2008 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
someone Posted April 8, 2008 Share Posted April 8, 2008 Hmm this is interesting... look at this code - create a folder with some folders in it, and leave the explorer window open... #Include <File.au3> #Include <Array.au3> WinActivate("[CLASS:CabinetWClass]", "") ;activate explorer $GetTextString = WinGetText("") $pos = StringInStr($GetTextString,@LF ) $folderpath = StringLeft($GetTextString, $pos) ;$folderpath = StringLeft($GetTextString, $pos -1) ClipPut($folderpath) ConsoleWrite($folderpath) MsgBox (0,"", $folderpath) $FileList =_FileListToArray($folderpath,"*", 2) If @error Then MsgBox(0, "error code", @error) EndIf _ArrayDisplay($FileList,"$FileList") If @Error=1 Then MsgBox (0,"","Not array.") Send("#r") ControlSetText("Run", "", "[CLASSNN:Edit1]", ClipGet()) Exit EndIf If you look, this will fail despite the message box containing what looks like the correct path. However, look at what gets pasted into the run dialog box.. to fix, uncomment the $pos -1 line, and comment the original. Is that a leftover linefeed character? While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
Pauletp Posted April 8, 2008 Author Share Posted April 8, 2008 Does the msgbox show "E:\abc\Script_test"?Yes, it does. Link to comment Share on other sites More sharing options...
Pauletp Posted April 8, 2008 Author Share Posted April 8, 2008 Hmm this is interesting... look at this code - create a folder with some folders in it, and leave the explorer window open... #Include <File.au3> #Include <Array.au3> WinActivate("[CLASS:CabinetWClass]", "") ;activate explorer $GetTextString = WinGetText("") $pos = StringInStr($GetTextString,@LF ) $folderpath = StringLeft($GetTextString, $pos) ;$folderpath = StringLeft($GetTextString, $pos -1) ClipPut($folderpath) ConsoleWrite($folderpath) MsgBox (0,"", $folderpath) $FileList =_FileListToArray($folderpath,"*", 2) If @error Then MsgBox(0, "error code", @error) EndIf _ArrayDisplay($FileList,"$FileList") If @Error=1 Then MsgBox (0,"","Not array.") Send("#r") ControlSetText("Run", "", "[CLASSNN:Edit1]", ClipGet()) Exit EndIf If you look, this will fail despite the message box containing what looks like the correct path. However, look at what gets pasted into the run dialog box.. to fix, uncomment the $pos -1 line, and comment the original. Is that a leftover linefeed character? Thank you for your help. That's done the trick. 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