You're right, Chip. At the last minute, I renamed the variable s to sKey, hoping it would be more understandable for the message I posted than the verbatim source code of HomerSharedObject.vbs. Apparently, I forgot to change each reference to the variable.
Jamal On Tue, 7 Jul 2009, Chip Orange wrote: > Date: Tue, 7 Jul 2009 12:51:12 -0400 > From: Chip Orange <lists3...@comcast.net> > Reply-To: gw-scripting@gwmicro.com > To: gw-scripting@gwmicro.com > Subject: RE: Some custom keyboard functions > > Thanks Jamal, this looks exactly like what Jeff was asking about. > > There's one line in function keyboardInsert which I'm wondering about > though: > > Set oKey = Keyboard.Key(s) > > shouldn't that be: > > Set oKey = Keyboard.Key(sKey) > > <query>? > > Chip > > > -----Original Message----- > From: Jamal Mazrui [mailto:empo...@smart.net] > Sent: Tuesday, July 07, 2009 12:06 PM > To: gw-scripting@gwmicro.com > 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 > >