MarioX Posted November 27, 2005 Share Posted November 27, 2005 (edited) I'm unable to stop a download in progress and quit the program... I know that the function to stop a download is InetGet("abort") How to correctly setup the abort routine ? Thanks for any advice Mario #include <GUIConstants.au3> GUICreate("Autoit download", 200, 100) $label = GUICtrlCreateLabel("Write here filename(with "".exe""):", 10, 10, 200, 20) $file = GUICtrlCreateInput("", 10, 30, 180, 20) $okbutton = GUICtrlCreateButton("Download", 10, 60, 60, 30) $quitbutton = GUICtrlCreateButton(" Quit ", 90, 60, 30) $read = GUICtrlCreateLabel("Bytes: ", 150, 60, 100, 40) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $okbutton Then If GUICtrlRead($file) = "" Then MsgBox(48, "AutoIt Download", "Please give an place to download to") Else GUISetState(@SW_DISABLE) GUICtrlSetData($label, "Downloading...") $size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe") $inet = InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", GUICtrlRead($file), 0, 1) While @InetGetActive $ToDown = $size - @InetGetBytesRead GUICtrlSetData($read, "Bytes to download: " &$ToDown) If $msg = $GUI_EVENT_CLOSE Then InetGet("abort") Sleep(125) Wend GUICtrlSetData($label, "File downloaded!") GUISetState(@SW_ENABLE) EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Edited November 27, 2005 by MarioX Link to comment Share on other sites More sharing options...
Developers Jos Posted November 27, 2005 Developers Share Posted November 27, 2005 You are not updating $msg in your download loop so it never detects $GUI_EVENT_CLOSE. Try: While @InetGetActive $ToDown = $size - @InetGetBytesRead GUICtrlSetData($read, "Bytes to download: " &$ToDown) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then InetGet("abort") Wend SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MarioX Posted November 27, 2005 Author Share Posted November 27, 2005 (edited) Thanks JdeB, I've added your code, but if I press the "X" close GUI the download is not stopped. The same happen if I change the code to use the Quit button: If $msg = $GUI_EVENT_CLOSE Then InetGet("abort") to If $msg = $quitbutton Then InetGet("abort") What's wrong ? Thanks again #include <GUIConstants.au3> GUICreate("Autoit download", 200, 100) $label = GUICtrlCreateLabel("Write here filename(with "".exe""):", 10, 10, 200, 20) $file = GUICtrlCreateInput("", 10, 30, 180, 20) $okbutton = GUICtrlCreateButton("Download", 10, 60, 60, 30) $quitbutton = GUICtrlCreateButton(" Quit ", 90, 60, 30) $read = GUICtrlCreateLabel("Bytes: ", 150, 60, 100, 40) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $okbutton Then If GUICtrlRead($file) = "" Then MsgBox(48, "AutoIt Download", "Please give an place to download to") Else GUISetState(@SW_DISABLE) GUICtrlSetData($label, "Downloading...") $size = InetGetSize("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe") $inet = InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", GUICtrlRead($file), 0, 1) While @InetGetActive $ToDown = $size - @InetGetBytesRead GUICtrlSetData($read, "Bytes to download: " &$ToDown) $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then InetGet("abort") Wend GUICtrlSetData($label, "File downloaded!") GUISetState(@SW_ENABLE) EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Edited November 27, 2005 by MarioX Link to comment Share on other sites More sharing options...
Developers Jos Posted November 27, 2005 Developers Share Posted November 27, 2005 Well what do you expect after you have done this command ? : GUISetState(@SW_DISABLE) Comment it out and try again... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MarioX Posted November 28, 2005 Author Share Posted November 28, 2005 Well what do you expect after you have done this command ? : GUISetState(@SW_DISABLE) Oh yes, after fixed the GUISetState now everything work fine, thanks for your help, really appreciated.Mario 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