Jump to content

Library:Files list to notepad display


Laymanball
 Share

Recommended Posts

Show file list in the notepad as listview.

;====================Library===========================
Func _FilesListToNotepadDisPlay($sPath)
    $hSearch = FileFindFirstFile($sPath&'\*.*')
    If $hSearch = -1 Then
    MsgBox(0, "Error!", "No files/directories matched the search pattern")
    Return
    EndIf
    $output = ""
    Do
    $sFile = FileFindNextFile($hSearch)
    $output = $output&$sFile&@CRLF
    Until $sFile = ''
    FileClose($hSearch)
    Run("Notepad.exe")
    WinWait("[Class:Notepad]")
    ControlSetText("[Class:Notepad]", "", "Edit1", $output)
    WinSetTitle("[Class:Notepad]", "", "Files list to notepad display [Library]")
    WinMove("[Class:Notepad]", "", 216, 200, 572, 305)
    Return
EndFunc ;==>FilesListToNotepadDisPlay
;============================================================

;===================Sample Script=========================
$sFiles = FileSelectFolder("Select a drive or folder", @DesktopDir, 2)
If(@error)Or(Not $sFiles)Then Exit
_FilesListToNotepadDisPlay($sFiles)
;============================================================

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

This is rather useless to the general public here. Please consider not using the example forum as your personal snippet archive. There are plenty of useful scripts in here that can assist you with that task however.

Edited by wraithdu
Link to comment
Share on other sites

modify code.

Save as file.log. When exit notepad.

;=================================Library========================================
#Include <File.au3>
Func _FilesListToNotepadDisPlay($sPath)
    $hSearch = FileFindFirstFile($sPath&'\*.*')
    If $hSearch = -1 Then
    MsgBox(0, "Error!", "No files/directories matched the search pattern")
    Return
    EndIf
    $output = ""
    Do
    $sFile = FileFindNextFile($hSearch)
    $output = $output&$sFile&@CRLF
    Until $sFile = ''
    FileClose($hSearch)
    Run("Notepad.exe")
    WinWait("[Class:Notepad]")
    ControlSetText("[Class:Notepad]", "", "Edit1", $output)
    WinSetTitle("[Class:Notepad]", "", "Files list Info")
    WinMove("[Class:Notepad]", "", 216, 200, 572, 305)
    $Text = ControlGetText("[Class:Notepad]", "", "Edit1")
    If WinWaitNotActive("[Class:Notepad]")Then
    $btn = MsgBox(36, "", "Do you wanted save file.log")
    If $btn <> 7 Then _FileWriteLog(@DesktopDir&"\Files List.log", ""&@CRLF&$Text)
    EndIf
    Return
EndFunc ;==>FilesListToNotepadDisPlay
;=================================================================================

;========================Sample Script================================
$sFiles = FileSelectFolder("Select a drive or folder", @DesktopDir, 2)
If(@error)Or(Not $sFiles)Then Exit
_FilesListToNotepadDisPlay($sFiles)
;=====================================================================

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

Why in the world are you sending it to Notepad with the variable $output, and then reading the contents of Notepad and putting it into $Text to save it to a file? Just save the $output information directly to the file and avoid the whole BS of using Notepad in the first place.

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 Gude
How 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

Link to comment
Share on other sites

I get the impression the author is a beginner, so I don't know why the fury accompanys the tips.

@ Laymanball: I was not asking you to alter the code, my question was a general one that notepad usually asks to be saved when its contents have changed.

I'm going to assume for now its something to do with the owner, but I'm just guessing.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

FileReadToTextDisPlay

Discription:Read File.txt and Display with MessageBox.

;========FileAppend Library Include========
Func _FileAppend($Text, $Filename)
    $Ret = FileWrite($Filename, $Text)
    If($Ret=0)Then Return SetError(1, 0, 0)
    Return $Ret
EndFunc ;==>FileAppend

;=========FileReadToTextDisPlay Library=====================
Global $Filename
Func _FileReadToTextDisPlay($Filename)
   $Ret = FileRead($Filename)
   If Assign("Filename", $Ret) Then MsgBox(4096, "", $Filename)
   Return
EndFunc

;==========================Sample Script=================================
If Not FileExists("Test.txt")Then _FileAppend("Hello World!", "Test.txt")
_FileReadToTextDisPlay("Test.txt")

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

BrewManHN

JohnOne

'Thanks to the guidance. I stopped post code.'

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...