Sign in to follow this  
Followers 0
smahdi83

Interrupt current action if Button is pressed

6 posts in this topic

Hello,

I have a script which does alot of processing and can take some time to finish. But I also want to include a button which gives the option to the user to stop the script at any given time.

Im using AutoItSetOption("GUIOnEventMode", 1), so each event has its own function.

The only problem is that once processing starts and I click on the stop button, the event only kicks in at the end of the script not during the script.

How can I create an interrupt to process the Stop button's event function?

Thanks,

Share this post


Link to post
Share on other sites



You should be able to use AdlibEnable().


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

You should be able to use AdlibEnable().

What function tells me if someone has clicked on a button. Like the state of the button has changed.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The proper thing to use is @GUI_CtrlId

Switch @GUI_CtrlId
        Case $your_button_here
              ;stuff to do here
EndSwitch

Put this in a function and it will work.

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Maybe GUIRegisterMsg()

I think this is the best way. The easiest method I found was like this

GUIRegisterMsg($WM_NOTIFY, "MY_WM_COMMAND")

Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    $nID            = BitAnd($wParam, 0x0000FFFF)
   
      ;if the control is the button and the left mouse is clicked 
    if $nID = $StopButton and _ispressed(1) then            
             $Stop = true
    endif
   
    Return $GUI_RUNDEFMSG
EndFunc

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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