home *** CD-ROM | disk | FTP | other *** search
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Filename: Accessibility.vbs
- ' *** ------------------------------------------------------------------------------
- ' *** Description: Accessibility HTA Script
- ' *** ------------------------------------------------------------------------------
- ' *** Version: 1.0
- ' *** Notes: Used by Accessibility.hta
- ' *** ------------------------------------------------------------------------------
- ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
- ' *** ------------------------------------------------------------------------------
- ' ***
-
- ' ~~~
- ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode
- ' ~~~
- Option Explicit
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- ' ~~~
- ' ~~~ declare variables and constants
- ' ~~~
- Dim oAccessibility, bApplied, colInput , oInput, sCurrentContrast , oToolTip
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Init()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed whilst the spash screen is displayed
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub Init()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- ' ~~~ create objects
- Set oAccessibility = New accessibility
-
- Set oToolTip = Window.CreatePopup()
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Load()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This subroutine is executed before a wizard page is displayed
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub Load()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- ' ~~~ Get the collection of input elements
- Set colInput = document.body.GetElementsByTagName("INPUT")
-
- ' ~~~ Call the method to populate the High Contrast options
- Call oAccessibility.GetContrastThemes("HTA", "Default")
-
- ' ~~~ Call the current Settings Subroutine
- CurrentSettings
-
- ' ~~~ Call the sub to enable body
- Call BodyDisable(False)
-
- ' ~~~ Disable the dd list if high contrast is not set
- Call HighContrastClick()
-
- ' ~~~ Call the method to set hover messages for the options in the HTA
- Call SetHoverMessage()
-
- End Sub
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Validate()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This function is executed before a wizard page is exited
- ' *** If this function returns false. The page does not exit.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Function Validate()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- Validate = True
- End Function
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Action()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This subroutine is executed when OK is clicked.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub Action()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- bProcessing = True
- 'Call BodyDisable(True)
-
- ' ~~~ Call SubmitAccessibility to set all the features selected
- SubmitAccessibility
-
- 'Call BodyDisable(False)
- bProcessing = False
- ' ~~~ Disable the dd list if high contrast is not set
- 'Call HighContrastClick()
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: Apply()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Called to apply current changes - when Apply is clicked.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub Apply()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
-
- bProcessing = True
-
- bApplied = False
- Call BodyDisable(True)
-
- ToggleFinish(True)
-
- ' ~~~ Call the sub to apply the settings
- SubmitAccessibility
-
- ' ~~~ To enable the finish text and button
- If bApplied = True Then
- ToggleFinish(False)
- Window.Focus
- oShell.Run "mshta.exe",0, True
- Window.resizeTo oDiv.offsetLeft + oDiv.offsetWidth + 15, oFooter.offsetTop + oFooter.offsetHeight + 35
- End If
-
- ' ~~~ Enable the UI to take input again
- Call BodyDisable(False)
-
- bProcessing = False
-
- ' ~~~ Disable the dd list if high contrast is not set
- Call HighContrastClick()
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: HTAKeyDown()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This subroutine is executed whenever tool specific
- ' *** key is pressed.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub HTAKeyDown()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: CurrentSettings()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This subroutine is executed on load of the application
- ' *** Displays the current settings of the Accessibility
- ' *** features in the HTA
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub CurrentSettings()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim colProcessList, oProcess, sContrastTheme
-
- ' ~~~ Set the currently set High contrast theme in the dd list
- sCurrentContrast = RegRead( "HKEY_CURRENT_USER\Control Panel\Accessibility\HighContrast\High Contrast Scheme")
- ddHighContrast.Value = sCurrentContrast
-
- ' ~~~ Check for High Contrast
- If oAccessibility.GetOption ("contrast") <> 0 Then
- document.all("chkHighContrast").checked = True
- End If
-
- ' ~~~ Check for Extra Large Cursor
- If oAccessibility.GetOption ("largepointer") Then
- Call CurrentChkbox("LARGEPOINTER")
- End If
-
- ' ~~~ Check for SoundSentry
- If oAccessibility.GetOption ("soundsentry") Then
- Call CurrentChkbox("SOUNDSENTRY")
- End If
-
- ' ~~~ Check for ShowSound
- If oAccessibility.GetOption ("showsound") Then
- Call CurrentChkbox("SHOWSOUND")
- End If
-
- ' ~~~ Check for Stickykeys
- If oAccessibility.GetOption ("stickykeys") Then
- Call CurrentChkbox("STICKYKEYS")
- End If
-
- ' ~~~ Check for FilterKeys
- If oAccessibility.GetOption ("filterkeys") Then
- Call CurrentChkbox("FILTERKEYS")
- End If
-
- ' ~~~ Check for MouseKeys
- If oAccessibility.GetOption ("mousekeys") Then
- Call CurrentChkbox("MOUSEKEYS")
- End If
-
- ' ~~~ Check for Narrator,Magnify,OSK
-
- Set colProcessList = oWMIService.ExecQuery _
- ("Select * from Win32_Process")
-
- For Each oProcess in colProcessList
- If UCase(oProcess.name) = UCase("Magnify.exe") Then
- Call CurrentChkbox("MAGNIFIER")
- ElseIf UCase(oProcess.name) = UCase("narrator.exe") Then
- Call CurrentChkbox("NARRATOR")
- ElseIf UCase(oProcess.name) = UCase("osk.exe") Then
- Call CurrentChkbox("OSKEYBOARD")
- End If
- Next
- Set oProcess = Nothing
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: SubmitAccessibility()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This subroutine is executed on submit of the application
- ' *** Sets the settings of the Accessibility
- ' *** features that are selected in HTA
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub SubmitAccessibility()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- ' ~~~ High Contrast settings
- If chkHighContrast.checked = True Then
- If ( sCurrentContrast <> ddHighContrast.Value ) OR ( sCurrentContrast = ddHighContrast.Value AND oAccessibility.GetOption ("contrast") = 0 ) Then
- sCurrentContrast = ddHighContrast.Value
- ' ~~~ update the registry
- RegWrite "HKEY_CURRENT_USER\Control Panel\Accessibility\HighContrast\High Contrast Scheme" , sCurrentContrast , "REG_SZ"
-
- ' ~~~ SetContrast function
- oAccessibility.SetOption "contrast", 1
- End If
- Else
- ' ~~~ Clear the current contrast variable
- sCurrentContrast = ""
- ' ~~~ disable the highcontrast and set the default theme
- If oAccessibility.GetOption ("contrast") <> 0 Then
- oAccessibility.SetOption "contrast", 0
- End If
- End If
-
- ' ~~~ Magnify option settings
- For Each oInput in colInput
- If UCase(oInput.type) = "CHECKBOX" Then
- If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
- If UCase(Mid(oInput.id,4)) = "MAGNIFIER" Then
- If document.all(oInput.id).checked Then
- If Not oAccessibility.Get_ProcessStatus("magnifier") Then
- oAccessibility.Start_Process("magnifier")
- End If
- Else
- If oAccessibility.Get_ProcessStatus("magnifier") Then
- oAccessibility.CloseApplication()
- End If
- End If
- Exit For
- End If
- End If
- End If
- Next
-
- ' ~~~ Narrator option settings
- For Each oInput in colInput
- If UCase(oInput.type) = "CHECKBOX" Then
- If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
- If UCase(Mid(oInput.id,4)) = "NARRATOR" Then
- If document.all(oInput.id).checked Then
- If Not oAccessibility.Get_ProcessStatus("narrator") Then
- oAccessibility.Start_Process("narrator")
- End If
- Else
- If oAccessibility.Get_ProcessStatus("narrator") Then
- oAccessibility.End_Process("narrator.exe")
- End If
- End If
- Exit For
- End If
- End If
- End If
- Next
-
- ' ~~~ OSK option settings
- For Each oInput in colInput
- If UCase(oInput.type) = "CHECKBOX" Then
- If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
- If UCase(Mid(oInput.id,4)) = "OSKEYBOARD" Then
- If document.all(oInput.id).checked Then
- If Not oAccessibility.Get_ProcessStatus("oskeyboard") Then
- oAccessibility.Start_Process("oskeyboard")
- End If
- Else
- If oAccessibility.Get_ProcessStatus("oskeyboard") Then
- oAccessibility.End_Process("osk.exe")
- End If
- End If
- Exit For
- End If
- End If
- End If
- Next
-
- ' ~~~ Extra Large Cursor settings
- Call SetFeature("largepointer")
-
- ' ~~~ Sound Sentry settings
- Call SetFeature("soundsentry")
-
- ' ~~~ Show Sound settings
- Call SetFeature("showsound")
-
- ' ~~~ StickyKeys settings
- Call SetFeature("stickykeys")
-
- ' ~~~ FilterKeys settings
- Call SetFeature("filterkeys")
-
- ' ~~~ MouseKeys settings
- Call SetFeature("mousekeys")
-
- ' ~~~ To set the boolean value to true to indicate the end of apply
- bApplied = True
-
- Set oInput = Nothing
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: ToggleFinish(bEnable)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: To enable/disable the finish text and button
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub ToggleFinish(bEnable)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- If bEnable = True Then
- ' ~~~ For Finish button
- btnFinish.disabled = True
- btnFinish.style.cursor = "auto"
-
- Else
- ' ~~~ For Finish button
- btnFinish.disabled = False
- btnFinish.style.cursor = "hand"
-
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: SetHoverMessage()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: To set hover messages for all the features in the tool.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub SetHoverMessage
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- For Each oInput in colInput
- If UCase(oInput.type) = "CHECKBOX" Then
- If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
- oInput.title = document.all(Mid(oInput.id,4)).innerHTML
- document.all("lbl" & Mid(oInput.id,4)).title = document.all(Mid(oInput.id,4)).innerHTML
- End If
- End If
- Next
-
- Set oInput = Nothing
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: CurrentChkbox(sFeature)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: To select/unselect checkboxes to display the current settings
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub CurrentChkbox(sFeature)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- For Each oInput in colInput
- If UCase(oInput.type) = "CHECKBOX" Then
- If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
- If UCase(Mid(oInput.id,4)) = sFeature Then
- document.all(oInput.id).checked = True
- Exit For
- End If
- End If
- End If
- Next
-
- Set oInput = Nothing
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: SetFeature(strFeature)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: To set the selected features in the tool. Called by
- ' *** submitaccessibility method.
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub SetFeature(strFeature)
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- For Each oInput in colInput
- If UCase(oInput.type) = "CHECKBOX" Then
- If document.all("tr" & Mid(oInput.id,4)).style.display <> "none" Then
- If UCase(Mid(oInput.id,4)) = UCase(strFeature) Then
- If document.all(oInput.id).checked Then
- If oAccessibility.GetOption (strFeature) = 0 Then
- oAccessibility.SetOption strFeature , 1
- End If
- Else
- If oAccessibility.GetOption (strFeature) = 1 Then
- oAccessibility.SetOption strFeature, 0
- End If
- End If
- Exit For
- End If
- End If
- End If
- Next
-
- Set oInput = Nothing
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: PopulateContrast(sContrastName)
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Populates the contrast themes in the dd list
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub PopulateContrast( sContrastName )
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim oOption
-
- Set oOption = document.CreateElement("OPTION")
-
- oOption.text = sContrastName
- oOption.Value = sContrastName
- oOption.Id = sContrastName
- ddHighContrast.add(oOption)
-
- Set oOption = Nothing
-
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: HighContrastClick()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This sub enables/disables the contrast dd list
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub HighContrastClick()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- If chkHighContrast.Checked = True Then
- ddHighContrast.disabled = False
- Else
- ddHighContrast.disabled = True
- End If
- End Sub
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: ContrastHoverText()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: Sets the tooltip message for the contrast dd list
- ' *** Uses popup object as a tooltip
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub ContrastHoverText()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
-
- Dim iXpos, iYpos, iHeight
-
- If ddHighContrast.disabled Then
- tdHighContrast.Title = ddHighContrast.Value
- Exit Sub
- End If
-
- tdHighContrast.Title = ""
-
- oToolTip.Document.Body.innerText = ddHighContrast.Value
- oToolTip.Document.Body.style.Border = ToolTipBorder.innerText
- oToolTip.Document.Body.style.Font = ToolTipFont.innerText
-
- ' ~~~ Get the mouse position
- iXpos = Window.event.ScreenX
- iYpos = Window.event.ScreenY
- iYpos = iYpos + 10
-
- oToolTip.Show iXpos,iYpos,225,100
-
- iHeight = oToolTip.document.body.ScrollHeight
- iHeight = iHeight + 3
-
- oToolTip.Show iXpos,iYpos,225,iHeight
-
- End Sub
-
-
- ' ***
- ' *** ------------------------------------------------------------------------------
- ' *** Name: HTAUnLoad()
- ' *** ------------------------------------------------------------------------------
- ' *** Purpose: This method unloads all the objects
- ' *** created within the scope of the HTA
- ' *** ------------------------------------------------------------------------------
- ' ***
- Sub HTAUnLoad()
- If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
- Set oAccessibility = Nothing
- Set oToolTip = Nothing
- End Sub