Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All,
I recently figured out how to stream QT movies on my website*. Now, I have two years worth of videos to convert and I am looking to automate. Unfortunately, QT Pro doesn't have a native CLI**. I figured this would be a good time to learn how to automate and control a Win32 application. In other words, even if there is a better way of doing this - I want to try and do it this way.

I asked in the CB and jmcnamara suggested Win32::GuiTest which has a tutorial, plenty of examples, as well as a "recorder" which you can use to generate code and then modify later. This was a bit too much of information overload. I was hoping for a 1 page tutorial explaining things like:

Do you know how to do this and wouldn't mind sharing? Do you know of a tutorial that is condensed into covering the tasks I mention above? Any help will be appreciated. Of course, if I do figure it out first I will be sure to share.

Cheers - L~R

  • Comment on Automating QuickTime Movies To Streaming

Replies are listed 'Best First'.
Re: Automating QuickTime Movies To Streaming
by BrowserUk (Patriarch) on Jul 29, 2008 at 02:39 UTC

    Maybe this will get you started. Save it as 700695.pl and run it from the directory where you saved it:

    #! perl -slw use strict; use Win32::GuiTest qw[SendKeys FindWindowLike SetForegroundWindow]; ## Start asynchronously system 1, 'notepad'; sleep 1; ## Give it chance to start ## Find it's window id ## Assumes only one copy with 'Untitled' is running. ## It two copies are, it doesn't matter which to use anyway my $wid = ( FindWindowLike 0, "Untitled - Notepad", 0, 0 )[0]; ## Ensure it's on top SetForegroundWindow( $wid ); sleep 1; ## Give it chance to respond ## Send the commands needed. ## If the processing is slow it may be better to break them into chaun +ks ## and intersperse with sleeps SendKeys ## Open the file menu, then the open dialog, ## enter the name of the file, and hit alt-O "%FO 700695.pl %O" ## Move to the end, add a DATA section and some text . "^{END}__DATA__~This was added automatically using Win32::GuiTes +t~" ## Open the file menu and save. OPen the file menu and exit. ## Say Yes to quiting . "%fs %fx Y" ## A short delay between keystrokes can help with slow dialogs. , 50;

    When you run it, it should get the following appended to it:

    __DATA__ This was added automatically using Win32::GuiTest

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Automating QuickTime Movies To Streaming
by Corion (Patriarch) on Jul 29, 2008 at 06:34 UTC

    As long as you can, avoid "using" the mouse. Always try to find out the keyboard shortcuts for operations and instead of sending mouse events, send the keyboard equivalents. That will spare you endless tweaking of coordinates and hassle with windows sitting on a different desktop or having weird coordinates/offsets because some system setting changed the window border to be thicker.

    To call up a menu, send ALT- combinations and then either cursor keys to navigate in the menu or directly the hotkey. Navigation in dialogs is best done using TAB for setting the focus and space to toggle selections.

    Checking whether a window has gone away is likely best done by checking whether there is still a window with the handle open.

Re: Automating QuickTime Movies To Streaming
by Limbic~Region (Chancellor) on Jul 30, 2008 at 01:04 UTC
    All,
    I had a private conversation with BrowserUk about how all the examples using notepad worked fine but QT Pro failed miserably. He was gracious enough to write some code that worked for him. His solution simplified the process greatly using the following techniques
    • Only use keyboard shortcuts (as Corion suggested)
    • Pass input file as argument when launching QT Pro
    • Take advantage of QT Pro remembering the last export settings
    • Export to the default directory

    This meant that I had to two things - write a wrapper routine to call this script and set up QT Pro with the settings to remember for each export. The following is BrowserUk's code modified for my purposes.

    Cheers - L~R