Clipboard & File

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
HolyAbsolut
Newbie
Posts: 17
Joined: Wed Sep 21, 2011 10:28 am

Clipboard & File

Post by HolyAbsolut » Wed Jul 10, 2013 10:44 am

Hi everybody,

I have a small question. I want to add a file to my clipboard.

But if the description is correct it is only possible to insert a Text.

Is there any another way?

I'm using v14.0.12

Best regards

HolyAbsolut

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Jul 10, 2013 12:41 pm

Use the CopyFile or MoveFile commands.

Code: Select all

CopyFile>c:\temp\myfile.txt,c:\my documents\myfile.old
OR with variables:

Code: Select all

Let>filename=c:\temp\myfile.txt
Let>newfilename=c:\temp\myfile.new
CopyFile>filename,newfilename

Code: Select all

MoveFile>c:\temp\myfile.txt,c:\temp\myfile.bak
Or with variables:

Code: Select all

Let>filename=c:\temp\myfile.txt
Let>newfilename=c:\temp\myfile.bak
MoveFile>filename,newfilename

HolyAbsolut
Newbie
Posts: 17
Joined: Wed Sep 21, 2011 10:28 am

Post by HolyAbsolut » Wed Jul 10, 2013 12:53 pm

Hi,
thanks for your fast reply. But unfortunately I can not use this in my case as I "Copy" the file to an other (foreign) Programm.

Best regards

HolyAbsolut

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Wed Jul 10, 2013 3:06 pm

Sounds like the program you want interact with has a file open/import feature. There most likely is a way to copy files to the program but I can't tell you how since I know nothing about it.

Here are a couple examples how you can interact with MS Paint.

Code: Select all

//Directory to image
Let>FileToAdd=C:\MyImg.bmp
RunProgram>mspaint.exe
WaitWindowOpen>Untitled - Paint
Wait>1
SetFocus>Untitled - Paint
Wait>1
//Send Control+o to open the Open window
CapsOff
Press Ctrl
Send>o
Release Ctrl
WaitWindowOpen>Open
Wait>1
GetWindowHandle>Open,hWndParent
FindObject>hWndParent,Edit,,1,hWnd,X1,Y1,X2,Y2,result
ObjectSendKeys>hWnd,%FileToAdd%,VK13

Code: Select all

//Directory to image
Let>FileToAdd=C:\MyImg.bmp
RunProgram>mspaint.exe "%FileToAdd%"

HolyAbsolut
Newbie
Posts: 17
Joined: Wed Sep 21, 2011 10:28 am

Post by HolyAbsolut » Thu Jul 11, 2013 7:09 am

Hi
thanks for your continues support. The program I'm talking about will not support such a feature as handing over parameters. It even does not support CTRL-V I only can right click and press "Add File from Clipboard"

So if there is no way to take it in copy I will try it on an other way


Best regards

HolyAbsolut

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Fri Jul 12, 2013 12:16 am

You should be able to browse to the file in explorer have macroscheduler copy the file to clipboard, switch to the application, right click and add file from clipboard,

If you can give us the program name, maybe a screenshot Iam sure we can work something out.

Edit: Attached a quick mock up. Was written very quickly on a Windows 7 machine, may require some tweaking for your needs.

Code: Select all

//http://www.mjtnet.com/usergroup/clipboard-file-t7852.html

Let>INPUT_BROWSE=1
Input>vFileLocation,Please Select File To Save To Clipboard,
If>%vFileLocation%=
  MDL>No File Selected / Cancelled Now Exiting
  Goto>Exit
EndIF

ExtractFilePath>%vFileLocation%,vFilePath
ExtractFileName>%vFileLocation%,vFileName

ExecuteFile>%vFilePath%

Separate>%vFilePath%,\,vFilePathArray
Let>vEndFolder=vFilePathArray_%vFilePathArray_Count%

Let>WW_TIMEOUT=30
WaitWindowOpen>%vEndFolder%
If>WW_RESULT=FALSE
  MDL>Window Timed Out Closing Application
  Goto>Exit
EndIf
Wait>5

SendText>%vFileName%

Press Ctrl
Wait>0.05
SendText>c
Wait>0.05
Release Ctrl
Wait>0.05
CloseWindow>%vEndFolder%
MDL>File Copied To Users Clipboard

Label>Exit
Exit>0
FIREFIGHTER

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Fri Jul 12, 2013 2:07 am

I also think this helps explain the issues around something like copying a file to clipboard.
Question: What is the command line equivalent to pressing CTRL+C over a file in the file manager so that the file (not the filename) is copied to the clipboard?

Answer: When you press Ctrl-C over a file in the file manager, the file's contents IS NOT copied to the clipboard.
Basically this seems to be a common questions and no real answer.

You could look at DROPTOCLIP http://jpsoft.com/forums/threads/copyin ... -tcc.4463/

But I don't have the time for that at the moment. As when you copy a file you are copying more that just the path, there are like 12 different strings / handles so the application receiving the file knows what to do.
FIREFIGHTER

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