Modifiers/special keys, redux

A couple of months ago I had a question about sending special keys and modifiers that @kzaverdinos cleared up for me.

I found a Softomotive page that gives instructions for WinAutomation that appear to work for Robin also. It might be worth your time to take a look at it.

This screenshot is of code that:

  1. Prompts for input (multiline);
  2. Runs MS Word;
  3. Puts the input on the clipboard, and
  4. Sends it to Word with Ctrl-V, selects it with Ctrl-A, then increases the font size
    with the key sequence ‘{Control}({Shift}({OemPeriod}))’.

Code:

#*************************************************************************************
# A lot of the free information graciously provided by
# Softomotive for WinAutomation customers is very useful for Robin too.
# We  often need to send special key sequences to our applications:
# Special keys like Comma, Period, Space, Enter, Backspace, etc;
# Modifier keys like Control, Shift, Alt, Windows key;
# Function keys like F1, F2, etc.;
# and Numeric Keypad keys.
#
# At the very least some (possibly all) of the available arguments to 'SendKeys' 
# are listed at this webpage: 
#
# 
# https://support.softomotive.com/support/solutions/articles/35000098627-how-to-send-keys-and-key-combinations
#
# Our steps here:
# 1) Input multiline text to send to an application.
# 2) Run MS Word.
# 3) Put our input on the clipboard.
# 4) Send it to the app with Ctrl-V, select it with Ctrl-A, then increase the font size
# with the key sequence shown below, i.e. {Control}({Shift}({OemPeriod})).
# 
#*************************************************************************************

Display.InputDialog                     Title:'Writing to Word via the clipboard' \
                                        Message:'Enter the text you want to be sent to Word' \
                                        DefaultValue:'' \
                                        InputType:Display.InputType.Multiline \
                                        IsTopMost:False \
                                        UserInput=> UserInput \
                                        ButtonPressed=> ButtonPressed

System.RunApplicationAndWaitToLoad      ApplicationPath:  'winword.exe' \
                                        CommandLineArguments:'' \
                                        WorkingDirectory:'' \
                                        WindowStyle:System.ProcessWindowStyle.Normal \
                                        Timeout:0 ProcessId=> ProcessId \
                                        WindowHandle=> WindowHandle


Clipboard.SetText                       Text: UserInput

wait 1

# Note the format required for the keys to send!

MouseAndKeyboard.SendKeys               TextToSend:  '{Control}({V})' + '{Control}({A})'+ '{Control}({Shift}({OemPeriod}))' \
                                        DelayBetweenKeystrokes:100

Regards, and Happy New Year to all,
burque505

1 Like