Keys

Overview

General Syntax

Parameters

target_window_string
(string) keyword or caption list string indicating which window is to receive the keys, surrounded by curly braces
Optional, defaults to the active window.
In the list of Possible Values below, each "to" may be replaced by "toany":
to
works with visible windows only
leaves the focus at the window receiving the keys
toany
works with both hidden and visible windows
returns the focus to the window which had it before keys were sent

Possible Values

{to *}
Sends keys to the currently active window.
Example
  • Win.Keys("{to *}%{f4}")
    • Sends alt-f4 to the current window, closing it.
{to activebar}
Sends the keys to the last window referenced by a button on an active windows bar.
Example
  • Win.Keys("{to activebar}quick brown fox")
    • Sends "quick brown fox" to the last window selected via a click on an active windows bar.
{to autorun}
Sends the keys to the last window matched by an autorun-type command list.
Example
  • Win.Keys("{to autorun}%{sp}n")
    • Sends alt-f4 to the current window, closing it.
{to captionlist}
Sends the keys to the first window matching the captionlist.
For full list of accepted window id types, see:
  • PPSR > Language Reference > Caption Lists
  • PPSR > Language Reference > Window ID's
Examples
  • Win.Keys("{to *Firefox}^l")
    • Sends Ctrl-L to Firefox to go to the location bar.
  • Win.Keys("{to c=metapad}quick brown fox")
    • Sends "quick brown fox" to the first window of class "metapad" found.
  • Win.Keys("{to =firefox}"++myusername++"{ta}{w3}"++mypassword++"{en}")
    • Sends a username & password to Firefox.
{to =fpath}
Sends keys to program run from the file path, fpath.
File path must be prepended with equals sign.
Example
  • Win.Keys("{to =c:\pgms\pgm.exe}something to be sent")
    • Sends "something to be sent" to pgm.exe.
{to none}
Does not check if a window is available, instead makes keys available in keyboard buffer only.
Example
  • Win.Keys("{to none}"++date)
    • Puts the current date on the kb buffer.
{to folder}fpath
Used with File Open/Save As dialogs.
Changes the current directory of a File Open/Save As dialog to the specified folder path, fpath.
Example
  • Win.Keys(?"{to folder}c:\program files")
    • Changes the current directory of a file open/save dialog to:
      "c:\program files".
    • Assign this command to a button on a bar of similar buttons with folder shortcuts, in order to create a quick-jump bar to be shown whenever a File Open/Save As dialog is shown.
Notes
  • The process PowerPro takes to perform this action is:
    • select the File Name field
    • save anything currently in it
    • send the folder path to the dialog
    • restore the File Name field's contents
  • Generates a PowerPro error if used on anything other than a File Open or Save dialog.
  • Any text after fpath will be considered part of the folder path (and thus may cause errors).
{filemenu filepath}
Shows a menu created from the contents of a file, & the selected option is sent as keys to the active document.
filepath=full path to the file containing the menu to be shown
Example
  • Win.Keys(?"{filemenu c:\path\to\menu.txt}")
    • Shows the contents of "menu.txt" as a menu, & sends the selection to the active document
Notes
  • *Format commands can be used with menu text files, but require an @label at the start of the line (for some reason..?)
See Also
  • More information on file menus:
    • PowerPro Help CHM > Built-in Commands > *Menu > File menus
{from c:\path\filename.txt}
Sends the contents of the specified text file to the active document.
Example
  • Win.Keys(?"{from c:\mydocs\signature.txt}")
Notes
  • The text file can contain both standard standard ascii characters & PowerPro key codes, enabling functionality such as text formatting, program shortcuts & menu actions.
  • Text file must be in DOS or Windows format (not Unicode).
  • Any text after the closing brace will cause errors.

Window Prefixes

  • An optional single character prepended to the target portion of the target window string, with special meaning as outlined below:
  • Possible Values

    ^
    hides error messages
    +
    waits up to 3 secs for for the specified window to be ready
    -
    PowerPro sleeps a short time before sending the keys
  • Examples
    • Win.Keys("{to +*metapad}quick brown fox")
      • Waits up to 3 seconds for the first Metapad window found to be ready for input, then sends the keys "quick brown fox" to it.
    • Win.Keys("{to ^=firefox}^l{w1}miinx.com.au{en}")
      • Sends the F6 key to the first Firefox window found to select the location bar, hiding any error message if the window is not found, then waits 1/10th of a second before sending the url "miinx.com.au" & the Enter key.
keys_to_send
(string) any combination of alphanumeric characters & special keycodes making up the keys to be sent to the target window

Keycodes

  • See:
    • PPSR > Appendix > Win.Keys() & Win.SendKeys() Key Codes

Notes

See Also