trying to add a cancel option to this function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
julesverne
Posts: 42
Joined: 18 Apr 2017, 14:39
Contact:

trying to add a cancel option to this function

20 Apr 2023, 15:08

DISCLAIMER: Posted this on WinSCP.ahk git by lipKau https://github.com/lipkau/WinSCP.ahk/blob/master/Examples/file_upload_with_progressbar.ahk using the example he provided. ONLY because I'm not entirely sure it is still being maintained. Also posted to the WinSCP forums in case it's a WinSCP thing. https://winscp.net/forum/viewtopic.php?p=116758#116758 Posting here in case it's an ahk user error 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#. 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
}
This is obviously just a test, once FileProgress is over half way done, cancel the transfer. Unfortunately, this does not cancel the transfer.
Last edited by gregster on 20 Apr 2023, 15:12, edited 1 time in total.
Reason: Added a provisional topic title, because there was none.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 99 guests