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.
once FileProgress is over half way done, cancel the transfer. Unfortunately, this does not cancel the transfer.
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
}