Jamal,

Does this code work if I pass in a key like:

Control-Windows-Alt-F12


----- Original Message ----- From: "Jamal Mazrui" <empo...@smart.net>
To: <gw-scripting@gwmicro.com>
Sent: Tuesday, July 07, 2009 9:06 AM
Subject: Some custom keyboard functions


Given that inserting a key combination by name has been a recent topic, I
thought I'd share some functions of HomerSharedObject.vbs in this area.

Hope this helps,
Jamal

Public Function KeyboardBypass(sName)
' Insert a key directly to the focused window, bypassing Window-Eyes
ExecuteHotkey hkBypass
KeyboardInsert sName
End Function

Public Function KeyboardGetModifiers(sName)
' Get modifier flags of a key

Dim iReturn
Dim oKey

Set oKey = Keyboard.Key(sName)
iReturn = 0
If oKey.FilterApplication = kfsDown Then iReturn = iReturn Or
kmApplication
If oKey.FilterAlt = kfsDown Then iReturn = iReturn Or kmAlt
If oKey.FilterControl = kfsDown Then iReturn = iReturn Or kmControl
If oKey.FilterInsert = kfsDown Then iReturn = iReturn Or kmInsert
If oKey.FilterNumlock = kfsDown Then iReturn = iReturn Or kmNumlock
If oKey.FilterNumpad = kfsDown Then iReturn = iReturn Or kmNumpad
If oKey.FilterShift = kfsDown Then iReturn = iReturn Or kmShift
If oKey.FilterWindows = kfsDown Then iReturn = iReturn Or kmWindows
KeyboardGetModifiers = iReturn
End Function

Public Function KeyboardInsert(sName, bSuppressInterrupt)
' Insert a key by name, and specify whether to suppress interruptability
so that speech in progress continues

Dim aKeys
Dim iOldInterrupt, iIndex, iModifiers
Dim oKey
Dim sKey

Set oKey = Keyboard.Key(sName)
iModifiers = KeyboardGetModifiers(oKey)
If Right(sName, 1) = "-" Then
sKey = "-"
Else
aKeys = Split(sName, "-")
sKey = aKeys(UBound(aKeys))
End If
Set oKey = Keyboard.Key(s)
iIndex = oKey.Index

If bSuppressInterrupt Then iOldInterrupt =
oHomer.KeyboardSetInterrupt(kimOff)
Keyboard.InsertKey iIndex, iModifiers
If bSuppressInterrupt Then oHomer.KeyboardSetInterrupt(iOldInterrupt)
End Function

Public Function KeyboardSetInterrupt(iNewState)
' Set state of interruptability, and return previous setting so it may be
restored

KeyboardSetInterrupt = ActiveSettings.Keyboard.Interruptability
ActiveSettings.Keyboard.Interruptability = iNewState
End Function



Reply via email to