[batch] copy to clipboard

Discussion in 'Scripting' started by thethingy, Nov 29, 2011.

  1. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    so I want to list a load of numbers like so in a batch menu;

    1: xxxx-xxxx-xxxx-xxxx-xxxx
    2: yyyy-yyyy-yyyy-yyyy-yyyy
    3: zzzz-zzzz-zzzz-zzzz-zzzz

    the user presses 1,2 or 3 etc as the menu choice and I want the number to be put in to the clipboard for pasting, anyone know how?


    ---------------------------

    also, hsatrt, how do you stop it displaying the hstart icon on the taskbar?
     
  2. Josh Cell

    Josh Cell MDL Developer

    Jan 8, 2011
    3,515
    7,170
    120
    #2 Josh Cell, Nov 29, 2011
    Last edited by a moderator: Apr 20, 2017
    After an command, will capture the return code .

    If you can echo an string or variable, this is code will copy to clipboard:

    Code:
    echo I'll copy this to the clipboard | clip
    or

    Code:
    echo Hello %USERNAME%, your OS Disk is: %SYSTEMDRIVE% | clip
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. padair

    padair MDL Novice

    Jan 14, 2011
    1
    1
    0
    #3 padair, Nov 29, 2011
    Last edited by a moderator: Apr 20, 2017
    Expanding on Josh's example you can then create a menu something like this
    Code:
    @ECHO off
    cls
    :start
    ECHO.
    ECHO 1. xxxx-xxxx-xxxx-xxxx-xxxx
    ECHO 2. yyyy-yyyy-yyyy-yyyy-yyyy
    ECHO 3. zzzz-zzzz-zzzz-zzzz-zzzz
    ECHO.
    ECHO.
    set choice=
    set /p choice=Select 1,2 or 3 and Press Enter: 
    ECHO.
    if not '%choice%'=='' set choice=%choice:~0,1%
    if '%choice%'=='1' echo xxxx-xxxx-xxxx-xxxx-xxxx | clip
    if '%choice%'=='2' echo yyyy-yyyy-yyyy-yyyy-yyyy | clip
    if '%choice%'=='3' echo zzzz-zzzz-zzzz-zzzz-zzzz | clip
     
  4. thethingy

    thethingy MDL Senior Member

    Sep 7, 2010
    301
    41
    10
    is it posible to store say 10 lots of numbers and have a random one copied to the clipboard?
     
  5. Silver Fox

    Silver Fox MDL Novice

    Sep 15, 2012
    1
    0
    0
    Clipboard

    Just stumbled on this forum and don't know if this question was ever answered but here is remedy.

    The easy way is to Hold the Ctrl key and press "C" twice, this will make the office clipboard the default temporary app into which you can save a max of 24 items. To enter a specific item simply follow the underlined tip & click on the desired item. NB Note if you add a 25th item the first one will be deleted. If you need any info about the Windows clipboard - like putting a shortcut on the desktop- just ask.
    Silver Fox.