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

How to check if the user is on Mac or Windows ?

Community Beginner ,
Feb 16, 2016 Feb 16, 2016

Copy link to clipboard

Copied

Hi everyone, in the JavaScript Tools Guide CC (http://download.macromedia.com/pub/developer/aftereffects/scripting/JavaScript-Tools-Guide-CC.pdf), on Chapter 3 : File System Access page 49 it says for the filter of function openDialog :

Optional. A filter that limits the types of files displayed in the dialog:

- In Windows, a filter expression, such as "JavaScript:*.jsx;All files:*.*"

- In Mac OS, a filter function that takes a File instance and returns true if the file

should be included in the display, false if it should not.

So how can I make the difference between widows and mac in my script ?

This is for the moment what I have. It works for windows but I don't know if it works for mac.

var filterFiles = function(file){

     // IF WINDOWS

      return "*.jsx;*.jsxinc";

     // IF MAX

      if (file.constructor.name == "Folder") { return true; }

      writeLn(file.name);

      if (file.name.slice(-4) == ".jsx" || file.name.slice(-7) == ".jsxinc") { return true; }

      return false;

    };

var files = File.openDialog("Choose a script", filter=this.filterFiles, multiSelect=this.multiSelect);

Thanks for your help

Views

4.3K

Translate

Translate

Report

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

Community Beginner , Apr 02, 2016 Apr 02, 2016

I found this on Duik repository‌ and it works fine.

os = $.os.toLowerCase().indexOf('mac') >= 0 ? "MAC": "WINDOWS";

Votes

Translate

Translate
Participant ,
Feb 16, 2016 Feb 16, 2016

Copy link to clipboard

Copied

Its simple.

var os = new csInterface().getOSInformation();

This will give you OS information. Then,

if(os)

{  

  os = os.indexOf("Mac") == 0 ? "MAC": "WINDOWS";

}

This is in javascript. You can pass it on to extendscript and use. I believe there are some APIs available in jsx also.

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 16, 2016 Feb 16, 2016

Copy link to clipboard

Copied

Thank you !

Votes

Translate

Translate

Report

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
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

This actually doesn't works, I have an error : "RefferenceError : csInterface does not have a constructor". Any idea on how to fix that ?

Votes

Translate

Translate

Report

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
Community Beginner ,
Apr 02, 2016 Apr 02, 2016

Copy link to clipboard

Copied

I found this on Duik repository‌ and it works fine.

os = $.os.toLowerCase().indexOf('mac') >= 0 ? "MAC": "WINDOWS";

Votes

Translate

Translate

Report

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
People's Champ ,
Apr 18, 2016 Apr 18, 2016

Copy link to clipboard

Copied

LATEST

The info is in navigator.userAgent

Votes

Translate

Translate

Report

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