Sign in to follow this  
Followers 0
thepaulguy

Making a script wait for file to be opened

8 posts in this topic

I have been searching the forums and the internet on how to make a script wait in the background for a file of a certain type to be opened. Once the file is opened, the script will perform what it needs to do then continue to wait for another file to be opened.

I have already written most of my script, I just cannot figure out how to make the script wait for the file to be opened.

Share this post


Link to post
Share on other sites



What do you mean by "beeing opened"? What type of file do you want ot wait for? Is it a text file, is it an exe ...?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thank you for your responses IanN1990 and water. I understand it will most likely be a While Wend loop but how to script out how to wait for the file to be opened is my issue.

OK, I will explain what my script currently does and will ultimately do upon completion (hopefully).

The script is creating a schedule for recording TV programs from internet TV streams. To do this I will be utilizing internet electronic program guide files which are basically text files that have an extension of .tvpi, containing scheduling information for television programming. My script reads the contents of the file and extracts the information and transfers it into XML file format. Then XML file is then used to fill in a ListView inside my GUI, for the user to see what they have scheduled and whether the program is currently recording, waiting or completed. For the most part this is what I have completed so far.

Now, here is my problem, I understand that I need to associate the .tvpi file with my compiled script to have it handle the files when the user opens the file. I have done this already, and it works like a charm. BUT if my script is already running and the user opens another .tvpi file, another instance of my script is ran and another GUI is created. I don't want that to happen. I want the script that is already running to handle the file when opened.

I hope this makes since. :)

...... As I'm typing this I just had a thought, I could have this all broken down into 2 scripts if it is not possible to have it all in done in one script

First script associated with the .tvpi files. Read the file, extract the information and write it to the XML file then close.

Second Script to monitor the XML file and update the ListView when changes to XML file occur.

Hmmmmm, what do you guys think? Again I appreciate any assistance or insight you can give.

Edited by thepaulguy

Share this post


Link to post
Share on other sites

I would go with your approach of two scripts.

Reading the file and creating the XML file should finish before the user is able to click on another file.

Monitoring is a long running task. Keeping both in one script is quite hard to do with AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks, I'll give it a shot with 2 scripts. :)

Share this post


Link to post
Share on other sites

And why not just use FileOpen in a loop ? A file open dialog will always be asking you to select a file and that is the only inconvinience.

Share this post


Link to post
Share on other sites

I don't want the AutoIT script to be an interface for the user to select a file. I want the script to just wait until the file was opened by the user and then handled by the script . For example, the user may open the file from the desktop or from an internet link.

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