home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileInclude001 < prev    next >
Encoding:
Text (UTF-16)  |  2005-09-02  |  34.8 KB  |  537 lines

  1. ' ***
  2. ' *** ------------------------------------------------------------------------------
  3. ' *** Filename:        Accessibility.vbs
  4. ' *** ------------------------------------------------------------------------------
  5. ' *** Description:    Accessibility HTA Script
  6. ' *** ------------------------------------------------------------------------------
  7. ' *** Version:        1.0
  8. ' *** Notes:        Used by Accessibility.hta
  9. ' *** ------------------------------------------------------------------------------
  10. ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  11. ' *** ------------------------------------------------------------------------------
  12. ' ***
  13.  
  14. ' ~~~ 
  15. ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode
  16. ' ~~~ 
  17. Option Explicit
  18. If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  19.  
  20. ' ~~~
  21. ' ~~~ declare variables and constants
  22. ' ~~~
  23. Dim oAccessibility, bApplied, colInput , oInput, sCurrentContrast , oToolTip
  24.  
  25. ' ***
  26. ' *** ------------------------------------------------------------------------------
  27. ' *** Name:            Init()
  28. ' *** ------------------------------------------------------------------------------
  29. ' *** Purpose:        This function is executed whilst the spash screen is displayed
  30. ' *** ------------------------------------------------------------------------------
  31. ' ***
  32. Sub Init()
  33.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  34.     
  35.     ' ~~~ create objects
  36.     Set oAccessibility = New accessibility
  37.     
  38.     Set oToolTip = Window.CreatePopup()
  39.     
  40. End Sub
  41.  
  42. ' ***
  43. ' *** ------------------------------------------------------------------------------
  44. ' *** Name:            Load()
  45. ' *** ------------------------------------------------------------------------------
  46. ' *** Purpose:        This subroutine is executed before a wizard page is displayed
  47. ' *** ------------------------------------------------------------------------------
  48. ' ***
  49. Sub Load()
  50.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  51.     
  52.     ' ~~~ Get the collection of input elements
  53.     Set colInput = document.body.GetElementsByTagName("INPUT")
  54.     
  55.     ' ~~~ Call the method to populate the High Contrast options
  56.     Call oAccessibility.GetContrastThemes("HTA", "Default")
  57.     
  58.     ' ~~~ Call the current Settings Subroutine
  59.     CurrentSettings
  60.     
  61.     ' ~~~ Call the sub to enable body 
  62.     Call BodyDisable(False) 
  63.     
  64.     ' ~~~ Disable the dd list if high contrast is not set
  65.     Call HighContrastClick()
  66.         
  67.     ' ~~~ Call the method to set hover messages for the options in the HTA
  68.     Call SetHoverMessage()
  69.     
  70. End Sub
  71. ' ***
  72. ' *** ------------------------------------------------------------------------------
  73. ' *** Name:            Validate()
  74. ' *** ------------------------------------------------------------------------------
  75. ' *** Purpose:        This function is executed before a wizard page is exited
  76. ' ***            If this function returns false. The page does not exit.
  77. ' *** ------------------------------------------------------------------------------
  78. ' ***
  79. Function Validate()
  80.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0    
  81.     Validate = True
  82. End Function
  83.  
  84. ' ***
  85. ' *** ------------------------------------------------------------------------------
  86. ' *** Name:            Action()
  87. ' *** ------------------------------------------------------------------------------
  88. ' *** Purpose:        This subroutine is executed when OK is clicked. 
  89. ' *** ------------------------------------------------------------------------------
  90. ' ***
  91. Sub Action()
  92.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  93.  
  94.     bProcessing = True
  95.     'Call BodyDisable(True)
  96.  
  97.     ' ~~~ Call SubmitAccessibility to set all the features selected
  98.     SubmitAccessibility
  99.  
  100.     'Call BodyDisable(False)
  101.     bProcessing = False
  102.     ' ~~~ Disable the dd list if high contrast is not set
  103.     'Call HighContrastClick()
  104.     
  105. End Sub
  106.  
  107. ' ***
  108. ' *** ------------------------------------------------------------------------------
  109. ' *** Name:            Apply()
  110. ' *** ------------------------------------------------------------------------------
  111. ' *** Purpose:        Called to apply current changes - when Apply is clicked.
  112. ' *** ------------------------------------------------------------------------------
  113. ' ***
  114. Sub Apply()
  115.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  116.  
  117.     
  118.     bProcessing = True
  119.     
  120.     bApplied    = False
  121.     Call BodyDisable(True)
  122.         
  123.     ToggleFinish(True)
  124.     
  125.     ' ~~~ Call the sub to apply the settings
  126.     SubmitAccessibility
  127.     
  128.     ' ~~~ To enable the finish text and button
  129.     If bApplied = True Then
  130.           ToggleFinish(False)
  131.           Window.Focus        
  132.           oShell.Run "mshta.exe",0, True
  133.           Window.resizeTo oDiv.offsetLeft + oDiv.offsetWidth + 15, oFooter.offsetTop + oFooter.offsetHeight + 35
  134.     End If
  135.  
  136.     ' ~~~ Enable the UI to take input again
  137.     Call BodyDisable(False)
  138.     
  139.     bProcessing = False
  140.     
  141.     ' ~~~ Disable the dd list if high contrast is not set
  142.     Call HighContrastClick()
  143. End Sub
  144.  
  145. ' ***
  146. ' *** ------------------------------------------------------------------------------
  147. ' *** Name:            HTAKeyDown()
  148. ' *** ------------------------------------------------------------------------------
  149. ' *** Purpose:        This subroutine is executed whenever tool specific 
  150. ' ***            key is pressed.
  151. ' *** ------------------------------------------------------------------------------
  152. ' ***
  153. Sub HTAKeyDown()
  154.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  155. End Sub
  156.  
  157. ' ***
  158. ' *** ------------------------------------------------------------------------------
  159. ' *** Name:            CurrentSettings()
  160. ' *** ------------------------------------------------------------------------------
  161. ' *** Purpose:        This subroutine is executed on load of the application
  162. ' ***            Displays the current settings of the Accessibility
  163. ' ***            features in the HTA
  164. ' *** ------------------------------------------------------------------------------
  165. ' ***
  166. Sub CurrentSettings()
  167.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  168.  
  169.     Dim colProcessList, oProcess, sContrastTheme  
  170.  
  171.     ' ~~~ Set the currently set High contrast theme in the dd list
  172.     sCurrentContrast = RegRead( "HKEY_CURRENT_USER\Control Panel\Accessibility\HighContrast\High Contrast Scheme")
  173.     ddHighContrast.Value = sCurrentContrast
  174.     
  175.     ' ~~~ Check for High Contrast
  176.     If oAccessibility.GetOption ("contrast") <> 0 Then
  177.         document.all("chkHighContrast").checked = True
  178.     End If
  179.     
  180.     ' ~~~ Check for Extra Large Cursor
  181.     If oAccessibility.GetOption ("largepointer") Then
  182.         Call CurrentChkbox("LARGEPOINTER")
  183.     End If
  184.  
  185.     ' ~~~ Check for SoundSentry 
  186.     If oAccessibility.GetOption ("soundsentry") Then
  187.         Call CurrentChkbox("SOUNDSENTRY")
  188.     End If
  189.  
  190.     ' ~~~ Check for ShowSound
  191.     If oAccessibility.GetOption ("showsound") Then
  192.         Call CurrentChkbox("SHOWSOUND")
  193.     End If
  194.  
  195.     ' ~~~ Check for Stickykeys
  196.     If oAccessibility.GetOption ("stickykeys") Then
  197.         Call CurrentChkbox("STICKYKEYS")
  198.     End If
  199.  
  200.     ' ~~~ Check for FilterKeys
  201.     If oAccessibility.GetOption ("filterkeys") Then
  202.         Call CurrentChkbox("FILTERKEYS")
  203.     End If
  204.  
  205.     ' ~~~ Check for MouseKeys
  206.     If oAccessibility.GetOption ("mousekeys") Then
  207.         Call CurrentChkbox("MOUSEKEYS")
  208.     End If
  209.  
  210.     ' ~~~ Check for Narrator,Magnify,OSK
  211.  
  212.     Set colProcessList = oWMIService.ExecQuery _
  213.         ("Select * from Win32_Process")
  214.  
  215.     For Each oProcess in colProcessList
  216.         If UCase(oProcess.name) = UCase("Magnify.exe") Then 
  217.             Call CurrentChkbox("MAGNIFIER")
  218.         ElseIf UCase(oProcess.name) = UCase("narrator.exe") Then 
  219.             Call CurrentChkbox("NARRATOR")
  220.         ElseIf UCase(oProcess.name) = UCase("osk.exe") Then 
  221.             Call CurrentChkbox("OSKEYBOARD")
  222.         End If
  223.     Next
  224.     Set oProcess = Nothing
  225. End Sub
  226.  
  227. ' ***
  228. ' *** ------------------------------------------------------------------------------
  229. ' *** Name:            SubmitAccessibility()
  230. ' *** ------------------------------------------------------------------------------
  231. ' *** Purpose:        This subroutine is executed on submit of the application
  232. ' ***            Sets the settings of the Accessibility
  233. ' ***            features that are selected in HTA
  234. ' *** ------------------------------------------------------------------------------
  235. ' ***
  236. Sub SubmitAccessibility()
  237.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  238.  
  239.     ' ~~~ High Contrast settings
  240.     If chkHighContrast.checked = True Then
  241.         If ( sCurrentContrast <> ddHighContrast.Value ) OR ( sCurrentContrast = ddHighContrast.Value AND oAccessibility.GetOption ("contrast") = 0 ) Then
  242.             sCurrentContrast = ddHighContrast.Value 
  243.             ' ~~~ update the registry
  244.             RegWrite "HKEY_CURRENT_USER\Control Panel\Accessibility\HighContrast\High Contrast Scheme" , sCurrentContrast , "REG_SZ"
  245.             
  246.             ' ~~~ SetContrast function
  247.             oAccessibility.SetOption "contrast", 1
  248.         End If
  249.     Else
  250.         ' ~~~ Clear the current contrast variable
  251.         sCurrentContrast = ""
  252.         ' ~~~ disable the highcontrast and set the default theme
  253.         If oAccessibility.GetOption ("contrast") <> 0 Then
  254.             oAccessibility.SetOption "contrast", 0
  255.         End If
  256.     End If
  257.         
  258.     ' ~~~ Magnify option settings
  259.     For Each oInput in colInput
  260.         If UCase(oInput.type) = "CHECKBOX" Then
  261.             If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
  262.                 If UCase(Mid(oInput.id,4)) = "MAGNIFIER" Then
  263.                     If document.all(oInput.id).checked Then
  264.                         If Not oAccessibility.Get_ProcessStatus("magnifier") Then
  265.                             oAccessibility.Start_Process("magnifier")
  266.                         End If
  267.                     Else
  268.                         If oAccessibility.Get_ProcessStatus("magnifier") Then
  269.                             oAccessibility.CloseApplication()
  270.                         End If
  271.                     End If
  272.                     Exit For
  273.                 End If
  274.             End If
  275.         End If
  276.     Next
  277.     
  278.     ' ~~~ Narrator option settings
  279.     For Each oInput in colInput
  280.         If UCase(oInput.type) = "CHECKBOX" Then
  281.             If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
  282.                 If UCase(Mid(oInput.id,4)) = "NARRATOR" Then
  283.                     If document.all(oInput.id).checked Then
  284.                         If Not oAccessibility.Get_ProcessStatus("narrator") Then
  285.                             oAccessibility.Start_Process("narrator")
  286.                         End If
  287.                     Else
  288.                         If oAccessibility.Get_ProcessStatus("narrator") Then
  289.                             oAccessibility.End_Process("narrator.exe")
  290.                         End If
  291.                     End If
  292.                     Exit For
  293.                 End If
  294.             End If
  295.         End If
  296.     Next
  297.     
  298.     ' ~~~ OSK option settings
  299.     For Each oInput in colInput
  300.         If UCase(oInput.type) = "CHECKBOX" Then
  301.             If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
  302.                 If UCase(Mid(oInput.id,4)) = "OSKEYBOARD" Then
  303.                     If document.all(oInput.id).checked Then
  304.                         If Not oAccessibility.Get_ProcessStatus("oskeyboard") Then
  305.                             oAccessibility.Start_Process("oskeyboard")
  306.                         End If
  307.                     Else
  308.                         If oAccessibility.Get_ProcessStatus("oskeyboard") Then
  309.                             oAccessibility.End_Process("osk.exe")
  310.                         End If
  311.                     End If
  312.                     Exit For
  313.                 End If
  314.             End If
  315.         End If
  316.     Next
  317.         
  318.     ' ~~~ Extra Large Cursor settings
  319.     Call SetFeature("largepointer")
  320.     
  321.     ' ~~~ Sound Sentry settings
  322.     Call SetFeature("soundsentry")
  323.             
  324.     ' ~~~ Show Sound settings
  325.     Call SetFeature("showsound")
  326.         
  327.     ' ~~~ StickyKeys settings
  328.     Call SetFeature("stickykeys")
  329.     
  330.     ' ~~~ FilterKeys settings
  331.     Call SetFeature("filterkeys")
  332.     
  333.     ' ~~~ MouseKeys settings
  334.     Call SetFeature("mousekeys")
  335.     
  336.     ' ~~~ To set the boolean value to true to indicate the end of apply
  337.     bApplied = True
  338.     
  339.     Set oInput = Nothing
  340.  
  341. End Sub
  342.  
  343. ' ***
  344. ' *** ------------------------------------------------------------------------------
  345. ' *** Name:        ToggleFinish(bEnable)
  346. ' *** ------------------------------------------------------------------------------
  347. ' *** Purpose:    To enable/disable the finish text and button
  348. ' *** ------------------------------------------------------------------------------
  349. ' ***
  350. Sub ToggleFinish(bEnable)
  351.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  352.     
  353.     If bEnable = True Then
  354.         ' ~~~ For Finish button
  355.         btnFinish.disabled = True
  356.         btnFinish.style.cursor = "auto"
  357.         
  358.     Else
  359.         ' ~~~ For Finish button
  360.         btnFinish.disabled = False
  361.         btnFinish.style.cursor = "hand"
  362.         
  363.     End If
  364. End Sub
  365.  
  366. ' ***
  367. ' *** ------------------------------------------------------------------------------
  368. ' *** Name:        SetHoverMessage()
  369. ' *** ------------------------------------------------------------------------------
  370. ' *** Purpose:    To set hover messages for all the features in the tool. 
  371. ' *** ------------------------------------------------------------------------------
  372. ' ***
  373. Sub SetHoverMessage
  374.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  375.     
  376.     For Each oInput in colInput
  377.         If UCase(oInput.type) = "CHECKBOX" Then
  378.             If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
  379.                 oInput.title = document.all(Mid(oInput.id,4)).innerHTML
  380.                 document.all("lbl" & Mid(oInput.id,4)).title  = document.all(Mid(oInput.id,4)).innerHTML
  381.             End If
  382.         End If
  383.     Next
  384.     
  385.     Set oInput = Nothing
  386. End Sub
  387.  
  388. ' ***
  389. ' *** ------------------------------------------------------------------------------
  390. ' *** Name:        CurrentChkbox(sFeature)
  391. ' *** ------------------------------------------------------------------------------
  392. ' *** Purpose:    To select/unselect checkboxes to display the current settings 
  393. ' *** ------------------------------------------------------------------------------
  394. ' ***
  395. Sub CurrentChkbox(sFeature)
  396.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  397.     
  398.     For Each oInput in colInput
  399.         If UCase(oInput.type) = "CHECKBOX" Then
  400.             If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
  401.                 If UCase(Mid(oInput.id,4)) = sFeature Then
  402.                     document.all(oInput.id).checked = True
  403.                     Exit For
  404.                 End If
  405.             End If
  406.         End If
  407.     Next
  408.     
  409.     Set oInput = Nothing
  410. End Sub    
  411.  
  412. ' ***
  413. ' *** ------------------------------------------------------------------------------
  414. ' *** Name:        SetFeature(strFeature)
  415. ' *** ------------------------------------------------------------------------------
  416. ' *** Purpose:    To set the selected features in the tool. Called by 
  417. ' ***        submitaccessibility method.    
  418. ' *** ------------------------------------------------------------------------------
  419. ' ***
  420. Sub SetFeature(strFeature)
  421.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  422.         
  423.     For Each oInput in colInput
  424.         If UCase(oInput.type) = "CHECKBOX" Then
  425.             If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
  426.                 If UCase(Mid(oInput.id,4)) = UCase(strFeature) Then
  427.                     If document.all(oInput.id).checked Then
  428.                         If oAccessibility.GetOption (strFeature) = 0 Then
  429.                             oAccessibility.SetOption strFeature , 1
  430.                         End If
  431.                     Else
  432.                         If oAccessibility.GetOption (strFeature) = 1 Then
  433.                             oAccessibility.SetOption strFeature, 0
  434.                         End If
  435.                     End If
  436.                     Exit For
  437.                 End If
  438.             End If
  439.         End If
  440.     Next
  441.     
  442.     Set oInput = Nothing
  443.     
  444. End Sub
  445.  
  446. ' ***
  447. ' *** ------------------------------------------------------------------------------
  448. ' *** Name:            PopulateContrast(sContrastName)
  449. ' *** ------------------------------------------------------------------------------
  450. ' *** Purpose:        Populates the contrast themes in the dd list
  451. ' *** ------------------------------------------------------------------------------
  452. ' ***
  453. Sub PopulateContrast( sContrastName )
  454.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  455.     
  456.     Dim oOption 
  457.     
  458.     Set oOption = document.CreateElement("OPTION")
  459.         
  460.     oOption.text = sContrastName
  461.     oOption.Value = sContrastName
  462.     oOption.Id = sContrastName
  463.     ddHighContrast.add(oOption)
  464.                 
  465.     Set oOption = Nothing
  466.     
  467. End Sub
  468.  
  469. ' ***
  470. ' *** ------------------------------------------------------------------------------
  471. ' *** Name:            HighContrastClick()
  472. ' *** ------------------------------------------------------------------------------
  473. ' *** Purpose:        This sub enables/disables the contrast dd list
  474. ' *** ------------------------------------------------------------------------------
  475. ' ***
  476. Sub HighContrastClick()
  477.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  478.     
  479.     If chkHighContrast.Checked = True Then
  480.         ddHighContrast.disabled = False
  481.     Else
  482.         ddHighContrast.disabled = True
  483.     End If
  484. End Sub
  485.  
  486. ' ***
  487. ' *** ------------------------------------------------------------------------------
  488. ' *** Name:            ContrastHoverText()
  489. ' *** ------------------------------------------------------------------------------
  490. ' *** Purpose:        Sets the tooltip message for the contrast dd list
  491. ' ***            Uses popup object as a tooltip
  492. ' *** ------------------------------------------------------------------------------
  493. ' ***
  494. Sub ContrastHoverText()
  495.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  496.     
  497.     Dim iXpos, iYpos, iHeight
  498.     
  499.     If ddHighContrast.disabled Then
  500.         tdHighContrast.Title = ddHighContrast.Value
  501.         Exit Sub
  502.     End If
  503.     
  504.     tdHighContrast.Title = ""
  505.     
  506.     oToolTip.Document.Body.innerText = ddHighContrast.Value
  507.     oToolTip.Document.Body.style.Border = ToolTipBorder.innerText
  508.     oToolTip.Document.Body.style.Font = ToolTipFont.innerText
  509.         
  510.     ' ~~~ Get the mouse position
  511.     iXpos = Window.event.ScreenX
  512.     iYpos = Window.event.ScreenY
  513.     iYpos = iYpos + 10
  514.     
  515.     oToolTip.Show iXpos,iYpos,225,100
  516.             
  517.     iHeight = oToolTip.document.body.ScrollHeight
  518.     iHeight = iHeight + 3
  519.     
  520.     oToolTip.Show iXpos,iYpos,225,iHeight
  521.         
  522. End Sub
  523.  
  524.  
  525. ' ***
  526. ' *** ------------------------------------------------------------------------------
  527. ' *** Name:            HTAUnLoad()
  528. ' *** ------------------------------------------------------------------------------
  529. ' *** Purpose:        This method unloads all the objects 
  530. ' ***            created within the scope of the HTA
  531. ' *** ------------------------------------------------------------------------------
  532. ' ***
  533. Sub HTAUnLoad()
  534.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  535.     Set oAccessibility = Nothing
  536.     Set oToolTip = Nothing
  537. End Sub