PDF Explorer > General

Capture "Print Screen" with a Script file

<< < (2/3) > >>

RTT:
If you are OK installing a third-party tool, then install a 32-bit version of ImageMagick, making sure you selected the "Install ImageMagickObject OLE Control..." additional tasks option, and then you can save the image in the clipboard, and process it, like this:

--- Code: ---var img = new ActiveXObject("ImageMagickObject.MagickImage.1");
//save clipboard to file
msgs = img.Convert("clipboard:", "c:\\temp\\image.bmp");

//create thumbnail
msgs=img.Convert("c:\\temp\\image.bmp","-thumbnail","244x244>","-background","#ffffffffffff0000","-gravity","center","-extent","244x244",
"(","+clone","-background","black","-shadow","80x3+4+4",")","+swap","-background","none","-layers","merge","+repage",
"-background","#ffffffffffff0000","-gravity","center","-extent","256x256","c:\\temp\\image.png");

--- End code ---

Padanges:

--- Quote ---If you are OK installing a third-party tool, then install a 32-bit version of ImageMagick
--- End quote ---
If there's no better way to capture image clipboard data - ImageMagick is fine. It's a great tool - it is even allowed to be used freely for personal or commercial purposes. Thank you for the solution - the code works fine now!

I have a question about your CopyTextToClipboard/GetTextFromClipboard methods. They seem to work "a bit slower" than the usual code and perhaps that is because of the While cycles with the Sleep() method:

--- Code: ---while(oIe.ReadyState!=4) WScript.Sleep(20);
while(oIe.document.readyState!='complete') WSript.Sleep(20);
--- End code ---
but removing these lines gives no problem to the methods. And trying to paste ~200kb of clipboard text data raises no issues (other than the waiting time). Are they really necessary? What should they help with?

RTT:

--- Quote from: Padanges on September 15, 2016, 08:05:56 PM ---I have a question about your CopyTextToClipboard/GetTextFromClipboard methods. They seem to work "a bit slower" than the usual code and perhaps that is because of the While cycles with the Sleep() method:

--- Code: ---while(oIe.ReadyState!=4) WScript.Sleep(20);
while(oIe.document.readyState!='complete') WSript.Sleep(20);
--- End code ---
but removing these lines gives no problem to the methods. And trying to paste ~200kb of clipboard text data raises no issues (other than the waiting time). Are they really necessary? What should they help with?

--- End quote ---
This is not my code, but these sleep values are indeed too high. A sleep(1) is enough, and the while(oIe.document.readyState!='complete') line is not really needed in this case. Checking if the browser is ready to accept interaction with the loaded document is really needed, or the script will fail if a command is sent before, but with modern fast PCs it gets ready soon than when this code got write. The amount of what is copied/pasted is not the issue here.

Padanges:
Thanks for the reply. I've modified the code lines accordingly.
Lastly, I would like to ask, whether we can escape the need to install ImageMagick at all. I found c++ code sample where you can register a *.dll for creating ImageMagickObject:
https://www.autoitscript.com/forum/topic/117914-imagemagickobject-object/?page=2
Do you think it's possible to get our clipboard image capture function using only "\ImageMagickObject.dll" with JS instead?

RTT:

--- Quote from: Padanges on September 16, 2016, 08:46:55 PM ---Do you think it's possible to get our clipboard image capture function using only "\ImageMagickObject.dll" with JS instead?

--- End quote ---
At least the ImageMagickObject.dll I have, with just 100KB, for sure just implements the COM handling thing. It needs to have many of the other DLL's present, to do the work.

A nice opportunity for you to learn how to code a COM server. ;)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version