Sign in to follow this  
Followers 0
AntiFros

How to exit this loop?

18 posts in this topic

Click start and it starts counting. When you click stop then it reacts and disable/enable buttons. But I dont know how to exit that loop or even whole func.

Code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


global $fInterrupt = 0

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
$stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
$Label1 = GUICtrlCreateLabel("Label1", 216, 72, 92, 17)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            GUICtrlSetState($Stop, $GUI_ENABLE)
            core()
    EndSwitch
WEnd



Func core()
AdlibRegister("_Interrupt",2000)

Local $i = 0


While 1

$i = $i + 1
Sleep(1000)
GUICtrlSetData($Label1,$i)
Wend


Endfunc






Func _Interrupt()
    If $fInterrupt Then
        Switch $fInterrupt
            Case 1
                    GUICtrlSetState($start, $GUI_ENABLE)
                    GUICtrlSetState($Stop, $GUI_DISABLE)

                $fInterrupt = 0
                Return True
            Case 2
                Exit
        EndSwitch
    EndIf
    Return False
EndFunc   ;==>_Interrupt

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0x0000FFFF) = $Stop Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Closure [X} pressed
    If BitAND($wParam, 0xFFF0) = 0xF060 Then
        $fInterrupt = 2
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites



Not the most elegant, but works:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


global $fInterrupt = 0

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
$stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
$Label1 = GUICtrlCreateLabel("Label1", 216, 72, 92, 17)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            GUICtrlSetState($stop, $GUI_ENABLE)
            core()
    EndSwitch
WEnd

Func core()
    AdlibRegister("_Interrupt", 100)
    Local $i = 0
    While 1
        If ControlCommand($Form1, "", $start, "IsEnabled") Then Return
        $i = $i + 1
        Sleep(1000)
        GUICtrlSetData($Label1, $i)
    Wend
Endfunc   ;==>core


Func _Interrupt()
    If $fInterrupt Then
        Switch $fInterrupt
            Case 1
                GUICtrlSetState($start, $GUI_ENABLE)
                GUICtrlSetState($stop, $GUI_DISABLE)

                $fInterrupt = 0
                Return True
            Case 2
                Exit
        EndSwitch
    EndIf
    Return False
EndFunc   ;==>_Interrupt

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0x0000FFFF) = $stop Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Closure [X} pressed
    If BitAND($wParam, 0xFFF0) = 0xF060 Then
        $fInterrupt = 2
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_SYSCOMMAND

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Sorry, forgot to mention that I want to stop lopp/ exit func without writing code into it.

If writing code into it then best way is to put   if _Interrupt then exitloop

 

The problem is that I have too much code which I need to stop. I need to put in like 50 lines "if _Interrupt then exitloop".

I want to do it easer.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I think this worked. Making While $loop = 1 instead of While 1 and when button clicked then it makes $loop = 0. So it stops. This is good way to do that?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


global $fInterrupt = 0, $loop = 1

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
$stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
$Label1 = GUICtrlCreateLabel("Label1", 216, 72, 92, 17)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            GUICtrlSetState($Stop, $GUI_ENABLE)
            core()
    EndSwitch
WEnd



Func core()
AdlibRegister("_Interrupt",2000)

Local $i = 0


While $loop = 1

$i = $i + 1
Sleep(1000)
GUICtrlSetData($Label1,$i)
Wend


Endfunc









Func _Interrupt()
    If $fInterrupt Then
        Switch $fInterrupt
            Case 1
                    GUICtrlSetState($start, $GUI_ENABLE)
                    GUICtrlSetState($Stop, $GUI_DISABLE)
                     $loop = 0
                $fInterrupt = 0
                Return True
            Case 2
                Exit
        EndSwitch
    EndIf
    Return False
EndFunc   ;==>_Interrupt

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0x0000FFFF) = $Stop Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Closure [X} pressed
    If BitAND($wParam, 0xFFF0) = 0xF060 Then
        $fInterrupt = 2
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc
Edited by AntiFros

Share this post


Link to post
Share on other sites

AntoFros,

Why so complicated? For something this simple just keep the code simple too: ;)

#include <GUIConstantsEx.au3>

Global $fRun = False

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
$stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
GUICtrlSetState($stop, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("0", 216, 72, 92, 17)
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            GUICtrlSetState($stop, $GUI_ENABLE)
            $nBegin = TimerInit()
            $fRun = True
        Case $stop
            GUICtrlSetState($start, $GUI_ENABLE)
            GUICtrlSetState($stop, $GUI_DISABLE)
            $fRun = False
    EndSwitch

    If $fRun And TimerDiff($nBegin) > 1000 Then
        GUICtrlSetData($Label1, GUICtrlRead($Label1) + 1)
        $nBegin = TimerInit()
    EndIf

WEnd
All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ahh can't explain with my bad english. Timer in my code is just easy way to see if loop still works or not.

The last code I posted works but loop stops after it finished everything what is in it.

I need to put something here

Func _Interrupt()
    If $fInterrupt Then
        Switch $fInterrupt
            Case 1
                GUICtrlSetState($start, $GUI_ENABLE)
                GUICtrlSetState($stop, $GUI_DISABLE)
  HERE/////////////////////////////////////////////////////////////
                $fInterrupt = 0
                Return True
            Case 2
                Exit
        EndSwitch
    EndIf
    Return False
EndFunc   ;==>_Interrupt

Code which would end loop in core() or stop whole core() func.

Edited by AntiFros

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

are you trying to exit from the while - wend loop within the core() function by an "external" event?

Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

AntiFros,

How about this script then: :)

#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $fInterrupt = 0

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
$stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
GUICtrlSetState($stop, $GUI_DISABLE)
$Label1 = GUICtrlCreateLabel("Label1", 216, 72, 92, 17)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            GUICtrlSetState($stop, $GUI_ENABLE)
            core()
    EndSwitch
WEnd

Func core()
    Local $i = 1, $nBegin = TimerInit()
    While 1

        If TimerDiff($nBegin) > 1000 Then
            $i = $i + 1
            GUICtrlSetData($Label1, $i)
            $nBegin = TimerInit()
        EndIf

        If $fInterrupt Then
            Switch $fInterrupt
                Case 1
                    $fInterrupt = False
                    GUICtrlSetState($start, $GUI_ENABLE)
                    GUICtrlSetState($stop, $GUI_DISABLE)
                    Return
                Case 2
                    Exit
            EndSwitch
        EndIf

        Sleep(10)

    WEnd


EndFunc   ;==>core

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0x0000FFFF) = $stop Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Closure [X} pressed
    If BitAND($wParam, 0xFFF0) = 0xF060 Then
        $fInterrupt = 2
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_SYSCOMMAND
Any better? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

are you trying to exit from the while - wend loop within the core() function by an "external" event?

Im trying to exit whole func. If I stop loop then func ends and it stops. So also I can directly exitfunc.

 Didnt understood half of your sentence but yes, Im trying to exit func outside it. Without any code in core() func.

 

 

Melba, nope. Ill probably just put "If _Interrupt() then exitloop" in every second line.

If there would be func like   ExitFunc(core)... :king:

Edited by AntiFros

Share this post


Link to post
Share on other sites

AntiFros,

In your original script, the core function had a loop - which is why I used one. If there is no loop then you are poorly placed to interrupt the function. Can you give us an idea of its internal structure - perhaps we might be able to suggest something. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Ahh can't explain with my bad english. Timer in my code is just easy way to see if loop still works or not.

The last code I posted works but loop stops after it finished everything what is in it.

I need to put something here

Func _Interrupt()
    If $fInterrupt Then
        Switch $fInterrupt
            Case 1
                GUICtrlSetState($start, $GUI_ENABLE)
                GUICtrlSetState($stop, $GUI_DISABLE)
  HERE/////////////////////////////////////////////////////////////
                $fInterrupt = 0
                Return True
            Case 2
                Exit
        EndSwitch
    EndIf
    Return False
EndFunc   ;==>_Interrupt

Code which would end loop in core() or stop whole core() func.

 

Please use code tags when you post your code.

Read "How to post code on the forum" from my singature.

mLipok


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

Is this anything like the functionality you desire?

HotKeySet("{ESC}", "_HotFunc")

_Main()

Func _Main()
    ConsoleWrite("_Main()" & @LF)
    While 3
        _func1()
        Sleep(2000)
    WEnd
EndFunc

Func _func1()
    ConsoleWrite("_func1()" & @LF)
    _func2()
EndFunc

Func _func2()
    ConsoleWrite("_func2()" & @LF)
EndFunc

Func _HotFunc()
    _Main()
EndFunc

Recursion is not always bad when used wisely, but I'd not advice it in a tight loop or if it's something which will be used very often in your script.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Ok, shortened my main code to show what Im doing here. Im collecting data about player (talking about game called Battlefield 2. This is NOT a game automation). This code are showing me if player is online, if he got any score and so  on. Just faster way to see what I can see also from surfing web.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <array.au3>
global $fInterrupt = 0

$oIE = _IECreate("http://37.187.75.29/bf2sclone/")

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
$stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
$Label1 = GUICtrlCreateLabel("Label1", 216, 72, 92, 17)
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
GUIRegisterMsg($WM_SYSCOMMAND, "_WM_SYSCOMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            GUICtrlSetState($Stop, $GUI_ENABLE)
            core()
    EndSwitch
WEnd



Func core()


_IELinkClickByText($oIE,"Scarred1.50")
Sleep(3000)
Local $oTable = _IETableGetCollection($oIE,0)
Local $aTableData = _IETableWriteToArray($oTable)
;_ArrayDisplay($aTableData)
While 1
; there code refreshes page every 1-5 mins (random)
;and gathers information.
;So if you quit loop then func ends. 
;there is about hundret lines of code mainly gathering tables, sleeps and _ielinkclicks. So I need easy way to stop it by pressing button.
Wend

Endfunc






Func _Interrupt()
    If $fInterrupt Then
        Switch $fInterrupt
            Case 1
                    GUICtrlSetState($start, $GUI_ENABLE)
                    GUICtrlSetState($Stop, $GUI_DISABLE)

                $fInterrupt = 0
                Return True
            Case 2
                Exit
        EndSwitch
    EndIf
    Return False
EndFunc   ;==>_Interrupt

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0x0000FFFF) = $Stop Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc

Func _WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    ; Closure [X} pressed
    If BitAND($wParam, 0xFFF0) = 0xF060 Then
        $fInterrupt = 2
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

Again, this is NOT game automation lol.

 

----Edit

JohnOne, where is button? lol.

Edited by AntiFros

Share this post


Link to post
Share on other sites

Obviously there is no button, what I have shown is a quick example of what functionality you might need.

It shows that it will leave any function and any loop anywhere in your script and return to it's main function.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Any way to do it without using hotkey?

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

another simple example:
you should declare a global variable (as you already done) for example global $fInterrupt = 0

then close all the functions that you want interrupt from the "outside" in a loop like this:

While Not $fInterrupt 
                   ; your code goes here
    WEnd

so when you want to exit just set the $fInterrupt to true (in this example by a checkbox)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $fInterrupt = 0, $loop = 1
AdlibRegister("_Interrupt", 500) ; check every half second if stop the loop(s)

$Form1 = GUICreate("Form1", 374, 184, 192, 124)
$start = GUICtrlCreateButton("start", 32, 32, 161, 49)
; $stop = GUICtrlCreateButton("stop", 32, 96, 161, 49)
$Label1 = GUICtrlCreateLabel("Label1", 216, 72, 92, 17)
Global $iCheckbox = GUICtrlCreateCheckbox("interrupt", 10, 10, 185, 25)

GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            GUICtrlSetState($start, $GUI_DISABLE)
            core() ; this starts the loop in the core() function
            GUICtrlSetState($start, $GUI_ENABLE)
            GUICtrlSetState($iCheckbox, $GUI_UNCHECKED)
    EndSwitch
WEnd

Func core()
    Local $i = 0
    While Not $fInterrupt ; $i$loop = 1
        $i = $i + 1
        Sleep(1000)
        GUICtrlSetData($Label1, $i)
    WEnd
EndFunc   ;==>core

Func _Interrupt()
    $fInterrupt = GUICtrlRead($iCheckbox) <> 4
EndFunc   ;==>_Interrupt
Edited by Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0