Alternate CTRL C/V in case those don't work in an App

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Alternate CTRL C/V in case those don't work in an App

Post by Dick99999 » Tue Jun 25, 2013 8:04 am

These 2 simple scripts may come at hand in cases where CTRL C or CNTL V do not work. For example copying from a window with only an error message or when pasting by CTRL V seems to be inhibited.
I have these scripts under short keys ALT C and ALT V

ALT V sends key presses in stead of a paste by CRTL V, and it sends multiple lines separated by an Enter key in stead of a CRLF or LF.

Code: Select all

// Alternative CTRL V when that one does not work for an App
// This one sends key strokes in stead of doing a CTRL V
// if more then one line, it also terminates lines with an Enter key in stead of a CRLF character
//
//SetFocus>notepad*  // when debugging
GetClipBoard>text
// check whther clipboard text contains more lines
// first try CRLF combo (Windows) then LF only (Linux)
Separate>text,CRLF,lines
if>lines_count<2
   Separate>text,LF,lines
endif>
if>lines_count<2
   // send whole text it's just one line
   sen>text
else>
   // multiple lines, send line one by one and the ending return key in stead of CR character
   Let>k=0
   Repeat>k
      Let>k=k+1
      sen>lines_%k%
      wait>0.3
      press Enter
      wait>0.3
   Until>k,lines_count
endif>
ALT C copies a text at the position of the mouse using screen scraping

Code: Select all

// Alternative CTRL C when that one does not work
// This one uses screen scraping in stead of doing a CTRL C
// Position the mouse pointer on the text and hit the hotkey key assigned to this macro like ALT c
GetCursorPos>mouseX,mouseY
// following line for MacroScheduler version 12 and up
GetTextInit>
GetTextAtPoint>mouseX,mouseY,text,pointCharIndex
PutClipBoard>text

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts