Skip navigation
Currently Being Moderated

Opening a web browser from an After Effects script

Apr 22, 2012 5:40 AM

Tags: #browser

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

 
Replies
  • Currently Being Moderated
    Apr 24, 2012 3:18 PM   in reply to Christian Lett

    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")};

     
    |
    Mark as:
  • Currently Being Moderated
    May 15, 2012 2:41 AM   in reply to Christian Lett

    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 ();

     
    |
    Mark as:
  • Currently Being Moderated
    May 28, 2012 2:37 PM   in reply to //-- Michel --

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 9, 2012 9:24 AM   in reply to Alan_AEDScripts

    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.

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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points