FlexMojos minimized Flash Player run blog home

Posted Wednesday, 28-Mar-2012 by Ingo Karkat

I'm working on a fairly large (currently ~ 80 Flex and 50 Java / Grails Maven modules) exterprise application with a Flex-based frontend and a Grails backend, prevalently developed on Windows 7. With such a complexity, running the tests frequently is a good idea :-) However, the pop-up of the Flash Player severely disturbs my workflow while the tests are running. (I'll spare you an extended rant about Windows' irritating pop-up and window focus behavior now.) Because each Maven Flex project serially pops up its own instance of the Flash Player, concurrent typing / editing is impossible, and even keeping up with industry news (otherwise known as browsing the web) is difficult because the Flash Player window keeps obscuring the screen.

Rather than just ranting about Adobe and the mess that is Flash Player (why do unit tests that just probe the internals need a window application, anyway?), I decided to work around this solution. Fortunately, one does not need to get out the big guns like AutoHotkey scripts that poll for the pop-up and minimize it, as it is possible (but sparely documented) to customize the launch of the Flash Player.

A simple batch wrapper around FlashPlayer.exe will do the trick of launching it with a minimized window, passing the command-line arguments to it, and waiting for its termination so that the invoking FlexMojos / Maven machinery doesn't fall out of rhythm.

The configuration is enabled via a private custom Maven profile, so it only affects my own private builds on my dev system, not the CI-build. Put the following into %USERPROFILE%\.m2\settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!-- http://maven.apache.org/settings.html -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
       <!-- Avoid that the Flash Player pops up and robs my focus while running
            the Flex unit tests.
            This has been driving me crazy :-( To solve this, override the
            default "FlashPlayer.exe" command with a Windows shell wrapper that
            is started with a minimized window. This blocks and the exit code is
            correctly returned, so it integrates seamlessly into FlexMojos.
            Contents of FlashPlayer.cmd:
              @start "FlashPlayer" /MIN /WAIT FlashPlayer.exe %*
        <!-- FlexMojos 3.5.0 -->
        <!-- FlexMojos 4.0 -->

The wrapper itself is a simple one-liner; put the FlashPlayer.cmd somewhere onto your PATH, or specify the full path (best with forward slashes) in above configuration.

@start "FlashPlayer" /MIN /WAIT FlashPlayer.exe %*

The trick is in using the START built-in with the /MIN option to minimize the launched application, and the /WAIT option to wait until it terminates. %* passes all arguments along, and the initial "FlashPlayer" argument is the meaningless window title that is only passed to avoid that START misinterprets the arguments.

Ingo Karkat, 28-Mar-2012

blog comments powered by Disqus