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
I found this on Duik repository‌ and it works fine.
os = $.os.toLowerCase().indexOf('mac') >= 0 ? "MAC": "WINDOWS";
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.
Copy link to clipboard
Copied
Thank you !
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 ?
Copy link to clipboard
Copied
I found this on Duik repository‌ and it works fine.
os = $.os.toLowerCase().indexOf('mac') >= 0 ? "MAC": "WINDOWS";
Copy link to clipboard
Copied
The info is in navigator.userAgent