Posted by baoputzi in SWF Studio V3 on Feb 28 2008, 08:32 am

In my appl. I need to load and place a pps in a window of the application. Like loading an external swf. That works fine with shell.invoke. with waitForExit i can catch the exitCode and go back to the applications mainmenu when the user quits the pps or ppt via the regular way (inside the ppt or pps or when the pps ends). But the customer wants an extra button or key which allows to quit the running pp or ppt which also works fine when I use waitForWindow and ask for the hwnd. But his method does not give me a notification when the pps ends on the regularway or is ended from the user from within pps/ppt. In my case I would need both: the onExit which tells me that the pps/ppt was ended or ended by user and return to the apps mainmenu and the waitfor window in order to allow the user to interrupt a running pps/ppt and the return to the mainmenu.
when I use waitForExit and the there provided hwnd (which returns 0) and then use ssCore.Win.sendMessage to kill the running pps/ppt it kills my .exe. I also tried to use target with the wWin.sendMessage but without results as there is no usable caption reference in a pps and if there would be it could be changed with any new pps.

sorry for the long post and thx for any help about that issue


Posted by mbd in SWF Studio V3 on Feb 28 2008, 10:28 am

What you could do is use waitForExit so you get the exitCode, and use ssCore.App.setNotify to listen for the onWindow event.


Posted by baoputzi in SWF Studio V3 on Feb 28 2008, 12:04 pm

mmh -thx for the answer I will check that option. But anyway it would be a cool solution if one could use both options from wthin invoke. I have many jobs with the subject to open, run and close external progs and apps out of a main .exe like a desktop or kiosk cms also know as digital signage

once again thx for your prompt answer


Posted by northcode in SWF Studio V3 on Feb 28 2008, 12:31 pm


QUOTE:
it would be a cool solution if one could use both options from wthin invokeThe problem is that the events that waitForWindow and waitForExit generate happen at different times and once your callback function is called it can't be called again. We could do this by adding a new event to ssCore.Shell.setNotify and that's not a bad idea - so I'll add it to the wish list :)


Posted by baoputzi in SWF Studio V3 on Feb 28 2008, 12:44 pm

var r = ssCore.Shell.invoke({path:"startdir://" + file, width:contentW, height:contentH, x:contentX,y:contentY, waitForExit:true, forceChild:true});


if (r.success)
{
var HWNDListener_obj:Object = new Object();
HWNDListener_obj.onWindow = function(ret_obj, cb_obj, err_obj)

{
v = ret_obj.result.split(",")


//_root.powerPointHWND = v[0];

ssDebug.trace("hwnd " + v[0]);
ssDebug.trace("caption " + v[1]);
ssDebug.trace("classname " + v[2]);
ssDebug.trace("style" + v[3]);

}

ssEvents.addEventListener({listener:HWNDListener_obj, event:"App.onWindow"});

_root.closeAllContent();


}
else
{
ssDebug.trace('pps ERROR: '+r.Error.description);
}

I used the above and the trace was a long list of open windows - I could not extract the specific one for which I was looking for, also the caption was empty. With setNotify I don't get any result at all. Thus I use ssEvents which also sounds a little bit more logical to me...
What did I do wrong here? The closeAllContent function closes all eventually opened content (i.e. all the external progs and apps or swf videos etc. opened and run by the application in one single content window.)


Posted by mbd in SWF Studio V3 on Feb 28 2008, 12:48 pm

You should setup the event BEFORE calling invoke. It's possible the window already opened and so no notification is given.


Posted by baoputzi in SWF Studio V3 on Feb 28 2008, 12:55 pm

this makes no difference except:

I get more trace output with all opened windows hidden or not in my system, the powerpoint was opened at the wrong place and positioned after all the traces were through.


Posted by baoputzi in SWF Studio V3 on Feb 29 2008, 08:25 am

I used a work around. but would be more elegant if it would be possible to catch an information about this specific opend window.


Posted by northcode in SWF Studio V3 on Feb 29 2008, 10:37 am

You need a window handle to get information about a specific window. If you don't have a window handle you have to use some other method to identify the window (the caption or class name for example). That's what the onWindow event allows you to do, see new windows as they appear so you can identify the one you're interested in.


Posted by baoputzi in SWF Studio V3 on Feb 29 2008, 04:30 pm

This is exactly what I tried to do but for the opened pps window there was no caption nor class which I could identify.Thus I could not localise the handle.
Why is it such a big story to allow both methods waitForWindow and waitForExit - or to add the hwnd proberty to waitForExit - this would make things a little easier as searching through some 30 or more apearing events.

thx and rgds from cologne/germany


Posted by mbd in SWF Studio V3 on Feb 29 2008, 04:44 pm

It's a big deal because, as Tim mentioned, once a callback is called it can't be called again. The only exception is notifications (setNotify), for which there is none for Shell.invoke at this time. Tim mentioned adding this to the wishlist.

In the API when you call a method with a callback an object is created that handles data that comes back from the SWF Studio player. When the data is returned the object calls the callback function and destroys itself, so we don't leave things lying around, unless it was a notification call.

The actual functionality for Shell.invoke wasn't designed to do this, and would have to be modified to pass data to a notification.

While we might add this functionality in a future build, I think Tim was trying to suggest a way for you to continue with your project right now.

In the current build, even if you got an HWND for waitForExit it would be useless to you since setting waitForExit to true means SWF Studio doesn't return from the call until the window has exited - if it returned before that, it wouldn't actually be waiting for exit. That's why there's waitForWindow.

The suggestion is on the wishlist.


Posted by baoputzi in SWF Studio V3 on Feb 29 2008, 05:33 pm

ok for now I could help me with some stupid workaround.- thanks for putting that on the wishlist