matys Posted March 25, 2014 Posted March 25, 2014 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!
FireFox Posted March 25, 2014 Posted March 25, 2014 (edited) Remove the loop wrapping your GUI... and add e.g a flag to be toggled when the process is found / not found. Edited March 25, 2014 by FireFox
water Posted March 25, 2014 Posted March 25, 2014 What is While/WEnd infunction gui1 for? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
matys Posted March 25, 2014 Author Posted March 25, 2014 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
FireFox Posted March 25, 2014 Posted March 25, 2014 (edited) 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 ;==>gui1Br, FireFox. Edited March 25, 2014 by FireFox
matys Posted March 25, 2014 Author Posted March 25, 2014 I tryed your script but it's doing same as before. Looping when notepad process is detected. Please help me!
matys Posted March 25, 2014 Author Posted March 25, 2014 I tested it on 2 computers right now, on windows 7 and 8. On both i get loop when notepad is opened. How is that possible that u don't get it ? Thanks for answer
matys Posted March 25, 2014 Author Posted March 25, 2014 Oh i didn't saw that you edited your code! I wanna ask why i can't close window "Embedded Web control Test" with "Exit" at top right corner of window? Thanks
FireFox Posted March 25, 2014 Posted March 25, 2014 (edited) It's not magic, you need to tell the GUI you want the script to Exit when you click on the close button.Look at the helpfile please (GUICreate). Edited March 25, 2014 by FireFox
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now