Help with WinSCP and ahk (cancelling a transfer while in progress)

Advertisement

julesverneonthweb
Joined:
Posts:
1

Help with WinSCP and ahk (cancelling a transfer while in progress)

DISCLAIMER: Posted this on WinSCP.ahk git by lipKau using the example he provided. ONLY cause I'm not entirely sure it is still being maintained. Also will be posting to the ahk forums in case it's an ahk thing.

I'm trying to add in a cancel option to this function by using the example that Martin (the WinSCP dev) suggested here for C#. Cancel file transfers while transferring file to destination However, it does not seem to work here. Example of what I've added.
session_FileTransferProgress(sender, e)
{
   ;Parse e Properties
   RegExMatch(e.FileName, ".*\\(.+?)$", match)
   FileName        := match1
   CPS             := Round(e.CPS / 1024)
   FileProgress    := Round(e.FileProgress * 100)
   OverallProgress := Round(e.OverallProgress * 100)
   action          := (e.Side==0) ? "Uploading" : "Downloading"
   
   ;Change GUI elements
   GuiControl,, txtTitle, % action " @ " CPS " kbps"
   GuiControl,, edtFileName, % FileName
   GuiControl,, proFileName, % FileProgress
   GuiControl,, proOverall, % OverallProgress
        if (FileProgress > 50)
        {
            try {
                        e.Cancel := "true" ; I've tried boolean values of 0 and 1. I've tried true as both a string and an expression.
                      ; e.Cancel           ; I've also tried this. commented out here to avoid confusion.
             } catch e {
                       ; unfortunately I haven't been able to catch the error either. Not sure if there even is a way to view the error as ahk debug doesn't show a message.
           }
        }
   if (OverallProgress==100)
      GuiControl, Enable, btnClose
   
   ;Show GUI
   Gui, Show, , File Transfere
}
once FileProgress is over half way done, cancel the transfer. Unfortunately, this does not cancel the transfer.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,243
Location:
Prague, Czechia

Re: Help with WinSCP and ahk (cancelling a transfer while in progress)

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Advertisement

You can post new topics in this forum