Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Copy from clipboard and/or keyboard

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PBCC Copy from clipboard and/or keyboard

    Code:
        #BREAK ON                                           '
                                                            '
    FUNCTION PBMAIN () AS LONG                              '
        t$ = "The quick brown fox."                         '
        CLIPBOARD SET TEXT t$                               ' Copy to clipboard
        COLOR 14,1                                          '
        CLS                                                 '
                                                            '
        LOCATE 5,20                                         '
        u$ = KeyClip                                        ' Read from key/clip
        LOCATE 7,20                                         ' board and verify.
        PRINT;u$;                                           '
        WAITKEY$                                            '
                                                            '
                                                            '
                                                            '
    END FUNCTION                                            '
                                                            '
                                                            '
    REM *************************************************** '
    REM *                                                 * '
    REM * Save this file as "KeyClip.inc"                 * '
    REM *                                                 * '
    REM *************************************************** '
    REM * Written in CC 5.01.                             * '
    REM * Text only.                                      * '
    REM * Enter text from the keyboard and/or clipboard   * '
    REM * or any combination thereof.                     * '
    REM *************************************************** '
    REM * Combine INKEY$ with CLIPBOARD GET TEXT into one * '
    REM * routine.                                        * '
    REM *                                                 * '
    REM * This can come in handy if, for example, you want* '
    REM * to store a partial password in a file. When     * '
    REM * needed, copy the incomplete password to the     * '
    REM * clipboard, go to your web page then manually    * '
    REM * type in what is not stored then paste the rest  * '
    REM * of the password into the web page. (or visa-vis)* '
    REM *                                                 * '
    REM * ENTER or TAB out of the routine at any time.    * '
    REM *************************************************** '
    REM * Couldn't really figure out a "proper" name for  * '
    REM * this.                                           * '
    REM *                                                 * '
    REM * Taken from KEYboard and CLIPboard.              * '
    REM *************************************************** '
                                                            '
    FUNCTION KeyClip AS STRING                              '
        LOCAL c, r, x AS LONG                               '
        LOCAL srow, sCol AS LONG                            ' Starting row/col
        sRow = CURSORY                                      '
        sCol = CURSORX                                      '
        DO                                                  '<-:
        WHILE INSTAT = 0                                    '  | Do other things here
                                                            '  | if you like.
        WEND                                                '  |
        an$ = INKEY$                                        '  |
        IF an$ = CHR$(13) OR an$ = CHR$(9) THEN EXIT LOOP   '  | Return/Tab exits
                                                            '  |
        IF an$ = CHR$(0,82) OR an$ = CHR$(22) THEN          '<:| Shift/Insert or Control-V
        CLIPBOARD GET TEXT TO t$                            ' || read from clipboard
        PRINT;t$;                                           ' ||
        te$ = te$ + t$                                      ' ||
        END IF                                              '<:|
                                                            '  |
        IF an$ = CHR$(8) THEN                               '<:| BackSpace
        te$ = LEFT$(te$,LEN(te$) - 1)                       ' ||
        r = CURSORY                                         ' ||
        c = CURSORX - 1                                     ' ||
        IF c < sCol THEN c = sCol                           ' ||
        LOCATE sRow, c                                      ' ||
        PRINT;" ";                                          ' ||
        LOCATE r, c                                         ' ||
        END IF                                              '<:|
                                                            '  |
        IF LEN(an$) = 2 THEN                                '<:| Function key
                                                            ' || routine(s) here.
        END IF                                              '<:|
                                                            '  |
        IF LEN(an$) = 1 AND ASC(an$) > 31 THEN              '<:| Printable ASCII
        PRINT;an$;                                          ' || characters.
        te$ = te$ + an$                                     ' ||
        END IF                                              '<:|
        LOOP                                                '<-:
                                                            '
        FUNCTION = te$                                      '
        END FUNCTION                                        '
                                 '
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.
Working...
X