Is there any script to wait until a file or files to exist then executing commands? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ahmed142
Posts: 19
Joined: 19 May 2022, 08:55

Is there any script to wait until a file or files to exist then executing commands?

Post by Ahmed142 » 30 Nov 2022, 13:37

Hello every one,

Is there any script to wait until a file or files to exist in the drive then to executing commands?
Let us dealing with MsgBox, then I can replace MsgBox with commands that I want.

I found a script from the old AutoHotkey community https://www.autohotkey.com/board/topic/91767-wait-for-a-file-to-exist-and-launch-it/

I modified a little bit on the code and the code after modifying is in the following:

Code: Select all

!F8::

#Persistent
SetTimer, Launch, 5000
return

Launch:
ifExist, D:\My Image.png
{
MsgBox, File is existing now.
Return
}
Now, for me, the problem with this code, is that If the file "My Image.png" is existing it show a MsgBox but when I close it appears again after the time in the script, so I want If the file is existing, then to show the MsgBox only one time, is there any way to do that?
Last edited by Ahmed142 on 01 Dec 2022, 09:28, edited 1 time in total.


LG Zana
Posts: 33
Joined: 06 Dec 2021, 17:50

Re: Is there any script to wait until a file or files to exist then executing commands?  Topic is solved

Post by LG Zana » 30 Nov 2022, 15:53

Try

Code: Select all

!F8::

#Persistent
SetTimer, Launch, 5000
Return

Launch:
ifExist, D:\My Image.png
{
	MsgBox, File is existing now.
	SetTimer, Launch, Off
}
Return

Ahmed142
Posts: 19
Joined: 19 May 2022, 08:55

Re: Is there any script to wait until a file or files to exist then executing commands?

Post by Ahmed142 » 01 Dec 2022, 03:54

boiler wrote:
30 Nov 2022, 14:21
See WatchFolder().
Thank you so much boiler for that topic, it could be very useful.

Ahmed142
Posts: 19
Joined: 19 May 2022, 08:55

Re: Is there any script to wait until a file or files to exist then executing commands?

Post by Ahmed142 » 01 Dec 2022, 03:56

LG Zana wrote:
30 Nov 2022, 15:53
Try

Code: Select all

!F8::

#Persistent
SetTimer, Launch, 5000
Return

Launch:
ifExist, D:\My Image.png
{
	MsgBox, File is existing now.
	SetTimer, Launch, Off
}
Return

Thank you so much LG Zana, that was really useful and solved my problem.

Post Reply

Return to “Ask for Help (v1)”