Jump to content

Problem with infinity looping GUI


 Share

Recommended Posts

Hello i am making a script. The main problem is that script is looping when process is found. I want that script open only 1 GUI when process it's recognized.

Here is script:

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

while 1
If ProcessExists("notepad.exe") Then ; Check if the Notepad process is running.

gui1()

Func gui1()
while 1
$oIE = ObjCreate("Shell.Explorer.2")

    ; Create a simple GUI for our output
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    GUICtrlCreateObj($oIE, 10, 40, 600, 360)

    GUISetState(@SW_SHOW) ;Show GUI

    $oIE.navigate("http://www.autoitscript.com")
 WEnd
EndFunc   ;==>gui

Else
    sleep(10000)
endif
WEnd

Thanks for help! 

Link to comment
Share on other sites

What is While/WEnd infunction gui1 for?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That's nothing i was testing something. How you mean flag to be toggled? Im new in autoit ..

Program must all the time check if process exist if not do nothing, if exist than open GUI.

Thanks for answers

Link to comment
Share on other sites

I didn't see your func is inside the loop. Read the helpfile with its examples and you will see how things work : it's outside everything.

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

Local $fExists = False

While 1
    If ProcessExists("notepad.exe") Then ; Check if the Notepad process is running.
        If Not $fExists Then
            $fExists = True
            gui1()
        EndIf
    ElseIf $fExists Then
        $fExists = False
        Sleep(100)
    EndIf
WEnd

Func gui1()
    $oIE = ObjCreate("Shell.Explorer.2")

    ; Create a simple GUI for our output
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    GUICtrlCreateObj($oIE, 10, 40, 600, 360)

    GUISetState(@SW_SHOW) ;Show GUI

    $oIE.navigate("http://www.autoitscript.com")
EndFunc   ;==>gui1
Br, FireFox. Edited by FireFox
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...