How to take a screenshot using VBS

StealthyDev
StealthyDev used Ask the Experts™
on
Hi Experts!

How to take screenshot (similar to print screen) and save the same to a JPEG file in harddisk.?

Do this in VBS that runs in windows?

Regards,
Senthur
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Check this link:
http://community.bistudio.com/wiki/VBS_screenshot

Hope it helps ;).
Top Expert 2010

Author

Commented:
@str82no1: thanks for your link, can you please give me an executable file with that function?

I dont understand how to execute it.
TechnoChatWintel Administrator / Cloud Computing
Commented:
You can find a simple example on following link.
http://qtp.blogspot.com/2010/02/screenshot-vbscript.html

Thanks
Saugata
Top Expert 2010

Author

Commented:
That looks pretty good. But my requirement is:

#1: Save clipboard content to a variable.
#2: Take screen shot.
#3: Save it to a file location configured to a variable.
#4. Restore clipboard content back.

Thanks.
Top Expert 2010

Commented:
That's kinda tricky to do... you can do the clipboard operations if the script is an HTA (or if you use WshExtra)... but the clipboard to jpg is a bit harder and could get messy/unreliable without using calling an external app/object.

This is pretty easy to do via vb .NET and you can avoid touching the clipboard.

When this vbs is launched, it will create DeskCap.exe in the same dir as the script... then launches it.  The exe saves a file to the same directory called Desktop.jpg.  This file is moved & renamed to a folder & name of your choice.  DeskCap.exe is deleted after executing.

I can provide the source code for the exe if you like.
strDestinationDir="c:\temp"
strFileName="My File Name.jpg"

SourceDir=replace(wscript.scriptfullname,wscript.scriptname,"")

Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FileExists(SourceDir & "DeskCap.exe") then MakeDeskCap(SourceDir & "DeskCap.exe")

Set WshShell=CreateObject("Wscript.Shell")
WshShell.run Chr(34) & SourceDir & "DeskCap.exe" & Chr(34),0,true

fso.MoveFile SourceDir & "Desktop.jpg",strDestinationDir & "\" & strFileName
fso.DeleteFile SourceDir & "DeskCap.exe"

msgbox "All done!" & vbCrLf & vbCrLf & "See file:  " & strDestinationDir & "\" & strFileName,vbInformation,"Screen Shot"

Sub MakeDeskCap(strOutFile)
	Set oFile = fso.OpenTextFile(strOutFile, 2, True)
	ON ERROR RESUME NEXT
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010400A250944A0000000000000000E0000E010B01060000280000000E000000000000CE46000000200000006000000000001100200000000200000400000000000000040000000000000000C000000004000000000000020000040000100000100000000010000010000000000000100000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("744600005700000000800000580800000000000000000000000000000000000000A000000C000000006000001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000D4260000002000000028000000040000000000000000000000000000200000602E73646174610000A60000000060000000020000002C0000000000000000000000000000400000C02E727372630000005808000000800000000A0000002E0000000000000000000000000000400000402E72656C6F6300000C00000000A00000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00020000003800000000000000000000000000004000004200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("B0460000000000004800000002000000B8310000BC140000010000001300000650200000EC0C000000000000000000000000000000000000000000000000000000000000000000000000000000000000E80C0000CECAEFBE010000009E0000002953797374656D2E5265736F75726365732E5265736F757263655265616465722C206D73636F726C69627353797374656D2E5265736F75726365732E52756E74696D655265736F757263655365742C206D73636F726C69622C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623737613563353631393334653038390100",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000A000000060000006D53797374656D2E436F6465446F6D2E4D656D626572417474726962757465732C2053797374656D2C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623737613563353631393334653038395E53797374656D2E426F6F6C65616E2C206D73636F726C69622C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623737613563353631393334653038396953797374656D2E44726177696E672E53697A652C2053797374656D2E44726177696E672C20566572",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("73696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623033663566376631316435306133617053797374656D2E476C6F62616C697A6174696F6E2E43756C74757265496E666F2C206D73636F726C69622C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623737613563353631393334653038395D53797374656D2E537472696E672C206D73636F726C69622C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("623737613563353631393334653038395C53797374656D2E496E7433322C206D73636F726C69622C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D623737613563353631393334653038395041445041445006CC8987E1639097EEFE9B9A26E8FBB243B5A8B6512B3AB81DA253041B51B20E941D9A17E87D8533F10000003B010000D800000000000000BB0000003100000094000000730000005200000016010000DA0400002C240074006800690073002E00440065006600610075006C0074004D006F006400690066006900650072007300000000001C240074006800",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("690073002E0044007200610077004700720069006400A00000001C240074006800690073002E004700720069006400530069007A006500D60000001C240074006800690073002E004C0061006E00670075006100670065007D01000022240074006800690073002E004C006F00630061006C0069007A00610062006C0065002A07000018240074006800690073002E004C006F0063006B00650064006007000014240074006800690073002E004E0061006D0065009607000020240074006800690073002E0053006E006100700054006F0047007200690064009D07000020240074006800690073002E005400720061007900480065006900670068007400D3",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("07000026240074006800690073002E0054007200610079004C006100720067006500490063006F006E00D8070000000001000000FFFFFFFF01000000000000000C020000004C53797374656D2C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D6237376135633536313933346530383905010000001F53797374656D2E436F6465446F6D2E4D656D62657241747472696275746573010000000776616C75655F5F000802000000001000000B010001000000FFFFFFFF010000000000000004010000000E53797374656D2E426F6F6C65616E01000000076D5F76616C7565",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("0001010B020001000000FFFFFFFF01000000000000000C020000005453797374656D2E44726177696E672C2056657273696F6E3D312E302E353030302E302C2043756C747572653D6E65757472616C2C205075626C69634B6579546F6B656E3D6230336635663766313164353061336105010000001353797374656D2E44726177696E672E53697A650200000005776964746806686569676874000008080200000008000000080000000B030001000000FFFFFFFF010000000000000004010000002053797374656D2E476C6F62616C697A6174696F6E2E43756C74757265496E666F0A000000066D5F6E616D650A6D5F646174614974656D116D5F75736555",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("7365724F766572726964650963756C7475726549440C6D5F6973526561644F6E6C790B636F6D70617265496E666F0874657874496E666F076E756D496E666F0C6461746554696D65496E666F0863616C656E64617201000000000303030303080108012053797374656D2E476C6F62616C697A6174696F6E2E436F6D70617265496E666F1D53797374656D2E476C6F62616C697A6174696F6E2E54657874496E666F2553797374656D2E476C6F62616C697A6174696F6E2E4E756D626572466F726D6174496E666F2753797374656D2E476C6F62616C697A6174696F6E2E4461746554696D65466F726D6174496E666F1D53797374656D2E476C6F62616C697A",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("6174696F6E2E43616C656E646172060200000000CA000000007F000000010903000000090400000009050000000A0A04030000002053797374656D2E476C6F62616C697A6174696F6E2E436F6D70617265496E666F020000000977696E33324C4349440763756C74757265000008087F0000007F00000004040000001D53797374656D2E476C6F62616C697A6174696F6E2E54657874496E666F030000000B6D5F6E446174614974656D116D5F757365557365724F766572726964650D6D5F77696E33324C616E674944000000080108CA000000007F00000004050000002553797374656D2E476C6F62616C697A6174696F6E2E4E756D626572466F726D6174",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("496E666F1F000000106E756D62657247726F757053697A65731263757272656E637947726F757053697A65731170657263656E7447726F757053697A65730C706F7369746976655369676E0C6E656761746976655369676E166E756D626572446563696D616C536570617261746F72146E756D62657247726F7570536570617261746F721663757272656E637947726F7570536570617261746F721863757272656E6379446563696D616C536570617261746F720E63757272656E637953796D626F6C12616E736943757272656E637953796D626F6C096E616E53796D626F6C16706F736974697665496E66696E69747953796D626F6C166E65676174697665",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("496E66696E69747953796D626F6C1770657263656E74446563696D616C536570617261746F721570657263656E7447726F7570536570617261746F720D70657263656E7453796D626F6C0E7065724D696C6C6553796D626F6C0A6D5F646174614974656D136E756D626572446563696D616C4469676974731563757272656E6379446563696D616C4469676974731763757272656E6379506F7369746976655061747465726E1763757272656E63794E656761746976655061747465726E156E756D6265724E656761746976655061747465726E1670657263656E74506F7369746976655061747465726E1670657263656E744E656761746976655061747465",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("726E1470657263656E74446563696D616C4469676974730A6973526561644F6E6C79116D5F757365557365724F766572726964651576616C6964466F72506172736541734E756D6265721776616C6964466F725061727365417343757272656E637907070701010101010101010101010101010100000000000000000000000000080808080808080808080808010101010906000000090700000009060000000609000000012B060A000000012D060B000000012E060C000000012C060D000000012C060E000000012E060F00000002C2A40A0610000000034E614E061100000008496E66696E6974790612000000092D496E66696E697479090B000000090C",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000006150000000125061600000003E280B0CA0000000200000002000000000000000000000001000000000000000000000002000000010001010F060000000100000008030000000F070000000100000008030000000B010001000000FFFFFFFF010000000000000004010000000E53797374656D2E426F6F6C65616E01000000076D5F76616C75650001000B010001000000FFFFFFFF010000000000000004010000000E53797374656D2E426F6F6C65616E01000000076D5F76616C75650001000B0405466F726D31010001000000FFFFFFFF010000000000000004010000000E53797374656D2E426F6F6C65616E01000000076D5F76616C7565000101",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("0B0550000000010001000000FFFFFFFF010000000000000004010000000E53797374656D2E426F6F6C65616E01000000076D5F76616C75650001000B3A007314000006280100000A00002A00C20002280200000A00020225FE071B000006730300000A280400000A000273010000067D07000004026F1600000600002A0000009200032C15027B060000042C0C027B060000046F0500000A0000000203280600000A00002A000000133004006000000001000011000212001B1F0D280700000A00066F0800000A000212002024010000200A010000280700000A00066F0900000A0002176F0A00000A000272010000706F0B00000A0002166F0C00000A000272",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("010000706F0D00000A0002176F0E00000A00002A13300B00D30100000200001100026F0F00000A00281000000A6F1100000A0A06720D00007016281200000A163306720F0000700A281300000A13171613163871010000111711169A1306110511066F1400000A281500000A13051205281600000A1205281700000A731800000A0B07281900000A0C08176F1A00000A0008281B00000A16161205281600000A1205281C00000ADA1205281700000A1205281D00000ADA6F1E00000A00086F1F00000A0D281300000A131516131438D4000000111511149A1307141313121311076F2000000A13121212141311121116131012102818000006130411076F1400",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("000A130F120F281C00000A1205281C00000ADA130911076F1400000A130F120F281D00000A1205281D00000ADA130A091109110A11066F1400000A130F120F281600000A11066F1400000A130E120E281700000A1104161611066F1400000A130D120D281600000A11066F1400000A130C120C281700000A202000CC002819000006130811082D0F732100000A130B110B282200000A00001104281A00000626111417D6131400111411158E693F21FFFFFF08096F2300000A00086F2400000A00111617D6131600111611178E693F84FEFFFF07067217000070282500000A282600000A6F2700000A00026F2800000A00002A002602282B00000A00002A0000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("1330020011000000030000110002280F0000066F030000060A2B00062A000000133009009D0000000400001100202000CC0013070328100000060D1209FE150500000203120928120000062612097B0400000412097B02000004DA130812097B0500000412097B03000004DA130409280A0000060C091108110428090000060B0807280D0000061305081616110811040916161107280800000626081105280D0000062608280B00000626030928110000062607282C00000A130607280C0000062611060A2B00062A0000001330030014000000050000110002036F030000060A0604056F2700000A00002A13300300130000000600001100026F020000060A",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("0603046F2700000A00002A00133008007B00000007000011007301000006130611066F02000006732D00000A0B0405076F2E00000A732F00000A0A12040F01281C00000A0F01281D00000A0405283000000A0006281900000A0D120516160405283000000A00090711051204281C00000A1204281D00000A1204281600000A1204281700000A186F3100000A00060C2B00082A005202282B00000A0002202000CC007D01000004002A0000002602282B00000A00002A000042534A4201000100000000000C00000076312E312E34333232000000000005006C000000A4080000237E000010090000E008000023537472696E677300000000F011000034000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("2355530024120000100000002347554944000000341200008802000023426C6F620000000000000001000001573D02140903000000FA013300020000010000002A00000007000000170000001B000000320000003C0000000F0000000B0000000300000034000000040000000E000000010000000700000001000000040000000000D4080100000000000600D20029001600DF003C0016001F010801160063013C0016006A013C0006009F0229001A00BF024B000E00F102DB020600E80329000600060429001A009B044B000600AB0429000600C10429001600CD043C001A00F7044B001A001B054B001A0047054B00160067053C001A0070054B000E007705",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("DB0206009B0529000A00D205AB0516003C062306160066063C00160074063C000E00C906B6060600FF06290006001207B60616003B070801160057073C0006008D076E070600A3076E070600CD07B6060600F307E10706000C086E0706001A08290006003008E10706004B08E10706006608E10706007F08E10706009808E1070600B508E1070000000001000000000001000100010000006B00790005000100010003000000930000000500010007000200000099000000050002000E000A010000A000000019000200130001000000A500AB001D000600130002010000BA000000290008001C000600AF013A000600A9023A000600AE023A000600B2023A00",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("0600B8023A000100FC027C0001001B03800006060B043A005680AF01AD0056801304AD0056801C04AD0056802304AD0056802D04AD0056803604AD0056804104AD0056804D04AD0056805704AD0056806204AD0056806A04AD0056807304AD0056807D04AD0056808704AD0056809104AD00F42F000000000618D900130001000030000000000600E500170001002030000000000600F3001C000100CC300000000006002B0122000200EC300000000006004F012A0005000C310000000006007401310007009431000000000618D90013000A000000000080001620B7013D000A000000000080001620FA014A00130000000000800016201502510016000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("0000800016202802560017000000000080001620310256001800000000008000162046025B001900AC31000000000618D90013001B000000000080001620530261001B0000000000800016206F0251001B000000000080001620800265001C0000000000800016208A026B001E003C2D000000009600C402730020004C2D000000000618D90013002000802D00000000C402C90277002000A82D0000000001000703130021000000000080001120530284002100000000008000162025038800210000000000800016206C03960025000000000080001620280251003000142E000000000100F203A6003100000001000101000001000101000002003F010000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("03004801000001003F01000002004801000001008C0100000200940100000300A10100000100BE0100000200C60100000300C80100000400CA0100000500D10100000600D90100000700E00100000800E50100000900EA0100000100110200000200CA0100000300D101000001001102000001001102000001003E02000001001102000002003E02000001007B02000001007B02000002001102000001007B0200000200980200000100D102002001002E03002002003B03002003004803000004005103000001007703000002007F03000003008C0300000400990300000500A40300000600B00300000700B70300000800C30300000900CF0300000A00D903",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000B00EA0100000100E40300000100FD030000020004045900A704FC003900D90013006100D90002013900B80408016900C90213003900C90277007100D9000E013900D20414013900E8041401390007051A0181002305200139002C05770081003E05200139005705250181008605130059008B053001A900A2053401B100DD0538019900E4053F019900F30545012900FE054A0129000406530129000E0653012100D9000E0191001906570191004F065E01C1007A06640129008606530129008C0653019100920669019100A00673019900A7063401A100D9001300D100CF0677019100D9067C019100C9021300A900E40681011900EB0687011100F406",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("2A003900F9061300D900D9001300E100D90013000900D900130011002F07BF012100D900D50111004707DB012100D900E0012900D900E80191006407F001F900D9000F020901D90016021101D90020011901D90020012101D90077002901D90020013101D90020013901D90020014101D90020014901D90020015101D900200108002400B10008002800B60008002C00BB0008003000C00008003400C50008003800CA0008003C00CF0008004000D40008004400D90008004800DE0008004C00E30008005000E80008005400ED0008005800F20008005C00F7002E00BB0153022E00E30153022E009B011C022E00AB0123022E00B3014D022E00C30153022E00",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("CB0153022E00D30153022E00DB01530260024B01B501C0025301B5014300940045009400470094002B018C01BA01C501BA01BA01FE0159025D0260026402680268026B026F026F0273023A003A006B026B026B026B023A005D025D025D023A0076023A0076027B027F027F026802680268023A0068027F023A003A0083027F027F0260026002600264026B026B028000F00164021E035C0343011100B701010043011300FA01010043011500150201004301170028020100430119003102010043011B004602010043011F0053020200430121006F0202004301230080020200430125008A02020043012F00530203004301310062030400430133006C030100",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("43013500280204000480000001000000C40DEA5D000000000000CC08000001000000881300000000000001000A00000000000700000088130000000000000A00130000000000010000008813000000000000010029000000000001000000881300000000000001003000000000000100000088130000000000000A003C000000000001000000881300000000000001004B000000000001000000881300000000000001006000000000000000000001000000AE070000030002000400020005000400070006000000003C4D6F64756C653E006D73636F726C6962004D6963726F736F66742E56697375616C42617369630053797374656D0053797374656D2E44",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("6174610053797374656D2E44726177696E670053797374656D2E57696E646F77732E466F726D730053797374656D2E586D6C0053637265656E43617074757265004465736B746F70436170747572652E53637265656E53686F7400474449333200557365723332005245435400466F726D31004465736B746F7043617074757265005465726E6172795261737465724F7065726174696F6E73004F626A656374002E63746F7200496D616765004361707475726553637265656E004361707475726557696E646F770068616E646C650053797374656D2E44726177696E672E496D6167696E6700496D616765466F726D6174004361707475726557696E646F77",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("546F46696C650066696C656E616D6500666F726D6174004361707475726553637265656E546F46696C65004269746D61700052656374616E676C6500436170747572654465736B546F7052656374616E676C65004361705265637400436170526563745769647468004361705265637448656967687400535243434F505900426974426C74006844657374444300780079006E5769647468006E4865696768740068537263444300785372630079537263006477526F700067646933322E646C6C00437265617465436F6D70617469626C654269746D61700068646300437265617465436F6D70617469626C6544430044656C65746544430044656C6574654F",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("626A65637400684F626A6563740053656C6563744F626A656374004765744465736B746F7057696E646F77007573657233322E646C6C0047657457696E646F7744430068776E640052656C6561736544430047657457696E646F7752656374006C70526563740056616C756554797065006C65667400746F7000726967687400626F74746F6D00466F726D004D61696E00446973706F736500646973706F73696E670053797374656D2E436F6D706F6E656E744D6F64656C0049436F6E7461696E657200636F6D706F6E656E747300496E697469616C697A65436F6D706F6E656E7400534300757365723332004372656174654443006C704472697665724E61",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("6D65006C704465766963654E616D65006C704F7574707574006C70496E697444617461006764693332004372656174654443410053747265746368426C740068646344657374006E584F726967696E44657374006E594F726967696E44657374006E576964746844657374006E4865696768744465737400686463537263006E584F726967696E537263006E594F726967696E537263006E5769647468537263006E48656967687453726300684443004576656E744172677300466F726D315F4C6F61640073656E646572006500456E756D0076616C75655F5F005352435041494E5400535243414E4400535243494E56455254005352434552415345004E4F",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("54535243434F5059004E4F545352434552415345004D45524745434F5059004D455247455041494E5400504154434F5059005041545041494E5400504154494E5645525400445354494E5645525400424C41434B4E4553530057484954454E455353004170706C69636174696F6E0052756E004576656E7448616E646C6572006164645F4C6F61640049446973706F7361626C650053697A65007365745F4175746F5363616C654261736553697A65007365745F436C69656E7453697A6500466F726D426F726465725374796C65007365745F466F726D426F726465725374796C6500436F6E74726F6C007365745F4E616D65007365745F53686F77496E5461",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("736B626172007365745F5465787400466F726D57696E646F775374617465007365745F57696E646F7753746174650047726170686963730053637265656E0057696E3332457863657074696F6E0048696465006765745F537461727475705061746800537472696E6700546F537472696E67004D6963726F736F66742E56697375616C42617369632E436F6D70696C6572536572766963657300537472696E675479706500537472436D70006765745F416C6C53637265656E73006765745F426F756E647300556E696F6E006765745F5769647468006765745F4865696768740046726F6D496D6167650053797374656D2E44726177696E672E44726177696E",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("67324400436F6D706F736974696E675175616C697479007365745F436F6D706F736974696E675175616C6974790053797374656D42727573686573004272757368006765745F4465736B746F70006765745F58006765745F590046696C6C52656374616E676C6500476574486463006765745F4465766963654E616D650053797374656D2E446961676E6F73746963730054726163650057726974654C696E650052656C6561736548646300436F6E636174006765745F4A706567005361766500436C6F736500535441546872656164417474726962757465004465627567676572537465705468726F7567684174747269627574650046726F6D486269746D",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("617000506978656C466F726D6174006765745F506978656C466F726D6174004772617068696373556E69740044726177496D6167650053797374656D2E52756E74696D652E496E7465726F705365727669636573005374727563744C61796F7574417474726962757465004C61796F75744B696E64004465736B746F70436170747572652E466F726D312E7265736F75726365730044656275676761626C654174747269627574650053797374656D2E5265666C656374696F6E00417373656D626C7956657273696F6E417474726962757465004775696441747472696275746500434C53436F6D706C69616E7441747472696275746500417373656D626C79",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("54726164656D61726B41747472696275746500417373656D626C79436F7079726967687441747472696275746500417373656D626C7950726F6475637441747472696275746500417373656D626C79436F6D70616E7941747472696275746500417373656D626C794465736372697074696F6E41747472696275746500417373656D626C795469746C65417474726962757465004465736B436170004465736B4361702E65786500000B46006F0072006D0031000001000763003A005C0000195C006400650073006B0074006F0070002E006A007000670000000000BD4B40C1253C4F4998AFB1E26A3AFF150008B77A5C561934E08908B03F5F7F11D50A3A03",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("200001042000120905200112091807200301180E120D062002010E120D0820031211111508080206080C000908180808080818080808060003181808080400011818040001081805000218181803000018050002081818070002081810111403000001042001010203061221030612080300000A0B000418100E100E100E100801220F000B0218080808081808080808111C062002011C12250306111C042000CC00048600EE0004C600880004460066000428034400040800330004A600110004CA00C000042602BB00042100F00004090AFB000449005A0004090055000442000000046200FF0005000101121D052002011C18052001011231052002010808",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("05200101113905200101113D042001010E05200101114504070111390300000E0320000E060003080E0E020500001D124D0420001115080002111511151115032000080600011249120905200101115D04000012650920050112650808080803200018040001011C04200101180500020E0E0E040000120D2807180E1211124918181115124D124D02080812511115111511151115080E0E0E081D124D081D124D040100000004070112090500011211180F070A120918181808181209080811140520010112090420001175072003010808117507200401080808080D2007011209111508080808117910070712111211121112491115111512080620010111",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("8081052002010202060100010100002901002439334439314132392D304633412D344444422D424344462D38393444323146463933443000000501000100000501000000000306113902060E0306121103061249020618030611150306124D02060204061D124D030612510306120903061114009C4600000000000000000000BE460000002000000000000000000000000000000000000000000000B04600000000000000000000000000000000000000005F436F724578654D61696E006D73636F7265652E646C6C0000000000FF25002000110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000A250944A00000000020000008A0000001C6000001C2C00005253445354484A494CD7F34A845830ACC2752C0401000000433A5C446F63756D656E747320616E642053657474696E67735C41646D696E6973747261746F725C4D7920446F63756D656E74735C56697375616C2053747564696F2050726F6A656374735C4465736B746F705F436170747572655C6F626A5C44656275675C4465736B4361702E70646200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("0000000000000000000000000000030003000000280000800E000000480000801000000060000080000000000000000000000000000002000200000078000080030000009000008000000000000000000000000000000100007F0000A80000800000000000000000000000000000010001000000C00000800000000000000000000000000000010000000000D80000000000000000000000000000000000010000000000E80000000000000000000000000000000000010000000000F800000000000000000000000000000000000100000000000801000020840000E80200000000000000000000088700002801000000000000000000003088000022000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("000000000000000018810000040300000000000000000000040334000000560053005F00560045005200530049004F004E005F0049004E0046004F0000000000BD04EFFE0000010000000100EA5DC40D00000100EA5DC40D3F000000000000000400000001000000000000000000000000000000440000000100560061007200460069006C00650049006E0066006F00000000002400040000005400720061006E0073006C006100740069006F006E00000000000000B00464020000010053007400720069006E006700460069006C00650049006E0066006F0000004002000001003000300030003000300034006200300000001C000200010043006F006D00",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("6D0065006E007400730000002000000024000200010043006F006D00700061006E0079004E0061006D00650000000000200000002C0002000100460069006C0065004400650073006300720069007000740069006F006E00000000002000000040000F000100460069006C006500560065007200730069006F006E000000000031002E0030002E0033003500320034002E00320034003000340032000000000038000C00010049006E007400650072006E0061006C004E0061006D00650000004400650073006B004300610070002E0065007800650000002800020001004C006500670061006C0043006F007000790072006900670068007400000020000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("2C00020001004C006500670061006C00540072006100640065006D00610072006B007300000000002000000040000C0001004F0072006900670069006E0061006C00460069006C0065006E0061006D00650000004400650073006B004300610070002E006500780065000000240002000100500072006F0064007500630074004E0061006D006500000000002000000044000F000100500072006F006400750063007400560065007200730069006F006E00000031002E0030002E0033003500320034002E00320034003000340032000000000048000F00010041007300730065006D0062006C0079002000560065007200730069006F006E00000031002E00",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("30002E0033003500320034002E00320034003000340032000000000000000000280000002000000040000000010004000000000080020000000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007777777777777777777777777777700444444444444444444444444444447004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFF",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("FFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFFFFFFFFFFFFFFF47004FFFFFFFFFFFFFF",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("FFFFFFFFFFFFF4700488888888888888888888888888847004444444444444444444444444444470044C4C4C4C4C4C4C4C4C4ECECE49747004CCCCCCCCCCCCCCCCCCCCCCCCCCC40000444444444444444444444444444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC00000018000000180000001800000018000000180000001800000018000000180000001800000018000000180000001800000018000000180000001800000018000000180000001800000018000000180000001800000018000000180000003C0000007FFFFFFFF",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("FFFFFFFFFFFFFFFF2800000010000000200000000100040000000000C0000000000000000000000000000000000000000000000000008000008000000080800080000000800080008080000080808000C0C0C0000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000077777777777777744444444444444474FFFFFFFFFFFF8474FFFFFFFFFFFF8474FFFFFFFFFFFF8474FFFFFFFFFFFF8474FFFFFFFFFFFF8474FFFFFFFFFFFF8474FFFFFFFFFFFF8474FFFFFFFFFFFF84748888888888888474CCCCCCCCCCCCC47C4444444444444C000000000000000000000000000000000FFFF0000800000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000000000000000000000000000000000000000000000000000000000000000000000010000FFFF0000FFFF00000000010002002020100001000400E802000002001010100001000400280100000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("004000000C000000D036000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",x,2))) : Next
	oFile.close
End Sub

Open in new window

Top Expert 2010

Author

Commented:
@jostrander:

Can you explain /  send project in .net ?
Top Expert 2010
Commented:
I'm using a class from here (ScreenCapture.vb):
http://www.developerfusion.com/code/4630/capture-a-screen-shot/
vb.net version:
http://www.vbforums.com/showthread.php?t=385497

And here's form1.vb

Form1.vb
Top Expert 2010

Commented:
I have it set up to get both monitors... adding monitor1 + monitor 2 into 1 bitmap... but on that forum, it sounds like there's a better way to do it (FindWindow instead of GetDesktopWindow).... I haven't tested that method on desktop capturing yet.

Here's the ScreenCapture.vb, in case it becomes unavailable someday:
ScreenCapture.vb
Top Expert 2010

Author

Commented:
Thank you :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial