Page 1 of 1

Console Window Copy & Paste

Posted: 17 Jul 2016, 01:51
by codegirl3942
If you want to copy and paste via ctrl-c and ctrl-v into Windows command prompt (versions XP through 8.1) (ie, copy/paste into the console window, or the terminal window) then this script should help. The ^v paste function idea I got from @ ... ipts-make/, and then wrote the ^c part. You have to press ctrl-c twice, first to enable the "Mark" mode, whereby the mouse (or shift+arrow keys on keyboard) can select the text to be copied. Then clicking ^c again actually copies the marked/highlighted text. Then pressing ctrl-v pastes the text at the current cursor position. It's a bit more complicated than it should be, but still fairly intuitive and very helpful to me personally, and probably others who aren't so familiar with console-window navigation.

Code: Select all

; The below hotkeys work in the console-window (Windows Command Prompt) only... and roughly enable normal usage of ctrl-c and ctrl-v for copy/paste.
#IfWinActive ahk_class ConsoleWindowClass
If toggle != 1
  CoordMode, Mouse, Window
  MouseGetPos, x, y
  MouseClick, Right, 40, 80   ; this opens the Console Window's context menu... and then selects 'Mark'.
  Sleep, 0050 
  Send, {Down}{Enter}
  MouseMove, x, y 
  toggle = 1
  ; MsgBox,,, You may now use the mouse (or shift+arrows on the keyboard) to select some text... then press ctrl-c again to copy the text to the clipboard., 2.0 
  Send, {Enter}
  toggle = 0

SendInput {Raw}%clipboard%      ; paste any text into the Console Window... not just text you copied from the Console Window.
I couldn't figure out how to make the FLASHING CURSOR (ie, Mark-mode cursor) position at the location of the input-text cursor, but that might not be desired anyway. See ... 85%29.aspx for official MS Console functions... maybe you'll get an idea of how to improve this code. Hope someone finds this submission to have been of help. Later.

Re: Console Window Copy & Paste

Posted: 17 Jul 2016, 16:47
by Hajin
Interesting, my "symbolic links" are made more easily now. :)