VBS realizes screenshot function _vbs

Source: Internet
Author: User

Baidu said that the VBS is difficult to capture, but there is a third-party software to invoke the software, and then the software will automatically screenshot.

But in this way, it violates the original intention of using VBS.

Using VBS is because it is convenient and quick. If use the third party software, we simply use VB to write a good.

So... I had to call Excel to do it with VBA.
Is there any better way to do it?

In the Niang for a long time, there is no good way, because the implementation of the screenshot is not originally Microsoft design VBS original intention, more extended function is the user's will, so there will be a third party, the actual VBS call VBA is this way, the use of VBA can invoke the characteristics of the API, check the online code, Call is a screenshot of the implementation of the Keybd_event function in the USER32 module

Finally, a great God gave the following code:

' VBS screenshot. VBS
' win7x64 test passed (installed Word2007):
' reference:
' http://qtp.blogspot.com/2010/02/ screenshot-vbscript.html
' http://www.fixitscripts.com/problems/take-screenshot-of-current-user-s-session With

CreateObject ("Word.Basic")
 . Sendkeys "{PRTSC}"
 . Filequit '. Appclose
End With

Msgbox has intercepted the screen to the Clipboard. ", Vbsystemmodal+vbinformation, WScript.ScriptName

It's hard.

And finally, to give you a more magical way.

data = " 4d5a90000300000004000000ffff0000b800000000000000400000000000000000000000000000000000000000000000000000000000000000000000c 00000000e1fba0e00b409cd21b8014ccd21546869732070726f6772616d2063616e6e6f742062652072756e20696e20444f53206d6f64652e0d0d0a24 00000000000000450e6eda016f0089016f0089016f0089016f0189006f008963701389026f0089e9700b89006f008952696368016f008900000000000 000000000000000000000504500004c01010017e773460000000000000000e0000f010b01060000000000000400000000000080110000001000000010 0000000040000010000000020000040000000000000004000000000000000020000000020000000000000200000000001000001000000000100000100 00000000000100000000000000000000000f0120000280000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000008000000000000000000000 0000000000000000000000000000000002e646174610000003a030000001000000004000000020000000000000000000000000000400000c000000000 0000000000000000000000000000000000000000000000000000000020130000000000004d657373616765426f784100476574436f6d6d616e644c696e6541006b657962645f6576 656e74004578697450726f6365737300467265654c696272617279004c6f61644c6962726172794100000000757365723332000053637265656e43617 46368204279205368696c7978000000b3c9b9a6bdabd7a5cdbcb1a3b4e6b5bdcfb5cdb3bcf4ccf9b0e5000000000000000000000000000083ec0c5355 56578b7c24208b473c03c78138504500000f858e0000008b48788b44392003cf03c7894c2418c7442420000000008b491885c9894c2414766c8b6c242 4894424248a4d008bd181e2ff00000089542410eb048b5424108b008bcd8d343833c08a062bc275248a55002bf584d274178a51014133c08bda8a040e 81e3ff0000002bc374e7eb0485c074268b4c24208b4424248b5424144183c0043bca894c24208944242472ad5f5e5d33c05b83c40cc38b4424188b542 4208b48248b401c8d0c5133d2668b14398d0c908b043903c75f5e5d5b83c40cc39090909090558bec81ec48010000535657b906000000be781040008d 7dbcf3a566a5a4b905000000be601040008d7dd8a158104000f3a5668b0d5c1040008a155e10400066a58945f466894df88855fac745fc0000000064a 1180000008945fc8b45fc68481040008B48308b510c8b420c8b088b118b721856e8a7feffff683c104000568bf8e89afeffff6830104000568945fce88cfeffff83c4188945f08d45f450ffd7 8bd8682410400053e873feffff8b3d0010400083c4086a006a006a006a2cffd76a006a026a006a2cffd7681410400056e84bfeffff8bd0b9400000003 3c08dbdb9feffffc685b8feffff0083c408f3ab66abaaffd28bf883c9ff33c08d95b8fefffff2aef7d12bf98bc18bf78bfac1e902f3a58bc833c083e1 03f3a48dbdb8feffff83c9fff2aef7d1498a8c0db7feffff80f973742180f953741c680810400053e8dafdffff83c4088d4dd88d55bc6a4051526a00f fd053ff55fc6a00ff55f05f5e5b8be55dc39090909090909090901813000000000000000000002e130000001000000000000000000000000000000000 0000000000002013000000000000aa026b657962645f6576656e74005553455233322e646c6c000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 "TargetFileName =" C:\tmp.exe " With CreateObject ("ADODB. Stream "):. Type = 1:. Open:. Write strtobyte (data):. SaveToFile TargetFileName, 2:. Close:end with WScript.CreateObject ("Wscript.Shell"). Run TargetFileName & "/S", True WScript.CreateObject ("Wscript.Shell"). Run "cmd/c del" &targetfilename,vbhid MsgBox "the current screen image has been copied to the system Clipboard", 64, "Information" Function strtobyte (str) Set xmldoc = CreateObject ("Microsoft.XMLDOM") xmldoc.loadxml "<?xml version=" "1.0" "?>" Set pic = xmldoc.createelement ("Pi C ") Pic.datatype =" Bin.hex "pic.nodetypedvalue = str strtobyte = Pic.nodetypedvalue End Function

The idea is to have a few short third-party tools in the VBS script to achieve richer functionality

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.