A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: open ppt with swf studio

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    11

    open ppt with swf studio

    I want to open a ppt point fullscreen from a flash exe using swf studio. I had it working in Zinc with the following:

    var ppeExec = "cmd /c start powerpnt.exe /s " + "\""+fqFileName+"\"";
    var ppePath = srcDir;
    mdm.Process.create("",0,0,500,250,"",ppeExec,ppePa th,2,1);

    How do I do something similar with SWF Studio? Also, can I trigger something in the flash piece when the user closes the powerpoint?

    Thank you,

    Teresa

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    This should do what you want, including notifying you when the PPT viewer has been closed. I wrapped up the call to open a PPT file in a little helper function to make it a bit easier to use.

    Code:
    ssCore.init();
    ssDefaults.synchronousCommands = true;
    
    function LaunchPPT(path:String, cbfn:Function)
    {
       var r:Object = ssCore.Shell.getDefaultApplication({extension:"ppt"});
    	
       if (r.success)
          if (r.result != "")
             ssCore.Shell.execute({path:r.result, arguments:"/s " + path, waitForExit:true}, {callback:cbfn});
    }
    
    function onPPTClosed(r, c, e)
    {
       ssCore.App.showMsgBox({prompt:"PPT closed"});
    }
    
    LaunchPPT("c:\\test.ppt", onPPTClosed);
    The ssDefaults.synchronousCommands = true; means the default call mode for ssCorec command is synchronous command. However, in the call to Shell.execute I've specified a callback function (passed in as cbfn) so that call is made asynchronously. That means that we don't have to worry about Flash timing out if the PPT file is kept open longer than 15 seconds.

    I guess that means you didn't get any love from MDM?

    Last edited by Northcode; 03-17-2010 at 01:51 PM.

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    11
    You guys are great. Thanks so much. I had some problems launching the powerpoint at first because the path to my file was too long. I converted it to a short path using the getShortPath function and now it works. The getShortPath should not introduce any other problems should it?

    I am over ZINC. Anybody out there considering buying this type of product, I highly recommend SWF Studio.

    Quote Originally Posted by Northcode View Post
    This should do what you want, including notifying you when the PPT viewer has been closed. I wrapped up the call to open a PPT file in a little helper function to make it a bit easier to use.

    Code:
    ssCore.init();
    ssDefaults.synchronousCommands = true;
    
    function LaunchPPT(path:String, cbfn:Function)
    {
       var r:Object = ssCore.Shell.getDefaultApplication({extension:"ppt"});
    	
       if (r.success)
          if (r.result != "")
             ssCore.Shell.execute({path:r.result, arguments:"/s " + path, waitForExit:true}, {callback:cbfn});
    }
    
    function onPPTClosed(r, c, e)
    {
       ssCore.App.showMsgBox({prompt:"PPT closed"});
    }
    
    LaunchPPT("c:\\test.ppt", onPPTClosed);
    The ssDefaults.synchronousCommands = true; means the default call mode for ssCorec command is synchronous command. However, in the call to Shell.execute I've specified a callback function (passed in as cbfn) so that call is made asynchronously. That means that we don't have to worry about Flash timing out if the PPT file is kept open longer than 15 seconds.

    I guess that means you didn't get any love from MDM?

  4. #4
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The short path is perfectly valid. I think powerpnt.exe also allows you to quote the path to the PPT file to avoid problems so you could set the arguments to Shell.execute like this as well...

    Code:
    ssCore.Shell.execute({path:r.result, arguments:"/s " + "\"" + path + "\"", waitForExit:true}, {callback:cbfn});

  5. #5
    Junior Member
    Join Date
    Mar 2010
    Posts
    11
    Thank you so much. I haveone more question. Some of the powerpoints I am opening have large file sizes, so they take awhile to open. That is why I wanted to have the wait for exit and that works great. However, if the user does happen to tab back to the flash piece, I want to prompt them to close the powerpoint before they can continue. Right now I disable the buttons in my flash piece until they close the powerpoint and I want to keep it that way but I wanted to be able to prompt them if they come back to the flash piece before closing the powerpoint. Is that possible? Thank you.

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    You can set up an onFocusChange event before you launch the PPT file and wait for the "GOTFOCUS" notification. If you get that before the PPT is closed you can do whatever you want in response.

    Code:
    ssCore.App.setNotify({event:"onFocusChange"}, {callback:onFocusChanged});
    
    function onFocusChanged(r, c, e)
    {
       if (r.success)
          if (r.result == "GOTFOCUS")
             ssDebug.Trace("application has focus again");
    }
    When you get the onPPTClosed event you should disable the focus change notification.

    Code:
    function onPPTClosed(r, c, e)
    {
       ssCore.Win.clearNotify({event:"onFocusChange"});
       ssCore.App.showMsgBox({prompt:"PPT closed"});
    }

  7. #7
    Junior Member
    Join Date
    Mar 2010
    Posts
    11
    First of all, thank you so much for all your help. The copy dll you wrote for me is awesome, I have it implemented in my project. I will definitely recommend SWF Studio to others. Your assistance has really helped me get this project done. I wasted so much time with Zinc and now I am rushing, so I am sorry to keep bugging you for help. I have another question/problem with my powerpoints. I could not get the onFocus to work, but now I am not so sure that is what I need. I originally asked you about waiting until the program is loaded to notify my app. However, I think what I really need is to notify myApp when the ppt has finished loading. I know there is a waitForWindow function, is that what this is for? Also, because some of these powerpoints are so large, I get this windows opening dialog box with a cancel button, if I click cancel, is there a way to notify myApp that I cancelled opening the powerpoint? Once again, thank you, T

  8. #8
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The waitForWindow notifies you when the application's main window appears and waitForExit tells you when the application has been closed. The only "gotcha" is that you can't use these two settings together, you either get notified when the window appears OR when the app ends.

    We've run into this problem before where someone really needed both notifications, but there was no way to implement it before because the first callback kills the activation object that triggers the callback (so you can only get one callback per method call).

    I recently added support for Shell.execute notifications (through our set/clearNotify mechanism) to allow for continuous feedback when using the saveStdOut flag with Shell.execute. The same mechanism can now be extended and applied to any event that I can define for Shell.execute.

    What is your timeline like? I should be able to get that working in fairly short order and then send you a link to a development build so you can try it.

  9. #9
    Junior Member
    Join Date
    Mar 2010
    Posts
    11
    That would be great. I have to get a beta version out Monday, but I can just use what I have, then I have about 3 weeks until the final is due. Thanks for your help.

    T

  10. #10
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Okay, it took a bit more effort than I thought but I believe I managed to get the new events working without breaking the existing Shell.execute functionality. It still needs some testing but our beta should be good enough for your beta at least

    Give me a shout at support@northcode.com and I'll get you hooked up with the development build so you can start playing with this...

    NOTE TO INNOCENT BYSTANDERS This code will only work with SWF Studio 3.8 build 175 or higher. That build has not been released yet (as of March 19, 2010), I just wanted to show how the new events work.

    This example lets you launch a PPT file and get notifications when the main application window becomes visible AND when the app is closed. The final onShellExecuteComplete event is fired when the Shell.execute call finally returns. The events both return the full path the application that generated them and the onShellExecuteWaitForWindow also returns the handle of the application window (HWND).

    Code:
    ssCore.init();
    ssDefaults.synchronousCommands = true;
    
    function LaunchPPT(path:String, cbfn:Function)
    {
       var r:Object = ssCore.Shell.getDefaultApplication({extension:"ppt"});
    	
       if (r.success)
          if (r.result != "")
             ssCore.Shell.execute({path:r.result, arguments:"/s " + path, findAny:true}, {callback:cbfn});
    }
    
    function onShellExecuteComplete(r, c, e)
    {
       ssDebug.trace("onShellExecuteComplete");
    }
    
    function onWaitForWindow(r, c, e)
    {
       ssDebug.trace("onWaitForWindow: " + r.result);
    }
    
    function onWaitForExit(r, c, e)
    {
       ssDebug.trace("onWaitForExit: " + r.result);
    }
    
    ssCore.Shell.setNotify({event:"onShellExecuteWaitForWindow"}, {callback:onWaitForWindow});
    ssCore.Shell.setNotify({event:"onShellExecuteWaitForExit"}, {callback:onWaitForExit});
    
    LaunchPPT("c:\\test.ppt", onShellExecuteComplete);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center