thepaulguy Posted January 25, 2012 Posted January 25, 2012 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.
IanN1990 Posted January 25, 2012 Posted January 25, 2012 (edited) Well you can use RunWait ShellExecuteWait or While 1 sleep(100) If WinExists("YourWindowTitle")then Exitloop Endif Wend Edited January 25, 2012 by IanN1990
water Posted January 25, 2012 Posted January 25, 2012 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 2024-07-28 - Version 1.6.3.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 (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
thepaulguy Posted January 25, 2012 Author Posted January 25, 2012 (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 January 25, 2012 by thepaulguy
water Posted January 25, 2012 Posted January 25, 2012 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 2024-07-28 - Version 1.6.3.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 (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
thepaulguy Posted January 25, 2012 Author Posted January 25, 2012 Thanks, I'll give it a shot with 2 scripts.
Juvigy Posted January 26, 2012 Posted January 26, 2012 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.
thepaulguy Posted January 26, 2012 Author Posted January 26, 2012 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now