home *** CD-ROM | disk | FTP | other *** search
/ Spidla DivX / DivX.bin / ReClock 1.2 / setup.exe / $INSTDIR / RunEvent.sample.vbs < prev   
Encoding:
Text File  |  2003-10-10  |  5.9 KB  |  138 lines

  1. ' -------------------------------------
  2. ' Event notification script for ReClock
  3. ' -------------------------------------
  4. '
  5. ' This script will be called when ReClock change the media adaptation of a played file
  6. ' either automatically or after some manual change made in the properties panel
  7. ' It is called only for media file which contain a video stream, and when frame rate of this file is known
  8. '
  9. ' ---------------------------------------------------------------------------------------------
  10. ' The 7 parameters received by this script are explained below:
  11. '
  12. ' (1) contains the event name that just occurred:
  13. '    - "GREEN"  : tray icon just got green (all is fine)
  14. '    - "YELLOW" : tray icon just got yellow. We should make what is necessary
  15. '                 to change the monitor refresh rate 
  16. '
  17. ' (2) contains the type of media file currently played:
  18. '    - "CINEMA" : frame rate of source file is around 24 fps
  19. '    - "PAL"    : frame rate of source file is around 25 fps
  20. '    - "NTSC"   : frame rate of source file is around 30 fps
  21. '    - "CUSTOM" : frame rate of source file does not fall in previous categories
  22. '
  23. ' (3) contains the current sound playback mode:
  24. '    - "PCM"    : PCM mode
  25. '    - "SPDIF"  : AC3 passthrough SPDIF
  26. '
  27. ' (4) contains the current resolution of your monitor (WIDTHxHEIGHT)
  28. '
  29. ' (5) contains the current refresh rate of your monitor (in Hz)
  30. '
  31. ' (6) contains the original playback rate of the file (in fps multiplied by 1000)
  32. '
  33. ' (7) contains the current playback rate of the file (in fps multiplied by 1000)
  34. '
  35. ' ---------------------------------------------------------------------------------------------
  36. ' Notifications examples:
  37. '   - GREEN CINEMA PCM 1024x768 72 23976 24000 : all is good
  38. '   - GREEN NTSC PCM 1024x768 60 29970 30000 : all is good
  39. '   - YELLOW PAL SPDIF 1024x768 72 25000 25000 : please switch to a multiple of 25 hz since PAL wants 25 fps
  40. '   - YELLOW CINEMA SPDIF 1024x768 75 23976 23976 : please switch to 71.928 hz
  41. '
  42. ' ---------------------------------------------------------------------------------------------
  43. ' Here is a sample in VbScript that will call Powerstrip to change the monitor refresh rate
  44. ' using the /T parameter (to obtain the timings parameters go to the timings setup in powerstrip and copy
  45. ' them to the clipboard)
  46. ' There is a VERY important thing to note. Powerstrip change the timings directly in the hardware, but
  47. ' forget to notify Windows applications it did that (including ReClock). So i provided a little tool
  48. ' called NotifyDisplayChange.exe that MUST be called after each reconfiguration by Powerstrip. If you
  49. ' don't do that ReClock won't see the changes and will get confused ...
  50.  
  51. ' Decode the parameters
  52. Set objArgs = WScript.Arguments
  53. If objArgs.Count < 7 Then
  54.     MsgBox "Bad argument count !",  MB_OK, "ReClock Event Notification"
  55.     WScript.Quit
  56. End If
  57.  
  58. eventName = objArgs(0)
  59. mediaType = objArgs(1)
  60. soundMode = objArgs(2)
  61. currentResolution = objArgs(3)
  62. currentRefreshRate = objArgs(4)
  63. originalPlaybackSpeed = objArgs(5)
  64. currentPlaybackSpeed = objArgs(6)
  65.  
  66. ' If you need to debug, replace false with true in the following line
  67. if false Then MsgBox _
  68.     eventName & " " & _
  69.     mediaType & " " & _
  70.     soundMode & " " & _
  71.     currentResolution & " " & _
  72.     currentRefreshRate & " " & _
  73.     originalPlaybackSpeed & " " & _
  74.     currentPlaybackSpeed, _
  75.     MB_OK, "ReClock Event Notification"
  76.  
  77. ' Here is a sample of what can be done with PowerStrip
  78. Set wshShell = CreateObject("WScript.Shell") 
  79.  
  80. ' We will put new timings here if necessary
  81. newTimings = ""
  82.  
  83. ' Obviously we have something to do only if the icon is yellow
  84. If eventName = "YELLOW" Then
  85.  
  86.     If soundMode  = "PCM" Then
  87.  
  88.         ' Call the profile that match best what we need in PCM mode
  89.         Select Case mediaType & ":" & currentResolution 
  90.             Case "CINEMA:1024x768"
  91.                 If currentRefreshRate <> "72" Then newTimings = "1024,40,136,144,768,3,6,29,77953,2054" ' 71.928 hz
  92.  
  93.             Case "PAL:1024x768"
  94.                 If currentRefreshRate <> "75" Then newTimings = "1024,40,136,144,768,3,6,29,81254,2054" ' 75 hz
  95.  
  96.             Case "NTSC:1024x768"
  97.                 If currentRefreshRate <> "60" Then newTimings = "1024,40,136,144,768,3,6,29,64894,2054" ' 59.98 hz
  98.         End Select
  99.     
  100.     ElseIf soundMode  = "SPDIF" Then
  101.  
  102.        ' In SPDIF mode we need an exact multiple to minimize the drops/repeats
  103.        ' Note: be careful in NTSC mode, because if "currentRefreshRate" is already "60"
  104.        ' when we go here then we won't switch but it may be 60 "bad" hz instead of 59.94 "wanted" hz
  105.        ' The same problem exists for NTSC film (23.976fps)
  106.        ' A solution is to force settings in the GREEN icon notification, but that would mean a pause
  107.        ' each time we play a file with SPDIF ...
  108.        ' That's why we use 59.94 hz and 71.928 hz for PCM too so we will never user 60 and 72 hz
  109.        Select Case currentResolution & "x" & originalPlaybackSpeed 
  110.            Case "1024x768x23976"
  111.                If currentRefreshRate <> "72" Then newTimings = "1024,40,136,144,768,3,6,29,77953,2054" ' 71.928 hz
  112.  
  113.            Case "1024x768x25000"
  114.                If currentRefreshRate <> "75" Then newTimings = "1024,40,136,144,768,3,6,29,81254,2054" ' 75 hz
  115.  
  116.            Case "1024x768x29970"
  117.                If currentRefreshRate <> "60" Then newTimings = "1024,40,136,144,768,3,6,29,64942,2054" ' 59.98 hz
  118.        End Select
  119.  
  120.     End if
  121.  
  122. End If
  123.  
  124. ' Do we have new timings to apply ?
  125. If newTimings <> "" Then
  126.     Set objShell = CreateObject("Shell.Application")
  127.     Set objFolder = objShell.Namespace(&H26&) 
  128.     Set objFolderItem = objFolder.Self   
  129.  
  130.     ' Run Powerstrip
  131.     WshShell.Run """" & objFolderItem.Path  & "\PowerStrip\pstrip.exe"" /T:" & newTimings
  132.     ' Notify the changes. Never ever forget to do that !
  133.     WshShell.Run "NotifyDisplayChange.exe"
  134. End If
  135.  
  136. ' All done, goodbye !
  137. WScript.Quit
  138.