getData method
Gets the data in the specified format from the clipboard through the dataTransfer object or the clipboardData object.
Syntax : object.getData(format)
Parameters :
format [in] Type: String
A String that specifies one of the following data format values.
Text
Gets data formatted as text.
URL
Gets data formatted as a URL.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace ClipboardPasteImage
{
[Guid("C503138B-C771-40A3-804B-4A702F8C9D50"), ProgId("ClipboardPasteImage.pasteImageObject")]
public class pasteImageObject
{
public void getimg(string fileName)
{
System.Drawing.Image im = Clipboard.GetImage();
im.Save(fileName);
}
}
}
<html>
<head>
<script>
var fso = null;
var netplug = null;
function toImage(destFile)
{
if(netplug == null) netplug = document.getElementById("netobj");
var data = netplug.getimg(destFile);
}
function getExtension(filename)
{
var parts = filename.split(".");
return (parts[(parts.length-1)]);
}
function LoadImage()
{
var strFileName = document.getElementById("fic").value;
var destFile = strFileName.substr(0, strFileName.lastIndexOf(".")) + ".png";
var imgplug = document.getElementById('imageplugin');
imgplug.IMAGE_URL = strFileName;
imgplug.CopyToClipboard();
toImage(destFile);
}
</script>
</head>
<body >
Fichier: <input type="text" id="fic" name="fic" /><br />
<input type="button" onclick="LoadImage();" value="Charger"/>
<object id='imageplugin' classid="CLSID:00000000-0000-0000-0000-000000000000" width='100%' height='500px'>
<param name="FM" value="98304">
</object>
<object id='netobj' classid="CLSID:C503138B-C771-40A3-804B-4A702F8C9D50" width='100%' height='500px'></object>
</body>
</html>
23 oct. 2014 à 10:20
Merci, mais je ne parviens pas à récupérer l'objet en fait, et l'event n'existe pas sous ie ... en fait je pense qu'il faudrai que je me tourne vers un composant activx mais je ne vois pas lequel, je patauge un peu ...
naga
23 oct. 2014 à 10:47
23 oct. 2014 à 11:30
23 oct. 2014 à 12:03
tu dis être en DOT.net 4.5 ... alors pourquoi ne pas utiliser les fonctions du press-papier du dot.net directement ??
=> Sachant que tu peux piloter ton navigateur depuis le dot.net ... pourquoi vouloir passer par du javascript ?
Et pour l'utilisation du clipboard :
http://msdn.microsoft.com/fr-fr/library/system.windows.clipboard.getimage%28v=vs.110%29.aspx