DAY 028: _SCREENPRINT - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Official Links (https://staging.qb64phoenix.com/forumdisplay.php?fid=16) +--- Forum: Learning Resources and Archives (https://staging.qb64phoenix.com/forumdisplay.php?fid=13) +---- Forum: Keyword of the Day! (https://staging.qb64phoenix.com/forumdisplay.php?fid=49) +---- Thread: DAY 028: _SCREENPRINT (/showthread.php?tid=1252) |
DAY 028: _SCREENPRINT - Pete - 12-09-2022 I ain't got nothin' but KEYWORDS, eight days a week... So let's talk _SCREENPRINT, the little bro to the bigger and better Win32 SENDKEYS function. SYNTAX: _SCREENPRINT text$ Note: This keyword is not supported in Linux and Mac Operating Systems. So what does it do? _SCREENPRINT is acts as a virtual keypress and text transmitter. It is limited in the key combos available, which can be seen in the table, below... Code: (Select All) CTRL + A = CHR$(1) ☺ StartHeader (SOH) CTRL + B = CHR$(2) ☻ StartText (STX) So let's take a look at the first entry, Ctrl+A. This is the key combo we use to highlight text in other apps. _SCREENPRINT CHR$(1) will therefore highlight all the text on another open and active app. Wait for it to compile and start. When you see the window open, click back on this browser window... Code: (Select All) _DELAY 5 ' Give yourself some time to click another app, like this browser. Cool, right? Well now _SCREENPRINT also works progressively, so if we wanted to copy that text to our clipboard, we would just code... Code: (Select All) _DELAY 5 ' Give yourself some time to click another app, like this browser. If you wanted to paste, it's _SCREENPRINT CHR$(22), btw. So speaking of pasting, lets try a select all, copy/paste from the QB64 IDE into Notepad... Windows only example. Code: (Select All) _CLIPBOARD$ = "" So with _SCREENPRINT we can do things like fill out web forms (Note: _SCREENPRINT CHR$(9) is Tab to change form fields), gather text from other apps, execute commands with _SCREENPRINT CHR$(13) the Enter key, etc. For some routines like ALT + F to open the QB64 IDE File Menu, you need something more robust like Win32 API SENDKEYS. Windows only Win32 API SENDKEYS example. Code: (Select All) CONST VK_ALT = &H12 'Alt key Pete |