Jump to content

GUICtrlCreateEdit stream file copy


Recommended Posts

Trying to think of a way to stream a filecopy to an editbox (GUICtrlCreateEdit), so it says like "copying files -filename-". Tried using GUICtrlSetData but that didn't work. Any ideas or examples would be helpful.

I'm not sure what you want to display in the edit box, but if you mean you want to have a line added saying "Copying..." each time a new file is copied then see the help for the optional parameters for GuiCtrSetData.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Sorry, I forgot to add my try at it. I'm using a Func to copy a group of files (example below), so when they copy I want this editbox to show "Copying -this file to there-". So when the first file finishes copying, the second file starts and says "Copying -this file to here-" under "Copying -this file to there-"

$Ok = GUICtrlCreateButton("Go", 252, 308, 40, 24)
$BE = GUICtrlCreateEdit("", 7, 80, 286, 228,$ES_READONLY)

Func _02()
_CopyWithProgress("CA\AudiMgr_AM_Auble.dll", "Test\AudioPluginMgr\AM_Auble.dll")
_CopyWithProgress("CA\AudiMgr_AM_mpPP.dll", "Test\AudioPluginMgr\AM_mpPP.dll")
_CopyWithProgress("CA\AudiMgr_AM_mppro.dll", "Test\AudioPluginMgr\AM_mppro.dll")
EndFunc

Func _CopyWithProgress($SourceFile, $DestFile)
    $Source = FileOpen($SourceFile, 16)
    If $Source = -1 Then; Check that file open was successful
        MsgBox(16, "Error", "Unable to open source file: " & $SourceFile)
        Return 0
    EndIf
    $Dest = FileOpen($DestFile, 26)
    If $Dest = -1 Then
        MsgBox(16, "Error", "Unable to open destination file: " & $DestFile)
        Return 0
    EndIf
    $SourceSize = FileGetSize($SourceFile)
    $Chunks = $SourceSize / 2048
    ProgressOn("File Copy", "Copying...", "Source: " & $SourceFile & @LF & "Dest: " & $DestFile)
    For $i = 0 to $Chunks
        $Data = FileRead($Source, 2048)
        FileWrite($Dest, $Data)
        ProgressSet(($i / $Chunks) * 100)
    Next
    FileClose($Dest)
    FileClose($Source)
    ProgressOff()
    If FileGetSize($DestFile) = $SourceSize Then Return 1
    Return 0
EndFunc

While 1
    $msg = GUIGetMsg()
    Switch $msg 
        Sleep(10)
            
        Case $Ok
            _02()
    
        Case -3
            Exit    
    EndSwitch
WEnd

I have tried a few ways, surrounding the Copy progress. And it just displays a "1".

GuiCtrlSetData($BE, _CopyWithProgress("CA\AudiMgr_AM_Auble.dll", "Test\AudioPluginMgr\AM_Auble.dll"))

Also.

Case $Ok
             GuiCtrlSetData($BE, _02())

Any Ideas? I know it's going to be simple. :mellow:

Edited by thexshadow
Link to comment
Share on other sites

Sorry, I forgot to add my try at it. I'm using a Func to copy a group of files (example below), so when they copy I want this editbox to show "Copying -this file to there-". So when the first file finishes copying, the second file starts and says "Copying -this file to here-" under "Copying -this file to there-"

$Ok = GUICtrlCreateButton("Go", 252, 308, 40, 24)
$BE = GUICtrlCreateEdit("", 7, 80, 286, 228,$ES_READONLY)

Func _02()
_CopyWithProgress("CA\AudiMgr_AM_Auble.dll", "Test\AudioPluginMgr\AM_Auble.dll")
_CopyWithProgress("CA\AudiMgr_AM_mpPP.dll", "Test\AudioPluginMgr\AM_mpPP.dll")
_CopyWithProgress("CA\AudiMgr_AM_mppro.dll", "Test\AudioPluginMgr\AM_mppro.dll")
EndFunc

Func _CopyWithProgress($SourceFile, $DestFile)
 $Source = FileOpen($SourceFile, 16)
 If $Source = -1 Then; Check that file open was successful
 MsgBox(16, "Error", "Unable to open source file: " & $SourceFile)
 Return 0
 EndIf
 $Dest = FileOpen($DestFile, 26)
 If $Dest = -1 Then
 MsgBox(16, "Error", "Unable to open destination file: " & $DestFile)
 Return 0
 EndIf
 $SourceSize = FileGetSize($SourceFile)
 $Chunks = $SourceSize / 2048
 ProgressOn("File Copy", "Copying...", "Source: " & $SourceFile & @LF & "Dest: " & $DestFile)
 For $i = 0 to $Chunks
 $Data = FileRead($Source, 2048)
 FileWrite($Dest, $Data)
 ProgressSet(($i / $Chunks) * 100)
 Next
 FileClose($Dest)
 FileClose($Source)
 ProgressOff()
 If FileGetSize($DestFile) = $SourceSize Then Return 1
 Return 0
EndFunc

While 1
    $msg = GUIGetMsg()
    Switch $msg 
        Sleep(10)
            
        Case $Ok
            _02()
    
        Case -3
            Exit    
    EndSwitch
WEnd

I have tried a few ways, surrounding the Copy progress. And it just displays a "1".

GuiCtrlSetData($BE, _CopyWithProgress("CA\AudiMgr_AM_Auble.dll", "Test\AudioPluginMgr\AM_Auble.dll"))

Also.

Case $Ok
 GuiCtrlSetData($BE, _02())

Any Ideas? I know it's going to be simple. :mellow:

I assume that you didn't write that function.

After it says ProgressON in the function why not add a line which is something like

GuiCtrlSetData(*$Be,"Copying " & $SourceFile &" to " & $DestFile & @CRLF,1); omit ,1 if you do not want more than one line.

Nothing is returned from the function so using

GuiCtrlSetData($BE, _CopyWithProgress("CA\AudiMgr_AM_Auble.dll", "Test\AudioPluginMgr\AM_Auble.dll")

is going to put nothing in the edit.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...