Console Window Copy & Paste

Post your working scripts, libraries and tools
codegirl3942
Posts: 3
Joined: 06 Jul 2016, 09:59

Console Window Copy & Paste

17 Jul 2016, 01:51

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 MakeUseOf.com @ http://www.makeuseof.com/tag/10-cool-au ... 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
{
^c:: 
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 
}
else
{
  Send, {Enter}
  toggle = 0
}  
Return 

^v::
SendInput {Raw}%clipboard%      ; paste any text into the Console Window... not just text you copied from the Console Window.
Return
}
#IfWinActive
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 https://msdn.microsoft.com/en-us/librar ... 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.
User avatar
Hajin
Posts: 48
Joined: 13 May 2016, 09:16

Re: Console Window Copy & Paste

17 Jul 2016, 16:47

Interesting, my "symbolic links" are made more easily now. :)

Return to “Scripts and Functions”

Who is online

Users browsing this forum: hasantr and 22 guests