CHronologist Posted May 17, 2008 Share Posted May 17, 2008 Basically the code looks like this:CODE#include "GUIConstants.au3"GUICreate("Control", 300, 300)$exitbtn = GUICtrlCreateButton("Exit", 210, 40, 80, 30)$downbtn = GUICtrlCreateButton("Download", 10, 40, 80, 30)Opt("GUIOnEventMode", 1)GUICtrlSetOnEvent($exitbtn, "_exit")GUICtrlSetOnEvent($downbtn, "_down")GUISetState(@SW_SHOW)Global $loopcode = 1While 1;here runs a main routineWEndFunc _down()GUICtrlSetData($exitbtn, "Stop")While $loopcode = 1;do somethingWEndGUICtrlSetData($exitbtn, "Exit")$loopcode = 1EndFuncFunc _exit()If GUICtrlRead($exitbtn) = "Stop" Then$loopcode = 0ElseIf GUICtrlRead($exitbtn) = "Exit" ThenExitEndIfEndFuncI just cut out the important parts. The intention is that while the mainroutine is running the exitbutton should end the programm. If inside the _down function the exitbutton becomes a stopbutton and when this is pressed the variable $loopcode should become 0 so that the While-Loop in the _down function will stop the next time the loop head is tested. For some reason the _exit function is not called. Any suggestions? Thanks for every idea. Link to comment Share on other sites More sharing options...
ProgAndy Posted May 17, 2008 Share Posted May 17, 2008 (edited) You have to make a "Callback". If you donÄt use AdLib, then you can to it like this: CODE#include "GUIConstants.au3" GUICreate("Control", 300, 300) $exitbtn = GUICtrlCreateButton("Exit", 210, 40, 80, 30) $downbtn = GUICtrlCreateButton("Download", 10, 40, 80, 30) Opt("GUIOnEventMode", 1) GUICtrlSetOnEvent($exitbtn, "_exit") GUICtrlSetOnEvent($downbtn, "_down") GUISetState(@SW_SHOW) Global $loopcode = 0 While 1 ;here runs a main routine WEnd Func _down() If Not $loopcode Then AdlibEnable("_Count") ConsoleWrite("->Loop started" & @CRLF) Else ConsoleWrite("->Loop already running" & @CRLF) EndIf EndFunc Func _exit() If GUICtrlRead($exitbtn) = "Stop" Then ConsoleWrite("->Stopping Loop" & @CRLF) $loopcode = 0 ElseIf GUICtrlRead($exitbtn) = "Exit" Then Exit EndIf EndFunc Func _Count() AdlibDisable() ConsoleWrite("#Count Called" & @CRLF) GUICtrlSetData($exitbtn, "Stop") $loopcode = 1 While $loopcode = 1 ;do something ToolTip(@HOUR & ":" & @MIN & ":" & @SEC) Sleep(10) WEnd ToolTip("") ConsoleWrite("#Count Stopped" & @CRLF) GUICtrlSetData($exitbtn, "Exit") EndFunc Otherwise, you have to use the Timer UDF Edited May 17, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
sandin Posted May 17, 2008 Share Posted May 17, 2008 try with this: expandcollapse popup#include "GUIConstants.au3" GUICreate("Control", 300, 300) $exitbtn = GUICtrlCreateButton("Exit", 210, 40, 80, 30) $downbtn = GUICtrlCreateButton("Download", 10, 40, 80, 30) Opt("GUIOnEventMode", 1) GUICtrlSetOnEvent($exitbtn, "_exit") GUICtrlSetOnEvent($downbtn, "_down") GUISetOnEvent($GUI_EVENT_CLOSE, "_quit") $progress = GUICtrlCreateProgress(10, 120, 280) GUISetState(@SW_SHOW) Global $loopcode = 0, $over = 0, $i = 0 While 1 if $loopcode = 1 Then if $over = 0 Then $i += 1 Sleep(10) GUICtrlSetData($progress, $i) if $i = 100 then $over = 1 Else $i -= 1 Sleep(10) GUICtrlSetData($progress, $i) if $i = 0 then $over = 0 EndIf EndIf WEnd Func _down() GUICtrlSetState($downbtn, $GUI_DISABLE) $loopcode = 1 GUICtrlSetData($exitbtn, "Pause") GUICtrlSetData($downbtn, "Download") EndFunc Func _exit() GUICtrlSetState($downbtn, $GUI_ENABLE) If GUICtrlRead($exitbtn) = "Pause" Then $loopcode = 0 GUICtrlSetData($exitbtn, "Exit") GUICtrlSetData($downbtn, "Continue") ElseIf GUICtrlRead($exitbtn) = "Exit" Then _quit() EndIf EndFunc func _quit() Exit EndFunc Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
CHronologist Posted May 17, 2008 Author Share Posted May 17, 2008 (edited) Ok,works thank you for help. Edited May 17, 2008 by CHronologist 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