Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Sending the date to clipboard without opening a command window  (Read 3152 times)

0 Members and 1 Guest are viewing this topic.

shyCordial

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 10
    Sending the date to clipboard without opening a command window
    « on: September 12, 2018, 06:54:33 PM »
    Hi!

    tl/dr:
    Can someone please give me a simple Run command snippet that will send the short version of today's date (ex. 09/12/18) to the clipboard without opening any Command prompt windows or changing focus? I have spent several hours searching for answers and trying different things, to no avail.

    The Run Command I was trying to use is:
    Code: [Select]
    echo %date:~4,6%%date:~12,2% | clip
    Context / Details:
    I have a macro keyboard (Razer Ornata Chroma) that allows me to create simple macros and bind them to keys.

    The Macro software allows me to use keystrokes, text, mouse clicks, and Run Commands. For example I have a simple Run Command + text macro that opens a browser window, pastes a fogbugz case URL without a case ID, and leaves the cursor at the end of the URL so I can type in the case ID. Yay. I am not a coder, so I just use a simple run command: "firefox URL about:blank"

    I'd like to create another basic macro that essentially inserts the date into whatever program/text field has focus, just to save me some typing time.
    I successfully created one using a Run command that pipes the %date% variable (or just the output of DATE /T) into the clipboard. Then I try to use a Keystroke to perform Ctrl+V. Should be simple.

    However I have 2 issues:
    1. My macro opens the cmd prompt window. I don't want a command window popping up every time I use the macro, or I will have 100 by the end of the day.
    2. The cmd window takes focus. So instead of pasting my clipboard contents into OneNote or FogBugz or whatever, I just end up with a "v" on the command line of a cmd window.
    3. I don't actually know how to use MS-DOS commands, so I'm not sure how to run a command silently / with invisible window. Also, the echo command baffles me.


    Thank you for your help!

    Salmon Trout

    • Guest
    Re: Sending the date to clipboard without opening a command window
    « Reply #1 on: September 13, 2018, 10:56:03 AM »
    Save the code below as a Visual Basic Script (with a .vbs extension)

    Make sure that wscript.exe is the default script engine
    Make sure that script engine logo display is disabled.
    To do these things open an Administrator command prompt and execute this command (you only need to do it once):

    wscript //h:wscript //nologo //s

    Code: [Select]
    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("clip")
    tnow=now()
    dd = day(tnow): if dd < 10 Then dd = "0" & dd
    mm = month(tnow): if mm < 10 Then mm = "0" & mm
    yyyy = year(tnow)
    dstring=mm & "/" & dd & "/" & yyyy
    Set oIn = oExec.stdIn
    oIn.WriteLine dstring
    oIn.Close

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Sending the date to clipboard without opening a command window
    « Reply #2 on: September 13, 2018, 03:45:17 PM »
    Use another keyboard macro program.
    Try this one:
    http://www.download82.com/download/Windows/KeyText
    Quote
    KeyText screenshotKeyText is a multi-function text and automation tool that is capable of storing boilerplate text, ready to be pasted or typed into any application or document with only a hotkey press, menu selection or trigger text. The program also features a "Right-click anywhere" function which eases form-filling and saves you precious time.

    KeyText also integrates commands to change windows, run applications, visit Internet websites, click buttons, and many more. in addition, the application enables you to automate mouse clicks that hit the right area in cases when a window changes its position.

    The "Smart Select" function allows you to easily select text in any application and trigger various actions (go to an online map, website, dictionary, e-mail, etc) according to the type of the selected text (URL, E-mail address, Zip Code, etc).

    KeyText integrates powerful and advanced features such as regular expressions which let you handle and examine text in a sophisticated and efficient manner. The built-in scheduler lets you set times and days for running various programs or monitor for specific dialogs, windows, password requests and automatically fill them with only one click.
    Pros
    The documentation is rather large. Sorry, I can't help you with that. I use it to do do this:
    Thursday, September 13, 2018
    The above line was entered when I held the alt key and hit F6.
    You will have to download and install the program end read the documentation. Sorry I can not help you with the details.   8)

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Sending the date to clipboard without opening a command window
    « Reply #3 on: September 13, 2018, 08:50:15 PM »
    ECHO is an internal command that is built-in to cmd.exe. If you are trying to execute that from the run box you would need to use cmd.exe with the /C option.

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Sending the date to clipboard without opening a command window
    « Reply #4 on: September 13, 2018, 09:23:12 PM »
    You can bind a keystroke to a macro in Windows.
    https://support.microsoft.com/en-us/help/237179/assign-macro-or-function-to-keys-on-your-keyboard
    Quote
    This article describes how to change or assign a command, a macro, or a program to a keyboard shortcut on the Microsoft Keyboard.

    That might be of some help, but it is beyond  my understanding.  :-[