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#. https://stackoverflow.com/questions/43648544/cancel-file-transfers-while-transferring-file-to-destination However, it does not seem to work here. Example of what I've added.
Code: Select all
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
}