Jump to content

_Filecopy successful ?


memnon
 Share

Recommended Posts

_Filecopy("c:\a\*.*","c:\b")

Func _FileCopy($fromFile,$tofile)

Local $FOF_RESPOND_YES = 16

Local $FOF_SIMPLEPROGRESS = 256

$winShell = ObjCreate("shell.application")

$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)

EndFunc

the function works really great, but how can i check, if the copyprocess was sucessful ?

do i get any errorstatement back ?

das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

Link to comment
Share on other sites

You could after it do a check to see if it was made, or edit the function itself to return true if the new file exists

(see FileExists in the helpfile, i think)

[quick&dirty, untested]

Func _FileCopy($fromFile,$tofile)
Local $FOF_RESPOND_YES = 16
Local $FOF_SIMPLEPROGRESS = 256
$winShell = ObjCreate("shell.application")
$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
if FileExists($tofile) then
return true
else
return false
endif
EndFunc

again, not sure if that'll work, but should give you a general idea of possible ways to verify. Another idea could be to have it check if $fromfile has like *.txt or file.* use FileFindFirstFile/nextfile.

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

  • 3 weeks later...

#include <GUIConstants.au3>
#include <Misc.au3>
#include "DllCallBack.au3"

Global $pTimerProc, $uiTimer
Global $CopyingTitle = "Copying..."

$sCopy = CopyFile("d:\Video\Films\video.avi", "c:\")

MsgBox(64, "Success", "File copying successfuly")

Quit()

Func CopyFile($source, $dest)
    $WinShell = ObjCreate("shell.application")
    If Not @error Then
        InitializeCallBack(100)
        $WinShell.NameSpace($dest).CopyHere($source)
    Else
        MsgBox(16, "Error", "Obj not created")
    EndIf
EndFunc

Func InitializeCallBack($CallEvery, $FuncName="MyCallBackFunc")
    $pTimerProc = _DllCallBack($FuncName, "hwnd;uint;uint;dword")
    $uiTimer = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", $CallEvery, "ptr", $pTimerProc)
    $uiTimer = $uiTimer[0]
EndFunc

Func MyCallBackFunc($hWnd, $uiMsg, $idEvent, $dwTime)
    Opt("MouseCoordMode", 2)
    
    If WinExists($CopyingTitle) And WinActive($CopyingTitle) Then
        If _IsPressed(01) Then
            Local $mousePos = MouseGetPos()
            If $MousePos[0] > 303 And $MousePos[0] < 362 And $MousePos[1] > 102 And $MousePos[1] < 124 Then
                WinClose($CopyingTitle)
                MsgBox(16, "Error", "Copying aborted")
                Quit()
            EndIf
        EndIf
    EndIf
EndFunc

Func Quit($Exit=1)
    _DllCallBack_Free($pTimerProc)
    DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer)
    If $Exit Then Exit
EndFunc

DllCallBack.au3 you can get from here.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

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...