ray_mosley
11 years agoFrequent Contributor
How to enter special key sequence in VBScript
I have a window object that pops up another window whenever CTRL+Shift+F12 is entered. This works as designed manually, but I cannot find the magic sequence to reporduce it from my code. Any suggestions?
The following sub is what I have tried:
Sub SpecialTestDriver
Dim xx
Dim myObj
Set myObj = eval("Sys.Process(""enterpriseroommanager"").VCLObject(""fmCHRTSelectICD10Options"").VCLObject(""Panel2"")")
myObj.SetFocus
Call CtrlShiftF12(myObj)
'''' Call CtrlShiftF12
xx = 0
End Sub
Sub CtrlShiftF12(obj)
''''Sub CtrlShiftF12
'***************************************************************************
'Purpose: Enter CTRL+Shift+F12 in the objectt
'
'Inputs:
' obj = object
'Returns: NA
'
'Change History:
'2015.06.03 HRM - Original creation
'***************************************************************************
''''Sys.Desktop.KeyDown(Win32API.VK_CONTROL) ' Press Ctrl
''''Sys.Desktop.KeyDown(65) ' Press A
''''Sys.Desktop.KeyUp(65) ' Release A
''''Sys.Desktop.KeyUp(Win32API.VK_CONTROL) ' Release Ctrl
'============= First attempt =======================
'''' obj.KeyDown(Win32API.VK_CONTROL) ' Press Ctrl
'''' obj.KeyDown(Win32API.VK_SHIFT) ' Press Shift
'''' obj.KeyDown(Win32API.VK_F12) ' Press F12
'''' obj.KeyUp(Win32API.VK_F12) ' Release F12
'''' obj.KeyUp(Win32API.VK_SHIFT) ' Release Shift
'''' obj.KeyUp(Win32API.VK_CONTROL) ' Release Ctrl
'============= Second attempt =======================
'''' obj.Keys(Win32API.VK_CONTROL+Win32API.VK_SHIFT+Win32API.VK_F12) ' Press Ctrl + Shift + F12
'''' obj.Keys("[CTRL]+[SHIFT]+[F12]") ' Press Ctrl + Shift + F12
'''' obj.SendKeys("(^+{F12})") ' Press Ctrl + Shift + F12
obj.Keys("(^+{F12})") ' Press Ctrl + Shift + F12
'============= Third attempt =======================
'''' Sys.Desktop.KeyDown(Win32API.VK_CONTROL) ' Press Ctrl
'''' Sys.Desktop.KeyDown(Win32API.VK_SHIFT) ' Press Shift
'''' Sys.Desktop.KeyDown(Win32API.VK_F12) ' Press F12
'''' Sys.Desktop.KeyUp(Win32API.VK_F12) ' Release F12
'''' Sys.Desktop.KeyUp(Win32API.VK_SHIFT) ' Release Shift
'''' Sys.Desktop.KeyUp(Win32API.VK_CONTROL) ' Release Ctrl
End Sub 'CtrlShiftF12That was my first attempt several days ago - it recorded but did not play back.
What I finally got to work today was:
obj.Keys("[Hold]^+[F12]{Release]") ' Press Ctrl + Shift + F12Now I am on to the next problem...