Jump to content
Sign in to follow this  

Issued with FileFindNextFile in a loop

Recommended Posts


I have a script to automate some things with Powerpoint and Camtasia. The script itself works fine, but I have an issue with the loop that actives the script for multiple files in a folder.

The script (shortened):

; Variables for paths and extensions
Global $presInputPath = "E:\inpres\"
Global $pptpath = "D:\Microsoft Office Ultimate 2007\Office12\POWERPNT.EXE /O "
Global $extension = "*.pptx"

; Find files in a directory
Global $search = FileFindFirstFile ($presInputPath&$extension)

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")

; Begin loop
While 1

; Get a file
$file = FileFindNextFile($search)
If @error Then
 MsgBox(0, "Finished", "No more presentations to produce")
; Do some things with the filename, e.g. append it to the path to start PPT

;Run Powerpoint

;Do a lot of stuff....

;Activate PPT and end it
WinActivate("Microsoft PowerPoint")
WinWaitActive("Microsoft PowerPoint")


The problem is that the script runs for the first file without any issues. But after PPT is closed, nothing happens. The script still sits in the background but doesn't start PPT again as it should. I'm not sure whether the Global keyword is correct in this case, but I suspected that somehow the variables can't be read after one run through the loop. I have no idea who could be the culprit, my best guess is the FileFindNexFile method but I can't figure out what is wrong. Any suggestions?

Share this post

Link to post
Share on other sites

Your posted script is not complete enough to test with, but one option to figure out where the script is hanging is to add this to the top:

Opt("TrayIconDebug", 1)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

It seemed to be some kind of weird timing issue. If I use sleep(200) before starting PPT everything works ok. Thanks anyway.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...