Softimage JScriptからクリップボードを使う

UseClipboard("文字列を渡す\r\n改行もできる");


//クリップボードに文字列コピー
function UseClipboard(in_stg){
	// クリップボードに文字列を設定
	var jp;
	if (!jp) jp = {};
	if (!jp.raindrop) jp.raindrop = {};
	if (!jp.raindrop.frog) jp.raindrop.frog = {};
	jp.raindrop.frog.clipboard || (function ()
	    {
	        // コマンドのID
	        var OLECMDID_COPY = 12;
	        var OLECMDID_PASTE = 13;
	        var OLECMDID_SELECTALL = 17;

	        // IE の初期化
	        var _internetExplorer = new ActiveXObject ('InternetExplorer.Application');
	        _internetExplorer.navigate ("about:blank");
	        while (_internetExplorer.Busy)
	            WScript.Sleep (10);

	        // textarea 要素を作成する
	        var _textarea = _internetExplorer.document.createElement ("textarea");
	        _internetExplorer.document.body.appendChild (_textarea);
	        _textarea.focus ();

	        jp.raindrop.frog.clipboard = {
	            // クリップボードに文字列をコピー
	            setText: function (text)
	            {
	                _textarea.innerText = text;
	                _internetExplorer.execWB (OLECMDID_SELECTALL, 0);
	                _internetExplorer.execWB (OLECMDID_COPY, 0);
	            },

	            // クリップボードより文字列を取得
	            getText: function ()
	            {
	                _textarea.innerText = "";
	                _internetExplorer.execWB (OLECMDID_PASTE, 0);
	                return _textarea.innerText;
	            },

	            // IE を解放
	            release: function ()
	            {
	                _internetExplorer.Quit ();
	            }
	        };
	    }());


	//
	jp.raindrop.frog.clipboard.setText (in_stg);
	
}