home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 November / APC411-2.ISO / multimed / MediaCenter.exe / data1.cab / WorkShop / Pages / NetcardLaunchItem.js < prev    next >
Encoding:
Text File  |  1999-07-27  |  1.6 KB  |  63 lines

  1. var gWorkshop = WScript.CreateObject("Workshop.Automation");
  2. var    netcardPath = GetNetCardPath();
  3.  
  4. if (netcardPath != "")
  5. {
  6.     var argList = WScript.Arguments;
  7.     if (argList.length > 0)
  8.     {
  9.         var    FSO = WScript.CreateObject("Scripting.FileSystemObject");
  10.         var WSHShell = WScript.CreateObject("WScript.Shell");
  11.         var    kJPEGFormat = 2;
  12.         var    kBitsPerPixel = 24;
  13.         var kCompressionFactor = 100;
  14.         for (i = 0; i < argList.length; i++) 
  15.         {
  16.             var    tempFile = argList(i);
  17.             var    bConvert = !IsValidFileExtension(FSO.GetExtensionName(tempFile));
  18.             if (bConvert)
  19.                 // Save in temporary jpg file, 24 bits/pixel, 100% compression, no thumbnail
  20.                 tempFile = gWorkshop.CreateTempFile(argList(i), kJPEGFormat, kBitsPerPixel, kCompressionFactor, false);
  21.  
  22.             WSHShell.Run(netcardPath + " " + tempFile, 1, true);
  23.  
  24.             // Delete the temporary file
  25.             if (bConvert && FSO.FileExists(tempFile))
  26.                 FSO.DeleteFile(tempFile, true);
  27.         }
  28.         WSHShell = "";
  29.         FSO = "";
  30.     }
  31.     else
  32.     {
  33.         if (gWorkshop.DoCommand(20003,0) == 0)
  34.             gWorkshop.RunCommand(netcardPath);
  35.     }
  36.  
  37. }
  38. else
  39.     WScript.Echo("Can't find the program NetCard.exe. \n\nMake sure that it is installed correctly and try again.");
  40.  
  41.  
  42. gWorkshop = "";
  43.  
  44. function GetNetCardPath()
  45. {
  46.     var gWSHShell = WScript.CreateObject("WScript.Shell");
  47.     var netcardPath = gWSHShell.RegRead("HKCU\\Software\\PictureWorks\\NetCard\\Location\\Path");
  48.     gWSHShell = "";
  49.     return netcardPath;
  50. }
  51.  
  52.  
  53. function IsValidFileExtension(extension)
  54. {
  55.     extension = extension.toLowerCase();
  56.  
  57.     return ( extension == "jpg" || 
  58.              extension == "jpeg" || 
  59.              extension == "jpe" ||
  60.              extension == "bmp" ||
  61.              extension == "avi")
  62. }
  63.