'************************************** ' Name: Windows 10 VBScript SendKeys Dem ' onstration ' Description:A very simple sample of VB ' Script SendKeys on Windows 10. ' By: A_X_O ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** ' '--------------------------------------- ' --------------------------------------- ' '+++++++++++++++++++++++++++++++++++++++ ' ++++++++++++++++++++++++++++++++ ' ' Demonstration: Windows 10, VBScript; ' SendKeys ' '+++++++++++++++++++++++++++++++++++++++ ' ++++++++++++++++++++++++++++++++ ' ' ' ' Purpose : Demonstrates VBScript SendK ' eys Function ' ' -------------------------------------- ' --------------------------------- ' ' Creation Date : 17/03/2018 [dd/mm/yyy ' y] ' ' Version : 1.1 ' ' Designer : Fabian ' ' ' '####################################### ' ####################################### ' ' MODIFICATION HISTORY ' '--------------------------------------- ' --------------------------------------- ' ' Version : 1:0 17/03/2018 Create the S ' ample ' ' Version : 1:1 31/03/2018 Close Notepa ' d at End ' ' ' '--------------------------------------- ' --------------------------------------- ' ' Dim ObjShell ' Create the memory dimensions for the scripting object Dim AppActivate ' Create the memory dimensions for Notepad ' Public Const ObjNotePad = "Notepad.exe" ' Store notepade early on Public Const IntDelay = 250 ' Define the WScript Sleep duration ' ' ' Message String To Be Split ' And Displayed ' Public Const strMessage = "Welcome|to|Planet Source Code|Here|is|a|sample|of|VBScript SendKeys Function" ' Public Const g_tCDelete = "{DEL}" ' SendKeys: DELETE Public Const g_tCSelect = "^+{HOME}" ' SendKeys: CONTROL and HOME Public Const g_tConfirm = "{ENTER}" ' SendKeys: ENTER Public Const g_tCStart = "36" ' SendKeys: Sample Font Size 36 Public Const g_tCStop = "10" ' SendKeys: Rest Font Size At End To 10 Public Const g_tBarMenu = "%+o" ' SendKeys: Format Font option on ToolBar Menu Public Const g_tCFont = "f" ' SendKeys: Font Public Const g_tCName = "Arial" ' SendKeys: Font Name Public Const g_tCNext = "{TAB}" ' SendKeys: Move System Focus To Next Font Dialog Option Public Const g_tCStyle = "Regular" ' SendKeys: SendKeys: Style Of Font Public Const g_tCEnd = "%+{F4}" ' SendKeys: Close Notepad after reseting the font. ' Set ObjShell = WScript.CreateObject("WScript.Shell") ' Create the scripting object: The Environment to work in ' AppActivate = ObjShell.Run(ObjNotePad, 1) ' Fire up Notepad and use as an Interface ' Dim i ' Memory Dimention i For a Loop Dim iCounter ' Memory Dimention iCounter For a Loop Dim iPart ' Memory Dimention iPart to Count Message Segments Dim MyString ' Memory Dimention MyString for each Message part in the String ' Call ModifyFont(0) ' Call ModifyFont with 0: First Run ' Public Sub ModifyFont(ByVal intFontSize) ' Setup the demonstration font On Error Resume Next ' With WScript ' Set the font ' .Sleep IntDelay * 4 : ObjShell.SendKeys g_tBarMenu .Sleep IntDelay : ObjShell.SendKeys g_tCFont .Sleep IntDelay : ObjShell.SendKeys g_tCName .Sleep IntDelay : ObjShell.SendKeys g_tCNext .Sleep IntDelay : ObjShell.SendKeys g_tCStyle .Sleep IntDelay : ObjShell.SendKeys g_tCNext ' If intFontSize = 0 Then ' Check if this is the start of the demo or the end ' ObjShell.SendKeys g_tCStart ' Start ' Else ' If not the Start, Must be the End ' ObjShell.SendKeys g_tCStop ' End of demo ' End If ' .Sleep IntDelay : ObjShell.SendKeys g_tConfirm ' Set font for either start or end .Sleep IntDelay * 2 ' Determine script process position, ie: start or end. If at end, then clean-up If iPart <> VbNullString And intFontSize = 1 Then ' ObjShell.SendKeys g_tCEnd ' End If ' End With ' End Sub ' For iCounter = 1 To Len(strMessage) ' Move through the message string and count parts ' If Mid((strMessage), iCounter, 1 ) = "|" Then ' iPart = iPart + 1 ' iPart is the Dimension that holds the integer (Dim iPart As Integer) ' End If ' Next ' For i = 0 To iPart ' Put each message part in the MyString Array ' MyString = Split(strMessage, "|", -1, 1) ' ObjShell.SendKeys MyString(i) ' Send each message part in turn to notepad ' With WScript ' .Sleep IntDelay * 6 : ObjShell.SendKeys g_tCSelect ' Pause a little, select the text .Sleep IntDelay * 2 : ObjShell.SendKeys g_tCDelete ' Delete the selected text ' End With ' Next ' WScript.Sleep IntDelay * 2 ' At the end of the message pause a little ' Call ModifyFont(1)