_SCREENPRINT - mkilgore/QB64pe GitHub Wiki

The _SCREENPRINT statement simulates typing text into a Windows focused program.

Syntax

_SCREENPRINT text$

Description

  • Keyword not supported in Linux or MAC versions
  • text$ is the text to be typed into a focused program's text entry area, one character at a time.
  • Set the focus to a desktop program by using the _SCREENIMAGE handle as the _SOURCE. Use the image to map the desired area.
  • _SCREENCLICK can also be used to set the focus to a program's text entry area on the desktop.
  • Note: If the focus is not set correctly, the text may be printed to the QB64 IDE, if open, or not printed at all.
  • Ctrl + letter key shortcuts can be simulated using the appropriate ASCII Control character codes 1 to 26 shown below:
 CTRL + A = CHR$(1)   ☺  StartHeader (SOH)    CTRL + B = CHR$(2)   ☻  StartText         (STX)
 CTRL + C = CHR$(3)   β™₯  EndText     (ETX)    CTRL + D = CHR$(4)   ♦  EndOfTransmit     (EOT)
 CTRL + E = CHR$(5)   ♣  Enquiry     (ENQ)    CTRL + F = CHR$(6)   β™   Acknowledge       (ACK)
 CTRL + G = CHR$(7)   β€’  [[BEEP]]        (BEL)    CTRL + H = CHR$(8)   β—˜  '''[Backspace]'''       (BS)
 CTRL + I = CHR$(9)   β—‹  Horiz.Tab   '''[Tab]'''    CTRL + J = CHR$(10)  β—™  LineFeed(printer) (LF)
 CTRL + K = CHR$(11)  β™‚  Vert. Tab   (VT)     CTRL + L = CHR$(12)  ♀  FormFeed(printer) (FF)
 CTRL + M = CHR$(13)  β™ͺ  '''[Enter]'''     (CR)     CTRL + N = CHR$(14)  β™«  ShiftOut          (SO)
 CTRL + O = CHR$(15)  ☼  ShiftIn     (SI)     CTRL + P = CHR$(16)  β–Ί  DataLinkEscape    (DLE)
 CTRL + Q = CHR$(17)  β—„  DevControl1 (DC1)    CTRL + R = CHR$(18)  ↕  DeviceControl2    (DC2)
 CTRL + S = CHR$(19)  β€Ό  DevControl3 (DC3)    CTRL + T = CHR$(20)  ΒΆ  DeviceControl4    (DC4)
 CTRL + U = CHR$(21)  Β§  NegativeACK (NAK)    CTRL + V = CHR$(22)  β–¬  Synchronous Idle  (SYN)
 CTRL + W = CHR$(23)  ↨  EndTXBlock  (ETB)    CTRL + X = CHR$(24)  ↑  Cancel            (CAN)
 CTRL + Y = CHR$(25)  ↓  EndMedium   (EM)     CTRL + Z = CHR$(26)  β†’  End Of File(SUB)  (EOF)                           

Examples

Example: Printing text into a Windows text editor (Notepad) and copying to the clipboard. May not work on all systems.

_SCREENPRINT "HELLO WORLD"
SLEEP 2
_SCREENPRINT CHR$(8) + CHR$(8) + CHR$(8) + CHR$(8) + CHR$(8) 'backspace 5 characters
SLEEP 3
_SCREENPRINT "QB64!"
SLEEP 2
_SCREENPRINT CHR$(1) 'CTRL + A select all
SLEEP 2
_SCREENPRINT CHR$(3) 'CTRL + C copy to clipboard
SLEEP 2
PRINT _CLIPBOARD$
_CLIPBOARD$ (statement) = "QB64 ROCKS!"
SLEEP 2
_SCREENPRINT CHR$(22) 'CTRL + V paste from clipboard
END '' ''
Code by Galleon
Explanation: If the Windows shortcuts are set up properly, printing ASCII Control characters acts like the user selected the control + letter combinations to Select all (CHR$(1)), Copy (CHR$(3)) and Paste (CHR$(22)) the text with the Windows Clipboard. If the editor program's CTRL key combinations are different, use the matching letter ASCII code from A = 1 to Z = 26 in the text editor.

See also


Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
⚠️ **GitHub.com Fallback** ⚠️