Jump to content

Stop a running script with a button.


cxzzD
 Share

Recommended Posts

Hello again.

The title says it all, I've got this script that starts when I press a button. I also have this other button that is supposed to stop the script and exit the program, however, as soon as I press the start button, the Stop button won't work. If I on the other hand press the Stop button before the script runs, the program exits directly.

I'm quite sure I know why this happens, but I have no clue how to fix this.

My thoughts would be something like.

--------------------------------------------------------------

If $button2 = isClicked <-- (I know, no such command) then

Exit 0

endif

--------------------------------------------------------------

But can't seem to find that command.

Here is the code atleast..

#include <NomadMemory.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("IP ftw", 625, 443, 192, 124)
$Label1 = GUICtrlCreateLabel(" ", 8, 32, 84, 25)
$Label2 = GUICtrlCreateLabel("", 8, 104, 84, 33)
$Label3 = GUICtrlCreateLabel("", 8, 176, 84, 42)
$Button1 = GUICtrlCreateButton("Start", 8, 360, 257, 57, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Stop", 300, 360, 257, 57, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


HotKeySet("{F7}", "_terexit")
Func _terexit()
    Exit 0
EndFunc   ;==>_terexit

Global $Stop = 1


Func _start()
    Global $1 = 1
    Global $2 = 1
    Global $3 = 1

    If WinActive("Google Chrome") Then
    Else
        MsgBox(0, "", "Process was not found.")
    EndIf
    WinWaitActive("Google Chrome") ;Start your chrome.
    $Start = 1
    If $Start = 1 Then
        Sleep(2000)

        Send("{TAB 11}")
        Sleep(3500)
        Send("{Enter}")
        Sleep(12000)
        Send("******")
        Sleep(200)
        Send("{Enter}")
        $Start += 1
    EndIf

    WinWaitActive("NetClient") 

    While $1 = 1
        $startFind = PixelSearch(321, 142, 1597, 937, 0x900000)
        If IsArray($startFind) = True Then
            MouseMove($startFind[0], $startFind[1], 5)
            Sleep(9000)
            MouseClick("left")
            Sleep(1000)
            $1 += 1
        EndIf
    WEnd

    While $2 = 1
        $Custom = PixelSearch(321, 142, 1597, 937, 0xBFBF99)
        If IsArray($Custom) = True Then
            MouseMove($Custom[1], $Custom[1], 5)
            Sleep(1000)
            MouseClick("left")
            Sleep(1000)
            $2 += 1
        EndIf
    WEnd

    MouseMove(602, 866, 5)
    Sleep(500)
    MouseClick("left")
    Sleep(1000)
    Send("epic")
    Send("{Tab}")
    Send("fist")
    MouseMove(544, 873, 5)
    Sleep(500)
    MouseClick("left")
    Sleep(500)
    MouseMove(783, 598, 5) 
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    MouseMove(1255, 596, 5)
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseClick("left")
    Sleep(1000)
    MouseMove(1175, 635, 5)
    MouseClick("left")
    Sleep(5000)
    MouseMove(763, 419, 5)
    Sleep(1500)
    MouseClick("left")
    Sleep(300)
    MouseMove(1189, 646, 5)
    Sleep(1000)
    MouseClick("left")
    Sleep(40000)


    While $3 = 1
        $Lot = PixelSearch(1388, 698, 1582, 885, 0xA50FB4)
        If IsArray($Lot) = True Then
            MouseMove($Lot[0], $Lot[1], 5)
            MouseClick("right")
        EndIf
    WEnd
EndFunc   ;==>_start

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _start()
        Case $Button2           
            Exit 0
    EndSwitch
WEnd

Thanks in advance :x

Edited by cxzzD
Link to comment
Share on other sites

  • Moderators

cxzzD,

The Interrupting a running function tutorial in the Wiki will explain how to do it. :x

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

I found that tutorial quite hard to follow. Does anyone know an easier way of doing this or a more clear tutorial?

My head began spining around when I saw all that code (They've used 3 different stop things in the same code), I couldn't figure out what part of the code did what..

Link to comment
Share on other sites

  • Moderators

cxzzD,

As I wrote the tutorial I am disappointed that you found it hard to follow - perhaps I need to rewrite it. :P

This is the example code reduced to just what is needed for your case. You are using lots of Sleep lines during which your script is completely inactive. So use the _Waiter function as in the following script instead - it looks for the interruption and you will be able to break out of your function just like the test one here:

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

; Declare a flag
$fInterrupt = 0

$hGUI = GUICreate("Test", 500, 500)

$hButton_1 = GUICtrlCreateButton("Start", 10, 10, 80, 30)
$hButton_2 = GUICtrlCreateButton("End", 10, 50, 80, 30)

GUISetState()

; Intercept Windows command messages with out own handler
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_1
            _Func_1()
    EndSwitch
WEnd

Func _Func_1()
    ; Make sure the flag is cleared
    $fInterrupt = 0
    For $i = 1 To 20

        ; Show we are running
        ConsoleWrite("-Running" & @CRLF)

        ; Use this instead of Sleep as it looks for the flag rather than being inactive
        _Waiter(100)

    Next
    ; Ended normally
    ConsoleWrite(">Ended" & @CRLF)
EndFunc

Func _Waiter($iDelay)

    $iBegin = TimerInit()
    ; Start a loop for the required time
    Do
        Sleep(10)
        ; And check if the flag is set
        If $fInterrupt Then
            ; If it is then exit
            ConsoleWrite("!Interrrupted" & @CRLF)
            Exit
        EndIf
    Until TimerDiff($iBegin) > $iDelay
    Return 0

EndFunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    ; The Exit button was pressed so set the flag
    If BitAND($wParam, 0x0000FFFF) =  $hButton_2 Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Is that easier to understand? Please ask if you have any questions - the idea is that you get your script to run as you wish. :x

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

As I wrote the tutorial I am disappointed that you found it hard to follow - perhaps I need to rewrite it. :x

No, I think its very understandable for the Novice and Advanced user. This is how I learnt about WM_COMMAND!

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

cxzzD,

As I wrote the tutorial I am disappointed that you found it hard to follow - perhaps I need to rewrite it. :shifty:

This is the example code reduced to just what is needed for your case. You are using lots of Sleep lines during which your script is completely inactive. So use the _Waiter function as in the following script instead - it looks for the interruption and you will be able to break out of your function just like the test one here:

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

; Declare a flag
$fInterrupt = 0

$hGUI = GUICreate("Test", 500, 500)

$hButton_1 = GUICtrlCreateButton("Start", 10, 10, 80, 30)
$hButton_2 = GUICtrlCreateButton("End", 10, 50, 80, 30)

GUISetState()

; Intercept Windows command messages with out own handler
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton_1
            _Func_1()
    EndSwitch
WEnd

Func _Func_1()
    ; Make sure the flag is cleared
    $fInterrupt = 0
    For $i = 1 To 20

        ; Show we are running
        ConsoleWrite("-Running" & @CRLF)

        ; Use this instead of Sleep as it looks for the flag rather than being inactive
        _Waiter(100)

    Next
    ; Ended normally
    ConsoleWrite(">Ended" & @CRLF)
EndFunc

Func _Waiter($iDelay)

    $iBegin = TimerInit()
    ; Start a loop for the required time
    Do
        Sleep(10)
        ; And check if the flag is set
        If $fInterrupt Then
            ; If it is then exit
            ConsoleWrite("!Interrrupted" & @CRLF)
            Exit
        EndIf
    Until TimerDiff($iBegin) > $iDelay
    Return 0

EndFunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    ; The Exit button was pressed so set the flag
    If BitAND($wParam, 0x0000FFFF) =  $hButton_2 Then $fInterrupt = 1
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_COMMAND

Is that easier to understand? Please ask if you have any questions - the idea is that you get your script to run as you wish. :x

M23

I think ill try to understand the more basic things before I try this again. Seems like im too much of a dumbass to get this.

Thanks for your time though, really appreciate it.

Any ideas for simple tasks to do?

I remember when I was learning c# that there was a couple of websites dedicated to create simple tasks that you were supposed to finish to move on, anything similar? :P

Link to comment
Share on other sites

Any ideas for simple tasks to do?

I remember when I was learning c# that there was a couple of websites dedicated to create simple tasks that you were supposed to finish to move on, anything similar? :x

I would suggest looking at C:\Program Files\AutoIt3\Examples to get an idea of simple examples.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

cxzzD,

I was serious when I said that I wanted to make sure you could code as you wanted. What is about the code I posted that makes it hard to understand? I am happy to explain any of it in more detail if required. :x

guinness,

Thanks you for the compliment - I did try to make the tutorial understandable. :P

M23

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

Open spoiler to see 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

 

Link to comment
Share on other sites

I stumbled onto that thing more than once. No matter how people say it's easy. It isn't. Melba23 did wonderful explanations in this I made. I didn't got it to work and I didn't understood too, help it isn't the same for you. Anyway, I'm planning to learn it.

A friend of mine shown this solution, which is really EASY to understand:

Just use GuiOnEventMode to do your gui and all will work fine.

A little example:

Opt("GUIOnEventMode", 1)

HotKeySet("{F1}", "_Start")
HotKeySet("{F2}", "_Pause")
HotKeySet("{F3}", "_Exit")

$IsPaused=1

$GUI=GUICreate("test", 300, 40)
GUISetOnEvent(-3, "_Exit")
GUICtrlCreateButton("Start", 10, 10, 80, 17)
GUICtrlSetOnEvent(-1, "_Start")
GUICtrlCreateButton("Pause", 110, 10, 80, 17)
GUICtrlSetOnEvent(-1, "_Pause")
GUICtrlCreateButton("Exit", 210, 10, 80, 17)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState()

Do
    Sleep(100)
    If $IsPaused=-1 Then
        ConsoleWrite(@HOUR&":"&@MIN&":"&@SEC&@TAB&"NotPaused"&@CRLF)
    EndIf
Until False

Func _Start()
    $IsPaused=-1
EndFunc

Func _Pause()
    $IsPaused=1
EndFunc

Func _Exit()
    Exit
EndFunc

Try it :x

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

  • Developers

Hello again.

I see this little piece of shit came back ... so you even can't keep your word and think by just changing the displayname the issues is resolved.

Remember? :

Edited by Jos

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

cxzzD,

I was serious when I said that I wanted to make sure you could code as you wanted. What is about the code I posted that makes it hard to understand? I am happy to explain any of it in more detail if required. :x

guinness,

Thanks you for the compliment - I did try to make the tutorial understandable. :shifty:

M23

Yea, I didn't mean to bash your tutorial or anything. Just me having a hard time understanding(as allways..).

I might give this another shot tomorrow. But I gotta say, my program, atleast if I ever get to finishing it, will need somekind of multithreading. And if I've understand it correctly, AutoIt dosn't support multithreading.

Is there any other brilliant way that makes it possible to run several loops at once? :P

*

Link to comment
Share on other sites

I stumbled onto that thing more than once. No matter how people say it's easy. It isn't. Melba23 did wonderful explanations in this I made. I didn't got it to work and I didn't understood too, help it isn't the same for you. Anyway, I'm planning to learn it.

A friend of mine shown this solution, which is really EASY to understand:

Just use GuiOnEventMode to do your gui and all will work fine.

A little example:

Opt("GUIOnEventMode", 1)

HotKeySet("{F1}", "_Start")
HotKeySet("{F2}", "_Pause")
HotKeySet("{F3}", "_Exit")

$IsPaused=1

$GUI=GUICreate("test", 300, 40)
GUISetOnEvent(-3, "_Exit")
GUICtrlCreateButton("Start", 10, 10, 80, 17)
GUICtrlSetOnEvent(-1, "_Start")
GUICtrlCreateButton("Pause", 110, 10, 80, 17)
GUICtrlSetOnEvent(-1, "_Pause")
GUICtrlCreateButton("Exit", 210, 10, 80, 17)
GUICtrlSetOnEvent(-1, "_Exit")
GUISetState()

Do
    Sleep(100)
    If $IsPaused=-1 Then
        ConsoleWrite(@HOUR&":"&@MIN&":"&@SEC&@TAB&"NotPaused"&@CRLF)
    EndIf
Until False

Func _Start()
    $IsPaused=-1
EndFunc

Func _Pause()
    $IsPaused=1
EndFunc

Func _Exit()
    Exit
EndFunc

Try it :x

I have actually allready gotten a HotKeySet in my script. But that dosn't really cut it for me, I'd like my button to work. :P
Link to comment
Share on other sites

I have actually allready gotten a HotKeySet in my script. But that dosn't really cut it for me, I'd like my button to work. :lol:

If you at least tried to run the example :x:P:shifty:

You would have noticed that also buttons in the gui modality i told you do the thing you're asking for :nuke:

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...