Sign in to follow this  
Followers 0
sak

Find the file and copy

6 posts in this topic

May search the file you want is easier. If you use this program.

If there are errors where additional help with editing. :)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$hForm = GUICreate("File Search Manager", 410, 204, -1, -1)
$Inp_foldpath = GUICtrlCreateInput("", 16, 32, 300, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY))
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Lbl_pathname = GUICtrlCreateLabel("Directory path", 128, 15, 70, 17)
$Btn_select = GUICtrlCreateButton("Browse", 320, 30, 75, 25, $WS_GROUP)
$Lbl_statname = GUICtrlCreateLabel("Search file:.....................................Status", 24, 128, 284, 17)
$Btn_find = GUICtrlCreateButton("Search", 152, 168, 75, 25, $WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetCursor(-1, 0)
$Inp_filefind = GUICtrlCreateInput("", 88, 88, 161, 21, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN))
$Lbl_info = GUICtrlCreateLabel("Enter: file name to search", 107, 71, 150, 17)
GUISetState(@SW_SHOW)

Local $dlgmessage = 'Choose a Folder'

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Btn_select
            $tablefiles = FileSelectFolder($dlgmessage, "", 0, "", $hForm)
            If @error Then ContinueLoop
            GUICtrlSetData($Inp_foldpath, $tablefiles)
            GUICtrlSetState($Btn_find, $GUI_ENABLE)
        Case $Btn_find
            If GUICtrlRead($Inp_filefind) = '' Then
                MsgBox(0, "", "Please enter the file name to search in the box.")
                ContinueLoop
            EndIf
            $varfile = GUICtrlRead($Inp_filefind)
            $sourcefiles = FileFindFirstFile($tablefiles&'\*.*')
            While 1
                $search = FileFindNextFile($sourcefiles)
                If @error Then ExitLoop
                GUICtrlSetData($Lbl_statname, 'Searching file: '& $search)
                Sleep(50)
                If $varfile = $search  Then
                    $btn = MsgBox(33, "", 'Found.. '& $search & ' ..Copy to the desktop.')
                    If $btn = 1 Then
                        FileCopy($tablefiles&'\'&$search, @DesktopDir, 1)
                    EndIf
                    ExitLoop
                EndIf
            WEnd
                If $search <> $varfile Then
                    MsgBox(64, "", 'Can not find file.')
                EndIf
                    FileClose($sourcefiles)
                    GUICtrlSetData($Lbl_statname, 'Search file:.....................................Done.')
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



When I look at your code, it's good, but why do you use a Sleep(50) in the loop what's searching for a file???

By Example: When I want to search a file what's in the system32 directory (which contains 2353 files on my XP system) and you're not lucky because the file you want to search is the last file in the folder, you have to wait about 2353 * 50 ms \ 1000 = 117,65 seconds = almost 2 minutes!!! :P

And that's then the minimal waiting time!! There's also about a few milliseconds a file for FileFindNextFile() and I think it would totally take about 3 or 4 minutes to search for that file. :) I prefer the standard Explorer, browse to the folder where the file exists and just copy the file to where I want. If you want to use this program, I'll suggest to sleep less, about 10 ms, is enough I think, that's about 5 times faster! :)

But it's good for your AutoIt skills :D .


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

can u teach me how to find and make a list of the file i have in the folder ?

Share this post


Link to post
Share on other sites

Skykaiwen,

Explain your question better, and preferably in the General Help And Support forum.

But do you mean a list of the files I have in the folder.

You have to make that list on your own I think. Look in the helpfile for FileFindFirstFile() and FileFindNextFile(). And I thought Melba32 made a UDF you want, I think....


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

AppTux

I find the time delay to slow down the file.

Because I want to see a running list of files.

Good Thanks for the advice.

Edited by sak

Share this post


Link to post
Share on other sites

sak,

You really want to see a useless list of files?? Yeah right. For you, but not for everyone. The most people hates to wait long before the file is found. The method of searching file is good, but if you want that other people use this program, then will I adjust the sleep value to 10 or something like that :) .

PS: Can't you speak a bit clearer English?? Your English looks like Google Translate. :)


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
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
Sign in to follow this  
Followers 0