Jump to content

Recommended Posts

  • Developers
Posted (edited)

found the problem...

the $tofile is actually the $todirectory ... in other words, you cannot specify a new name but copy a sourcefile to another directory .....

Need to see how you can specify the Target filename...

Func _FileCopy($fromFile,$todirectory) 
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($todirectory).CopyHere($fromFile)
EndFunc
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

Thanks to all who replied with suggestions and JdeB for assisting offline.

I got it going and it works very nicely.

PeterF :)

Posted (edited)

Try this UDF...you can specify destination file name for copies also. (put @LF in b/w multiple sources)

Just call _ExplorerCopy($source, $dest, [bitOr($Option1,$Option2)] ) ; see Options at top of UDF file

The returns aren't as predictable as I would like them to be, but I'll look into it later.

*Requires Beta*

-Livewire

Global Const $FO_COPY                   = 0x0002        ; Copies the files specified in pFrom to the location specified in pTo
Global Const $FO_DELETE                 = 0x0003        ; Deletes the files specified in pFrom (pTo is ignored)
Global Const $FO_MOVE                   = 0x0001        ; Moves the files specified in pFrom to the location specified in pTo
Global Const $FO_RENAME                 = 0x0004        ; Renames the files specified in pFrom

Global Const $FOF_ALLOWUNDO             = 0x0040        ; Preserve Undo information, if possible
Global Const $FOF_CONFIRMMOUSE          = 0x0002        ; Not currently implemented
Global Const $FOF_FILESONLY             = 0x0080        ; Perform the operation on files only if a wildcard file name (*.*) is specified.
Global Const $FOF_MULTIDESTFILES        = 0x0001        ; The pTo member specifies multiple destination files (one for each sourcr file)
                                                            ; rather than one directory where all source files are to be deposited.
Global Const $FOF_NOCONFIRMATION        = 0x0010        ; Respond with "Yes to All" for any dialog box that is displayed.
Global Const $FOF_NOCONFIRMMKDIR        = 0x0200        ; Does not confirm the creation of a new directory if the operation requires one to be created.
Global Const $FOF_NOCOPYSECURITYATTRIBS = 0x0800        ; Do not copy NT file Security Attributes
Global Const $FOF_NOERRORUI             = 0x0400        ; No user interface will be displayed if an error occurs
Global Const $FOF_NORECURSION           = 0x1000        ; Do not recurse directories (i.e. no recursion into subdirectories)
Global Const $FOF_RENAMEONCOLLISION     = 0x0008        ; Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exisits.
Global Const $FOF_SILENT                = 0x0004        ; Does not display a progress dialog box
Global Const $FOF_SIMPLEPROGRESS        = 0x0100        ; Displays a progress box but does not show the file names
Global Const $FOF_WANTMAPPINGHANDLE     = 0x0020        ; If $FOF_RENAMEONCOLLISION is specified, the hNameMappings member will be filled in if any files were renamed

; These two apply in Internet Explorer 5 Environments
Global Const $FOF_NO_CONNECTED_ELEMENTS = 0x2000        ; Do not operate on connected elements
Global Const $FOF_WANTNUKEWARNING       = 0x4000        ; During delete operations, warn if permanent deleting instead of placing in recycle bin (partially overrides $FOF_NOCONFIRMATION)

; ????
Global Const $FOF_NORECURSEREPARSE      = 0x8000        ;

;$n = _CopyWithProgress("C:\Documents and Settings\All Users\Documents\shared\04.jpg" @LF & "C:\Documents and Settings\All Users\Documents\shared\11.jpg", "C:\Documents and Settings\Livewire\Desktop")
;MsgBox(0,"Testing","Success = " & $n)

Func _ExplorerCopy($source, $dest, $Options = 0)
    Local $SHFILEOPSTRUCT, $source_struct, $dest_struct
    Local $i, $aDllRet
    
    Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle
    $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr")
    If @error Then
        MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure")
        Return False
    EndIf
    
    $source_struct = DllStructCreate("char[" & StringLen($source)+2 & "]")
    DllStructSetData($source_struct, 1, $source)
    For $i = 1 To StringLen($source)+2
        If DllStructGetData($source_struct, 1, $i) = 10 Then DllStructSetData($source_struct, 1, 0, $i)
    Next
    DllStructSetData($source_struct, 1, 0, StringLen($source)+2)

    $dest_struct = DllStructCreate("char[" & StringLen($dest)+2 & "]")
    DllStructSetData($dest_struct, 1, $dest)
    DllStructSetData($dest_struct, 1, 0, StringLen($dest)+2)
    
    DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0)
    DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_COPY)
    DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($source_struct))
    DllStructSetData($SHFILEOPSTRUCT, $pTo, DllStructGetPtr($dest_struct))
    DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options)
    DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0)
    DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0)
    DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0)
    
    If _SHFileOperation($SHFILEOPSTRUCT) Then
        $aDllRet = DllCall("kernel32.dll", "long", "GetLastError")
        If @error Then MsgBox(4096,"Error","Error calling GetLastError")
        SetError($aDllRet[0])
        Return False
    ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then
        MsgBox(0,"Testing","Operation aborted")
        Return False
    EndIf
    Return True
EndFunc

Func _ExplorerMove($source, $dest, $Options = 0)
    Local $SHFILEOPSTRUCT, $source_struct, $dest_struct
    Local $i, $aDllRet
    
    Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle
    $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr")
    If @error Then
        MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure")
        Return False
    EndIf
    
    $source_struct = DllStructCreate("char[" & StringLen($source)+2 & "]")
    DllStructSetData($source_struct, 1, $source)
    For $i = 1 To StringLen($source)+2
        If DllStructGetData($source_struct, 1, $i) = 10 Then DllStructSetData($source_struct, 1, 0, $i)
    Next
    DllStructSetData($source_struct, 1, 0, StringLen($source)+2)

    $dest_struct = DllStructCreate("char[" & StringLen($dest)+2 & "]")
    DllStructSetData($dest_struct, 1, $dest)
    DllStructSetData($dest_struct, 1, 0, StringLen($dest)+2)
    
    DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0)
    DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_MOVE)
    DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($source_struct))
    DllStructSetData($SHFILEOPSTRUCT, $pTo, DllStructGetPtr($dest_struct))
    DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options)
    DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0)
    DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0)
    DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0)
    
    If _SHFileOperation($SHFILEOPSTRUCT) Then
        $aDllRet = DllCall("kernel32.dll", "long", "GetLastError")
        If @error Then MsgBox(4096,"Error","Error calling GetLastError")
        SetError($aDllRet[0])
        Return False
    ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then
        MsgBox(0,"Testing","Operation aborted")
        Return False
    EndIf
    Return True
EndFunc

Func _ExplorerDelete($path, $Options = 0)
    Local $SHFILEOPSTRUCT, $path_struct
    Local $nError = 0
    Local $i
    
    Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle
    $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr")
    If @error Then
        MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure")
        Return False
    EndIf
    
    $path_struct = DllStructCreate("char[" & StringLen($path)+2 & "]")
    DllStructSetData($path_struct, 1, $path)
    For $i = 1 To StringLen($path)+2
        If DllStructGetData($path_struct, 1, $i) = 10 Then DllStructSetData($path_struct, 1, 0, $i)
    Next
    DllStructSetData($path_struct, 1, 0, StringLen($path)+2)
    
    DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0)
    DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_DELETE)
    DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($path_struct))
    DllStructSetData($SHFILEOPSTRUCT, $pTo, 0)
    DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options)
    DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0)
    DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0)
    DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0)
    
    If _SHFileOperation($SHFILEOPSTRUCT) Then
        $aDllRet = DllCall("kernel32.dll", "long", "GetLastError")
        If @error Then MsgBox(4096,"Error","Error calling GetLastError")
        SetError($aDllRet[0])
        Return False
    ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then
        MsgBox(0,"Testing","Operation aborted")
        Return False
    EndIf
    Return True
EndFunc

Func _ExplorerRename($old_name, $new_name, $Options = 0)
    Local $SHFILEOPSTRUCT, $old_name_struct, $new_name_struct
    Local $nError = 0
    Local $i
    
    Local Enum $hwnd = 1, $wFunc, $pFrom, $pTo, $fFlags, $fAnyOperationsAborted, $hNameMappings, $lpszProgressTitle
    $SHFILEOPSTRUCT = DllStructCreate("int;uint;ptr;ptr;uint;int;ptr;ptr")
    If @error Then
        MsgBox(4096,"ERROR","Error creating SHFILEOPSTRUCT structure")
        Return False
    EndIf
    
    $old_name_struct = DllStructCreate("char[" & StringLen($old_name)+2 & "]")
    DllStructSetData($old_name_struct, 1, $old_name)
    For $i = 1 To StringLen($old_name)+2
        If DllStructGetData($old_name_struct, 1, $i) = 10 Then DllStructSetData($old_name_struct, 1, 0, $i)
    Next
    DllStructSetData($old_name_struct, 1, 0, StringLen($old_name)+2)

    $new_name_struct = DllStructCreate("char[" & StringLen($new_name)+2 & "]")
    DllStructSetData($new_name_struct, 1, $new_name)
    DllStructSetData($new_name_struct, 1, 0, StringLen($new_name)+2)
    
    DllStructSetData($SHFILEOPSTRUCT, $hwnd, 0)
    DllStructSetData($SHFILEOPSTRUCT, $wFunc, $FO_RENAME)
    DllStructSetData($SHFILEOPSTRUCT, $pFrom, DllStructGetPtr($old_name_struct))
    DllStructSetData($SHFILEOPSTRUCT, $pTo, DllStructGetPtr($new_name_struct))
    DllStructSetData($SHFILEOPSTRUCT, $fFlags, $Options)
    DllStructSetData($SHFILEOPSTRUCT, $fAnyOperationsAborted, 0)
    DllStructSetData($SHFILEOPSTRUCT, $hNameMappings, 0)
    DllStructSetData($SHFILEOPSTRUCT, $lpszProgressTitle, 0)

    If _SHFileOperation($SHFILEOPSTRUCT) Then
        $aDllRet = DllCall("kernel32.dll", "long", "GetLastError")
        If @error Then MsgBox(4096,"Error","Error calling GetLastError")
        SetError($aDllRet[0])
        Return False
    ElseIf DllStructGetData($SHFILEOPSTRUCT,$fAnyOperationsAborted) Then
        MsgBox(0,"Testing","Operation aborted")
        Return False
    EndIf
    Return True
EndFunc

Func _SHFileOperation(ByRef $lpFileOp)
    Local $aDllRet
    $aDllRet = DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($lpFileOp))
    If Not @error Then Return $aDllRet[0]
EndFunc
Edited by livewire
  • 2 months later...
  • 1 month later...
Posted (edited)

Hello Everybody.

An noob question from me. :">

How can i setup the Option to overwrite existing files with progress bar copy method from JdeB ?

If i set the ",1" switch the function doesnt work anymore, without ",1" no Problems and an Progessbar but an overwrite Question.

_FileCopy("C:\Temp1\file1.txt","C:\Temp2\",1)

doesnt work

thanks a lot

Edited by Kmike9k
  • 3 weeks later...
Posted

sO, JdeB, long time no chat... How would I get the return of the copy? So I know if it's been successful or not?

here's what windows uses:

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

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

"I'm not even supposed to be here today!" -Dante (Hicks)

  • 1 month later...
Posted (edited)

Hi,

how can i the script do work with multiple files??

;~ 4 Do not display a progress dialog box. 
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists. 
;~ 16 Respond with "Yes to All" for any dialog box that is displayed. 
;~ 64 Preserve undo information, if possible.
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified. 
;~ 256 Display a progress dialog box but do not show the file names. 
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created. 
;~ 1024 Do not display a user interface if an error occurs. 
;~ 2048 Version 4.71. Do not copy the security attributes of the file.
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories.
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.

_FileCopy("c:\temp\test.exe" ,"d:\temp1\")

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

It runs only with a specific file.

LG

Schnuecks

EDIT

I found my resolution in the UDF uses _ExplorerCopy

Edited by Schnuecks
  • 4 years later...
Posted

Can this be made to add a list of files? Say from a txt file?

here's what windows uses:

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

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

Posted

Do mean (for example) passing an Array of files to the "Windows Shell Copy Function?" As for now the only way to do would be using a For...Next Loop.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

  • 3 weeks later...
Posted

hey JdeB,

i am only trying to see it work right now. Other than file location, I think it is a copy of your post.

Is It?

Peter

;~ 4 Do not display a progress dialog box.

;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.

;~ 16 Respond with "Yes to All" for any dialog box that is displayed.

;~ 64 Preserve undo information, if possible.

;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.

;~ 256 Display a progress dialog box but do not show the file names.

;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.

;~ 1024 Do not display a user interface if an error occurs.

;~ 2048 Version 4.71. Do not copy the security attributes of the file.

;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories.

;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.

FileCopy("C:\Windows\temp\test3.tmp","C:\windows\temp\peter1.pjf")

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

How do i have progress bar for these...

DirCopy(@MyDocumentsDir, "C:\Backups\MyDocs")

DirCopy(@DesktopDir, "C:\Backups\Desktop")

MsgBox( 64, "Successful", "Backup Completed - Thank You")
  • 4 years later...
Posted (edited)

Jos' code COM CopyHere nearly does what I need. Here's my version:

_FileCopy("\\Andrew2\AutoIt-GUI\downloaded_from_cams", "C:\Users\Andrew\Google Drive\CHDK\Autoit\WIP\GUI\C.SlaveJmages")
_FileCopy("\\Andrew3\AutoIt-GUI\downloaded_from_cams", "C:\Users\Andrew\Google Drive\CHDK\Autoit\WIP\GUI\C.SlaveJmages")

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

So, it displays the Windows progress bar just as needed and copies the remote files as required (overwrites local, if they exist) - however, the local path includes the auto-created remote portion:

C:\Users\Andrew\Google Drive\CHDK\Autoit\WIP\GUI\C.Slaveimaqes\downloaded_from_cams

I'd prefer the files to be copied to the local dir without the remote extension, i.e. to:

C:\Users\Andrew\Google Drive\CHDK\Autoit\WIP\GUI\C.Slaveimaqes

Is that possible using COM (and associated Win based progress bar)?

(My note: also reviewed in connection with this:

)

 

Edited by newniman
  • 1 year later...
Posted

Help I have problems, conditions to assign this function in a graphical user interface

;=========== Koda GUI section=======================================
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 380, 169, 192, 154)
$Button1 = GUICtrlCreateButton("Button1", 72, 88, 177, 57)
$Input1 = GUICtrlCreateInput("Input1", 24, 8, 313, 21)
$Input2 = GUICtrlCreateInput("Input2", 24, 40, 313, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;======Function1============================================

Func Function1()

_FileCopy($Input1, $Input2)
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
EndFunc
;======Function1  End ==========================


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $nMsg= $button1
function1(); runs Button1 function
    EndSwitch
WEnd

I know the problem is in the "Function1 ()"
But I have no idea how to write it in Autoit
Someone who can give me a hand?

Posted

The function _FileCopy already exists so there is no need for the other function for example:

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Form1", 380, 169, 192, 154)
$Button1 = GUICtrlCreateButton("Copy", 72, 88, 177, 57)
$idSource = GUICtrlCreateInput(@ScriptFullPath, 24, 8, 313, 21)
$idTarget = GUICtrlCreateInput(@ScriptDir & "\ScriptCopy\", 24, 40, 313, 21)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            $sSource = GUICtrlRead($idSource)
            $sTarget = GUICtrlRead($idTarget)
            If FileExists($sSource) = 0 Or $sTarget = "" Then ContinueLoop
            _FileCopy($sSource, $sTarget)
    EndSwitch
WEnd

Func _FileCopy($sCopySource,$sCopyTargetDir)
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    If Not FileExists($sCopyTargetDir) Then DirCreate($sCopyTargetDir)
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($sCopyTargetDir).CopyHere($sCopySource,$FOF_RESPOND_YES)
EndFunc

 

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
  • Recently Browsing   0 members

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