Using Windows Clipboard

Post Reply
User avatar
clintonman
Captain
Posts: 5432
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Using Windows Clipboard

Post by clintonman »

I found out how to use the windows clipboard in script. The attach script will convert feet and inches to meters and will copy the result to the clipboard so it can be pasted elsewhere. The odd thing is you have to use 2 different objects when using the clipboard. The "InternetExplorer.Application" object is used to write to the clipboard and the "htmlfile" object is used to read from the clipboard. There are permission issues so when writing to the clipboard windows will ask first. I suspect that behavior can be adjusted in the Internet Explorer browser if it's still available.

Code: Select all

	var ClipboardCopy = params.ConValue('ClipboardCopy');
	var Inches = params.ConValue('Inches');
	var Feet = params.ConValue('Feet');

	var meters =  Feet / 3.28084 + Inches / 39.37008;

	params.ConValue("Meters") = meters;

	if(!ClipboardCopy) return;

	var ieObj = new ActiveXObject("InternetExplorer.Application");

	ieObj.Navigate("about:blank");

	ieObj.document.parentWindow.clipboardData.setData("text", ""+meters);

	ieObj.Quit();

	//note how to read clipboard

	//var htmlfile = new ActiveXObject("htmlfile")
	//var cpValue = htmlfile.parentWindow.clipboardData.getData("text")
Attachments
Feet Inches to Meters.RsObj
(9.11 KiB) Downloaded 15 times
Clinton Reese

http://clintons3d.com
Post Reply