Sign in to follow this  
Followers 0
58hoo

File status - Open, closed, etc.

8 posts in this topic

Have looked at the Help Topics for File but found nothing. I need to determine whether a file is open or closed and take action accordingly.... Thanks

Share this post


Link to post
Share on other sites



Have looked at the Help Topics for File but found nothing. I need to determine whether a file is open or closed and take action accordingly.... Thanks

If you're opening the file with FileOpen, you can check the return value to see if the file is open.

$file = FileOpen($name, $mode)
If $file = -1 Then
    ;file isn't open
    ;do stuff
Else
    ;file is open
    ;do stuff
EndIf

If the file is being "run" or something equivalent to that, try using WinExists or WinGetState.

Hope that helps.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Thanks... Specifically, I want to see if a non text file is executing (a .wav file). Am not sure how it would be identified as in execution.

Share this post


Link to post
Share on other sites

Thanks, Mike ... As I get more into this I don't think I defined the problem very well and your answers are helping me see this. Let me try to be very specific:

I want to determine if a specific .wav file is BEING executed so that a sound occurs. The file always exists, its just that sometimes it is being executed by a sound producing program such as Windows Media Player. I suppose I could see if the process, WMP, exists but I wouldn't know WHAT file it was executing. For example, if two files, Call911.wav and Chill.wav, were the files in question... I would like to take different program actions depending upon which is being executed.

Share this post


Link to post
Share on other sites

Yeah, in that case, my previous advice is terrible ;)

How are the files being executed? Through your script, or externally?


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

The link Dabus supplied is rich for both approaches and solutions for my problem. Thanks all!

Share this post


Link to post
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
Sign in to follow this  
Followers 0