Jump to content

File status - Open, closed, etc.


58hoo
 Share

Recommended Posts

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]
Link to comment
Share on other sites

How about using ProcessExists?

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]
Link to comment
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.

Link to comment
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]
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...