6 Replies Latest reply: Jun 9, 2012 9:24 AM by Alan_AEDScripts RSS

    Opening a web browser from an After Effects script

    Christian Lett Community Member

      Hi,

       

      This may be a stupid question, but is there any way to open a web browser with a URL from an AE script, other than explicity lanuching the browser app via a sys.callSystem() command?

       

      I'm asking because obviously scripts need to run on both Windows and MacOS, and the user's default/preferred browser isn't necessarily going to be IE or Safari. That and I'd need to find the file path of the browser anyway somehow.

       

      It's to display external help.

       

      Thanks,

       

      Christian

        • 1. Re: Opening a web browser from an After Effects script
          Christian Lett Community Member

          OK so I've figured out a method that works.

           

          Within your script dynamically create a local, temporary HTML file that does a simple URL redirect, such as:

           

          <html>

              <head>

                  <script language="javascript">

                      <!--

                      location.replace("http://www.quarterlightpictures.com");

                      //-->

                  </script>

              </head>

              <body>

              </body>

          </html>

           

          called something like "openwebpage.html"

           

          Then use new File("openwebpage.html").execute(); to open the HTML file in the default browser. The Javascript in the HTML head tag forwards to the desired web page.

          • 2. Re: Opening a web browser from an After Effects script
            David Torno Community Member

            system.callSystem() can launch a URL without specifying the specific app. This code user's default browser. The last line is the main deal, the other stuff keeps it universal for PC and MAC.

             

            //CHECKS FOR USER OS

            function osCheck(){

                      var op = $.os;

                      var match = op.indexOf("Windows");

                      if(match != (-1)){

                                var userOS = "PC";// User is on PC

                      }else{

                                var userOS = "MAC";// User is on MAC

                      }

                      return userOS;

            }

             

            // RUNS OS CHECK FUNCTION

            var userOSVer = osCheck();

             

            //DEFINES PC OR MAC TERMINAL SYNTAX

            if(userOSVer == "MAC"){

                      var urlLaunchCode = "Open";//Mac based

            }else{

                      var urlLaunchCode = "Start";//PC based

            }

             

            //ONCLICK FUNCTION FOR YOUR URL BUTTON CONTROL

            //urlLaunchCode = Open or Start / " " = keeps a space character separator / "http://myurl.com" = Defines the actual URL path

            myURLButton.onClick = function(){system.callSystem(urlLaunchCode + " " + "http://forums.adobe.com/thread/993523?tstart=0")};

            • 3. Re: Opening a web browser from an After Effects script
              Christian Lett Community Member

              David, you've been very helpful on here, thank you! A much more elegant solution than mine too!

               

              Christian

              • 4. Re: Opening a web browser from an After Effects script
                //-- Michel --

                Here is an example of what I use to display a web page (to run directly from After Effects) :

                 

                var win = new Window ("dialog");

                 

                var winBrowserCmd = "C:/Program Files/Internet Explorer/iexplore.exe";

                var macBrowserCmdStart = "osascript -e 'open location \"";

                var macBrowserCmdEnd = "\"'";

                 

                var BtnURL = win.add("button", undefined, "Check for update");

                 

                BtnURL.onClick = LinkToURL;

                 

                win.add ("button", undefined, "Close", {name: "ok"});

                 

                function LinkToURL()

                        {

                            var URL = "http://www.google.fr/"; // your web page

                           

                            if ($.os.indexOf("Windows") != -1)

                                system.callSystem(winBrowserCmd + " " + URL);

                            else

                                system.callSystem(macBrowserCmdStart + URL + macBrowserCmdEnd);

                           

                        }

                 

                win.show ();

                • 5. Re: Opening a web browser from an After Effects script
                  Alan_AEDScripts Community Member

                  I had been using the below, not fully tested on mac however....

                   

                  function checkOSandLaunch(theAddress){ // pass in www. no need for http etc.

                            $.writeln(system.osName);

                                      if (    $.os.indexOf("Windows") != -1 ) {//SYSTEM IS ONE OF THE WINDOWS, XP OR 7 ETC - have the word Windows in it.

                                                system.callSystem("cmd.exe /c\"start http://"+theAddress+"\"" );

                   

                                                }

                                                else{//MUST BE MAC

                                                 system.callSystem("open http://"+theAddress+ "\"");

                                }

                   

                  }//Close function.

                  • 6. Re: Opening a web browser from an After Effects script
                    Alan_AEDScripts Community Member

                    I posted incorrect information in the last post, just to correct, this is what is working.

                    //=======================================================

                    function checkOSandLaunch(theAddress) { // pass in www.

                              var site=theAddress;

                              if (  $.os.indexOf("Windows") != -1 ) {//SYSTEM IS ONE OF THE WINDOWS

                                                  system.callSystem("cmd.exe /c\"start http://"+site+"\"" );

                                        }

                                                  else{//MUST BE MAC

                                                  system.callSystem("open http://"+site);

                                  }

                     

                    }//Close function.

                    //=======================================================