Jump to content
Sign in to follow this  
jonathanhafkamp

Stop function

Recommended Posts

jonathanhafkamp

Hey,

How can you stop an function while running that function? Like this:

#include <GuiConstants.au3>
GuiCreate("Example")
$button = GuiCtrlCreateButton("Click Me", 10, 10, 200, 200)
GuiSetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $button Then oops_Function_That_Forgets_To_Check_GuiGetMsg()
WEnd


Func oops_Function_That_Forgets_To_Check_GuiGetMsg()
    While 1
        sleep(100)
    WEnd
EndFunc

Share this post


Link to post
Share on other sites
Jos

Hey,

How can you stop an function while running that function? Like this:

<{POST_SNAPBACK}>

You could use HotKeySet() which enables you to loop until the specified keycombo is pressed....

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jonathanhafkamp

I want to use a button

Share this post


Link to post
Share on other sites
Jos

I want to use a button

<{POST_SNAPBACK}>

Then you will have to use GuiGetMsg() to see if the button is clicked.......

I guess iam not really understanding what you are trying to achieve here....

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MHz

You could use a second instance of GUIGetMsg() ?

Example:

#include <GuiConstants.au3>
GuiCreate("Example")
$button = GuiCtrlCreateButton("Click Me", 10, 10, 200, 30)
$button_out = GuiCtrlCreateButton("Click Me Out", 10, 50, 200, 30)
GuiSetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $button Then oops_Function_That_Forgets_To_Check_GuiGetMsg()
WEnd


Func oops_Function_That_Forgets_To_Check_GuiGetMsg()
    While 1
        $msg = GUIGetMsg()
        if $msg = $button_out Then ExitLoop
        sleep(100)
    WEnd
EndFunc

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  

×