Jump to content

Making a script wait for file to be opened


Recommended Posts

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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

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...