PDF Explorer > General

Capture "Print Screen" with a Script file

(1/3) > >>

Padanges:
Hi,
is it possible for a script to create a clipboard content file? For example, after pressing "Print Screen" I get the screen captured into memory, but can I create an object which has that memory (paste) content? If we have a text and an image copied simultaneously - can we access both of them separately? Can we verify whether it's a proper txt/bmp format? I would intend then to save the captured clipboard as a *.JPG/*.TXT file with some index number in the file name.


Regards

RTT:
Clipboard access from active scripting, using standard available objects, is very limited. Only with specific ActiveX objects this would be feasible.
Even to just copy/paste text there is the need to use tricks like this:

--- Code: ---function CopyTextToClipboard(sTxt){
    var oIe = WScript.CreateObject('InternetExplorer.Application');
    oIe.silent = true;
    oIe.Navigate('about:blank');
    while(oIe.ReadyState!=4) WScript.Sleep(20);
    while(oIe.document.readyState!='complete') WSript.Sleep(20);
    oIe.document.body.innerHTML = "<textarea id=txtArea wrap=off></textarea>";
    var oTb = oIe.document.getElementById('txtArea');
    oTb.value = sTxt;
    oTb.select();
    oTb = null;
    oIe.ExecWB(12,0);
    oIe.Quit();
    oIe = null;
}                 

function GetTextFromClipboard(){
    var oIe = WScript.CreateObject('InternetExplorer.Application');
    oIe.silent = true;
    oIe.Navigate('about:blank');
    while(oIe.ReadyState!=4) WScript.Sleep(20);
    while(oIe.document.readyState!='complete') WSript.Sleep(20);
    oIe.document.body.innerHTML = "<textarea id=txtArea wrap=off></textarea>";
    var oTb = oIe.document.getElementById('txtArea');
    oTb.focus();
    oIe.ExecWB(13,0);
    var s = oTb.value;
    oIe.Quit();
    oIe = null;
    return s;
}
CopyTextToClipboard("Hello, World!");
pdfe.echo(GetTextFromClipboard());
--- End code ---

The usual method to copy both images and text to the clipboard is by using the RTF format. Is this the format you are tying to deal with? Don't know any ready available trick to access this type of data from active scripting. Probably with MS Word automation this may be possible.

Padanges:
Thanks now we can capture clipboard text. But how do we GetImageFromClipboard()?
sLister can copy both text and image - I was wondering whether I capture both using scripts.

RTT:

--- Quote from: Padanges on September 10, 2016, 07:33:07 AM ---But how do we GetImageFromClipboard()?

--- End quote ---
Not possible without a dedicated ActiveX control or a trick with MS Word, Libre/OpenOffice, or another similar app, automation.
Or executing a PowerShell script, like this ones.

--- Quote ---sLister can copy both text and image - I was wondering whether I capture both using scripts.

--- End quote ---
Not the sLister, but the Sumatra PDF. Indeed it puts in the clipboard both formats, when the selection includes multiple content. Unfortunately doesn't provide a mixed content format, like RTF.

Padanges:
That's quite off-putting. I think binding scripts with windows powershell is not a right way to go.
OK. So could you give some hints on how to go about with ActiveX? Perhaps these links could be useful:
http://www.codeproject.com/Articles/25967/Clipboard-ActiveX-for-Image-Copy-Paste-into-Web-Fo
http://alvinalexander.com/java/java-clipboard-image-copy-paste

Navigation

[0] Message Index

[#] Next page

Reply

Go to full version