Copy link to clipboard
Copied
Dear all,
The purpose of my function copyToWinClipboard (text) is to get a string directly into the Windows Clipboard. The purpose is to allow the user of my project just to paste into the open-dialog of the application EndNote. I’m not certain whether the FM clipboard (supported by the copy/cut/paste methods for Doc) really fills into the Windows Clipboard also.
In the PhotoShop script forum I found the idea how to do this.
#target framemaker
// note the blank in the path
copyToWinClipboard ("E:\\_DDDprojects\\FM+EN escript\\FM-11-testfiles\\BibFM-collected.rtf");
function copyToWinClipboard (text) {
var theCmd, clipFile = new File(Folder.temp + "\\ClipBoardW.bat");
clipFile.open('w');
// theCmd = "echo \"" + text + "\" | clip"; // this doesn’t help either
theCmd = "echo " + text + " | clip";
clipFile.writeln (theCmd);
clipFile.close ();
clipFile.execute ();
}
Running this script provides a short flicker (the command prompt), but the clipboard does not contain the expected string. However, when double clicking on the generated I:\!_temp\ClipBoardW.bat the clipboard is filled correctly.
IMHO the execute method does not work correctly for bat files. In another area of my project-script i run an exe file with this method correctly.
Just wanted to report that the sample script in your first post does work on my computer.
You mention the command window comes up shortly, which indicates that the .bat file is executed.
Maybe the execution fails at another point?
If you want to keep the command window open and check for messages, add the "pause" command to the batch file:
....
clipFile.writeln("pause");
clipFile.close();
clipFile.execute();
I'm using FM11 on Windows 7.
Copy link to clipboard
Copied
If nothing helps for my first 'solution', my idea how to do this with the copy method looks a little bit heavy to me:
Would this be the desirable approach?
Copy link to clipboard
Copied
Just wanted to report that the sample script in your first post does work on my computer.
You mention the command window comes up shortly, which indicates that the .bat file is executed.
Maybe the execution fails at another point?
If you want to keep the command window open and check for messages, add the "pause" command to the batch file:
....
clipFile.writeln("pause");
clipFile.close();
clipFile.execute();
I'm using FM11 on Windows 7.
Copy link to clipboard
Copied
JoH,
It seems that my system (W7 x64, FM-12) is special also here...
The Pause has no effect on the display of the command window, it just flickers and disappears - and the clip-buffer contains still the old stuff.
I have checked: the execute() retruns true - hence no error from the script.
Copy link to clipboard
Copied
Hi Klaus,
sorry for my late response.
execute definitely works witch batch-files
Here's a "batch" - example you can test.
There are two methods to prevent window from closing:
"|more" - kind of pagebreak
"pause"
var oTemp = app.UserSettingsDir + "\\tmp";
var MyDosCommand = "ipconfig.exe /a|more";
var MyPath = new Folder (oTemp);
if (!oTemp.exists)
{
var MyPath = new Folder (oTemp);
var lFehler = MyPath.create();
}
oTemp = oTemp + "\\" +"nw.bat";
var MyFile = new File (oTemp);
MyFile.open ('w');
if (MyFile.error > "")
{
alert("ERROR");
}
MyFile.writeln(MyDosCommand);
MyFile.writeln("pause");
MyFile.close();
MyFile.execute();
Copy link to clipboard
Copied
Klaus, I have now tested on my wife's PC (W7, X32) - everything works correctly there.
As mentioned before, my W7 X64 system has some quirks - and this may be just onther one. The most annoying is that in my working environment FM (10 ... newest) does not interact with the ESTK. Hence my script development takes the loop Editor - Add/Refresh in the Script catalogue - Run - look at the console log...Editor ...
For this "Copy to clipboard" problem I have found another solution which I also had reported in this forum.
Also with your recent sample script on my W7 x64 the command console just flickers (it does not execute the pause!). Maybe I have some very special settings....