Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Opening a web browser from an After Effects script

Engaged ,
Apr 22, 2012 Apr 22, 2012

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

TOPICS
Scripting
5.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Apr 22, 2012 Apr 22, 2012

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

...
Translate
Engaged ,
Apr 22, 2012 Apr 22, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 24, 2012 Apr 24, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 12, 2012 May 12, 2012

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

Christian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2012 May 15, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 28, 2012 May 28, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 09, 2012 Jun 09, 2012
LATEST

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.

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines