Marco282 Posted July 2, 2014 Share Posted July 2, 2014 (edited) Hello people of autoit, I have been working on my program for quite some time now, but i am walking into some issues unfortanatly. The script handles downloads from a website which are quite big (700mb average) So depending on the internet speed this can take some time or not. I want the user to be able to hit a cancel button instead of killing the process to stop the download/program. The script runs 2 inetget in background mode and then does the script in the autoit tags. The function that all this is in is called upon by $downloadlatest = GUICtrlCreateButton("Download Latest",180,120,95,20) GUICtrlSetOnEvent(-1, "DownloadLatest") I already tried working with the guigetmsg() with switch and select function. Both ways no success. I also tried creating the cancel button within the while script using this: Global $cancelconvert = GUICtrlCreateButton("Cancel",300,150,80,20) GUICtrlSetOnEvent(-1, "Cancel_convert") and the cancel_convert function would kill the autopid. Also no success How would a proper cancel button be made in such a case? Thankyou! While Not InetGetInfo($INET, 2) ;Loop until download is finished Sleep(1000); $BytesReceived = InetGetInfo($INET, 0) ;Get bytes received $BytesReceived2 = InetGetInfo($INET2, 0) ;Get bytes received $BytesReceivedtotal = $BytesReceived+$BytesReceived2 $Pct = Int($BytesReceivedtotal / $FileSizetotal * 100) ;Calculate percentage GUICtrlSetData($downloadprogressbar, $Pct) GUICtrlSetData($downloadpercentagelabel, $Pct & "%") WEnd Edited July 2, 2014 by Marco282 Link to comment Share on other sites More sharing options...
dbzfanatic Posted July 3, 2014 Share Posted July 3, 2014 Instead of using -1 with your onevent code have you tried using the actual label? Like GuiCtrlSetOnEvent($downloadlates,"DownloadLatest")? You could also try putting a ConsoleWrite or MsgBox in there somewhere after your While Not loop to make sure it's actually going through properly. Let us know if either of those helps and we can go from there. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 3, 2014 Share Posted July 3, 2014 Follow this link - http://www.autoitscript.com/wiki/Interrupting_a_running_function. It is code written by Melba23, a well respected member here. It may or may not help you, but I believe it will. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Marco282 Posted July 3, 2014 Author Share Posted July 3, 2014 Instead of using -1 with your onevent code have you tried using the actual label? Like GuiCtrlSetOnEvent($downloadlates,"DownloadLatest")? You could also try putting a ConsoleWrite or MsgBox in there somewhere after your While Not loop to make sure it's actually going through properly. Let us know if either of those helps and we can go from there. This did not matter unfortanatly. The loop is running correctly, if i but a msgbox in, it pops up everytime. Maybe more explanation to how its run in the script. The mainscript calls $downloadlatest = GUICtrlCreateButton("Download Latest",180,120,95,20) GUICtrlSetOnEvent(-1, "Button3Click") Then button3click: Func Button3Click() ;Download LATEST check If GuiCtrlRead($highlightlatest) = $GUI_CHECKED then Convertcheckhighlight() Else Convertcheckbroadcast() EndIf EndFunc Func Convertcheckbroadcast() ;Check for converting last broadcast If GuiCtrlRead($checkautoconvertlatest) = $GUI_CHECKED then LatestBroadcastconvert() Else LatestBroadcast() EndIf EndFunc Then latestbroadcast is being called. Within that function is a while not during the download. And somdcomputerguy, it sounds like it would apply on my situation. Unfortanatly I dont seem to be able to implement it. Does the HotKeySet("x", "_Interrupt") even work when its in the mainscript and the script is running an onevent function? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted July 3, 2014 Share Posted July 3, 2014 (edited) And somdcomputerguy, it sounds like it would apply on my situation. Unfortanatly I dont seem to be able to implement it. Does the HotKeySet("x", "_Interrupt") even work when its in the mainscript and the script is running an onevent function? I don't have or run your script, so I don't know. Does it? Try it and see, Edited July 3, 2014 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Marco282 Posted July 5, 2014 Author Share Posted July 5, 2014 I don't have or run your script, so I don't know. Does it? Try it and see, It seems to not do anything, unfortanatly. So is there anyway, i can put code in the while loop where it checks for the GUI presses? It must be possible and somehow i am doing it wrong. Link to comment Share on other sites More sharing options...
guinness Posted July 15, 2014 Share Posted July 15, 2014 Sorry to bump, but look in my signature for _InetGetGUI() as an idea. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now