Jump to content

Creating two whiles loop at the same time.


Recommended Posts

I've been searching for a way on how to run two whiles at the same time. But i have no luck. Is there a way to make two whiles run at the same time? If not, is there any alternate way?

What I'm trying to do is, make both of the whiles to run at the same time. One is for checking errors constantly, and the other is sending msgboxes. If the error check comes out, the loop searching for the error, disables the other loop, then resumes it after clearing the error.

Link to comment
Share on other sites

hi

check out AdlibRegister() in help file

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Link to comment
Share on other sites

MsgBox will always pause your script, though you can use workaround with this:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 600, 400)
$Label1 = GUICtrlCreateLabel(Random(0, 99, 1), 10, 10, 580, 40)
$Button1 = GUICtrlCreateButton('New MessageBox', 10, 100, 100, 25)
GUISetState(@SW_SHOW)
$Timer1 = TimerInit()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _NewMsgBox(0, 'title', 'text')
    EndSwitch
    If TimerDiff($Timer1) >= 500 Then
        $Timer1 = TimerInit()
        GUICtrlSetData($Label1, Random(0, 99, 1))
    EndIf
WEnd
Func _NewMsgBox($Flag, $Title, $Text, $Timeout = -1, $hwnd = -1)
    Local $command = '"MsgBox(' & $Flag & ', ''' & $Title & ''', ''' & $Text & ''', ' & $Timeout & ')"'
    Run (@AutoItExe & ' /AutoIt3ExecuteLine  ' & $command)
EndFunc

So you see, numbers in main while will change even though there is msgbox started

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...