_Vlad Posted March 12, 2020 Posted March 12, 2020 Hello AutoIt :), As the title is saying I have below a simple code. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Wait Exist", 340, 64, -1, -1) $Button1 = GUICtrlCreateButton("Wait Exist", 16, 16, 75, 25) $Button2 = GUICtrlCreateButton("Message", 156, 16, 75, 25) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To 3 MsgBox(0,'',$i) While Not FileExists(@DesktopDir & '\ExampleFile.txt') WEnd Next Case $Button2 MsgBox(0, '', '') EndSwitch WEnd Here I must wait for a file to exist while using the menu at the same time. The problem is that I can't use an Adlibregister cause I use a for and it must wait for the file to exist before continue. EXAMPLE : #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Wait Exist", 340, 64, -1, -1) $Button1 = GUICtrlCreateButton("Wait Exist", 16, 16, 75, 25) $Button2 = GUICtrlCreateButton("Message", 156, 16, 75, 25) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To 3 MsgBox(0,'',$i) AdlibRegister('_Wait',1000) Next Case $Button2 MsgBox(0, '', '') EndSwitch WEnd Func _Wait() If FileExists(@DesktopDir & '\ExampleFile.txt') Then EndIf EndFunc How can I do that? Thank you!
Zedna Posted March 12, 2020 Posted March 12, 2020 (edited) #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Wait Exist", 340, 64, -1, -1) $Button1 = GUICtrlCreateButton("Wait Exist", 16, 16, 75, 25) $Button2 = GUICtrlCreateButton("Message", 156, 16, 75, 25) GUISetState(@SW_SHOW, $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To 3 MsgBox(0,'',$i) While Not FileExists(@DesktopDir & '\ExampleFile.txt') $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit If $nMsg = $Button2 Then FuncButton2() WEnd Next Case $Button2 FuncButton2() EndSwitch WEnd Func FuncButton2() MsgBox(0, 'Button2', '') EndFunc Edited March 12, 2020 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Nine Posted March 12, 2020 Posted March 12, 2020 Another way (especially if you got a large and complex GUI) : #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Wait Exist", 340, 64, -1, -1) $Button1 = GUICtrlCreateButton("Wait Exist", 16, 16, 75, 25) $Button2 = GUICtrlCreateButton("Message", 156, 16, 75, 25) GUISetState(@SW_SHOW, $Form1) Local $bWaiting = False While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $bWaiting = True GUICtrlSetState ($Button1, $GUI_DISABLE) Case $Button2 FuncButton2() EndSwitch If $bWaiting And FileExists ("your path goes here") Then ;do stuff here GUICtrlSetState ($Button1, $GUI_ENABLE) $bWaiting = False EndIf WEnd Func FuncButton2() MsgBox(0, 'Button2', '') EndFunc ;==>FuncButton2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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