      */
     private function enterFrameHandler(e:Event):void
     {
-    	if (frameCounter == 2)
-    	{
-	    	removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
-	    	_nativeWindow.visible = _nativeWindowVisible;
-	    	dispatchEvent(new AIREvent(AIREvent.WINDOW_COMPLETE));
-	    	if (_nativeWindow.visible)
-	    	{
-	    		if (openActive)
-	    			_nativeWindow.activate();
-	    	}
-    	}
-    	frameCounter++;
+        if (frameCounter == 2)
+        {
+            removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
+            _nativeWindow.visible = _nativeWindowVisible;
+            dispatchEvent(new AIREvent(AIREvent.WINDOW_COMPLETE));
+	    	
+            // Event for Automation so we know when windows 
+            // are created or destroyed.
+            if (ApplicationGlobals.application)
+            {
+                ApplicationGlobals.application.dispatchEvent(
+                    new WindowExistenceEvent(WindowExistenceEvent.WINDOW_CREATE, 
+                                             false, false, this));
+            }
+            
+            if (_nativeWindow.visible)
+            {
+                if (openActive)
+                    _nativeWindow.activate();
+            }
+        }
+        frameCounter++;
     }
 
 	/**

		    	if (NativeWindow.supportsMenu)
		    		nativeWindow.menu = menu.nativeMenu;
		    }
        }

        if (titleBarFactoryChanged)

            _nativeWindow.addEventListener("deactivate", nativeWindow_deactivateHandler, false, 0, true);
            
 			addEventListener(Event.ENTER_FRAME, enterFrameHandler);
 			
 			//'register' with WindowedSystemManager so it can cleanup when done.
 			sm.addWindow(this);
        }
