Screen Snapshot


Screen Snapshot

Author
Message
DavidMcKnight2
View Quick Profile

Supreme Being
Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 7, Visits: 23
I want to be able to get a screen snapshots from a bunch of remote clients that have VNC server services running.  Is there a way to get, what is equivalent to, one frame from a VNC server and put it in something like a VB picture box with the ViewerX control? What I think would be really useful would be, given username, password, remote ip, remote port and a function like getsnapshot(), ViewerX would quickly login to remote system get a snapshot in a format that could easily be handed to a control like VB's picturebox, then logout of the remote system.
Yury Averkiev (s-code)
View Quick Profile

Supreme Being
Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)

Group: Administrators
Last Active: 3 days ago @ 6:45 PM
Posts: 1.9K, Visits: 3.5K
Hi David,
there are two ways to get a bitmap snapshot from ViewerX.

First of all take a look at the ScreenBitmap property. It returns HBITMAP of the current screen.

Here is how you can create bitmap in C#:
Bitmap bmp = Image.FromHbitmap(new IntPtr(viewerX.ScreenBitmap));

Or you can use the GetScreenBitmapScaled method. For some reason the method is not included in the CHM file, but this should be fixed in the next build.
[id(32),helpstring("Resizes the screen image to the specified width and height and returns HBITMAP handle of the scaled bitmap. You must release this handle using the GDI DeleteObject method.")]
HRESULT GetScreenBitmapScaled([in] long nWidth, [in] long nHeight, [out,retval] long *phBmp);


 

Please note that in the first case, you must not to destroy the HBITMAP returned by ScreenBitmap property. But in case of the second method you must destroy the HBITMAP returned by the method call.






http://www.s-code.com/App_Themes/Default/images/blue_line.gif
Kindest Regards,
SmartCode Solutions Support
Edited
6 Years Ago by Yury Averkiev (s-code)
DavidMcKnight2
View Quick Profile

Supreme Being
Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 7, Visits: 23
I want to try to use your Viewer to do something it's probable not designed to do but...

I want to try to get a screenshot from a powershell script.  To start with I need to try to get the Viewer COM object loaded, but I can't figure out how.  In powershell you load a COM object with a simple statement like

$excel = New-Object -ComObject Excel.Application

I can't figure a way to load it with the CLSID so does your Viewer ActiveX have some sort of handle I can reference?


Yury Averkiev (s-code)
View Quick Profile

Supreme Being
Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)

Group: Administrators
Last Active: 3 days ago @ 6:45 PM
Posts: 1.9K, Visits: 3.5K
Hi David,
I think the problem here, is that unlike Excel ActiveX that can be created as a window-less ActiveX control, ViewerX requires a parent window.

You can use the following CLSID to create a ViewerX instance:
62FA83F7-20EC-4D62-AC86-BAB705EE1CCD

DavidMcKnight2 (11/8/2011)
I want to try to use your Viewer to do something it's probable not designed to do but...

I want to try to get a screenshot from a powershell script.  To start with I need to try to get the Viewer COM object loaded, but I can't figure out how.  In powershell you load a COM object with a simple statement like

$excel = New-Object -ComObject Excel.Application

I can't figure a way to load it with the CLSID so does your Viewer ActiveX have some sort of handle I can reference?


http://www.s-code.com/App_Themes/Default/images/blue_line.gif
Kindest Regards,
SmartCode Solutions Support
DavidMcKnight2
View Quick Profile

Supreme Being
Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 7, Visits: 23
Yury Averkiev (s-code) (10/3/2011)
Hi David,
HRESULT GetScreenBitmapScaled([in] long nWidth, [in] long nHeight, [out,retval] long *phBmp);


When I try to work with this function in Visual Studio (VB.NET 2008)  it sees it as

GetScreenBitmapScaled( nWidth as Integer, nHeight as Integer) as Integer


There is no reference to a variable to hold the returning bitmap info.

Yury Averkiev (s-code)
View Quick Profile

Supreme Being
Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)

Group: Administrators
Last Active: 3 days ago @ 6:45 PM
Posts: 1.9K, Visits: 3.5K
You should create an IntPtr and feed to to a Bitmap constructor. The sample code was posted two posts above (it's in C# but VB code would be pretty much the same):
Bitmap bmp = Image.FromHbitmap(new IntPtr(viewerX.ScreenBitmap));

http://www.s-code.com/App_Themes/Default/images/blue_line.gif
Kindest Regards,
SmartCode Solutions Support
DavidMcKnight2
View Quick Profile

Supreme Being
Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)Supreme Being (873 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 7, Visits: 23
Thank you I've been able to get a bitmap from the control.

But, is there a way to tell when the ViewerX control has rendered a full screen from the remote server?

Again, I want to login, get a valid screen cap, and logout as quickly as possible.  If I put the code in one line after the other the screen cap I get is a blank screen with "Establishing connection to VNC server at..".  Just because the GetConnectionState equals VCS_CONNECTED doesn't necessarily mean that the remote screen has had time to render locally.  I can put in a Sleep function, but I was hoping for a more event driven/property setting solution.

Thanks again,

David
Yury Averkiev (s-code)
View Quick Profile

Supreme Being
Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)Supreme Being (193.8K reputation)

Group: Administrators
Last Active: 3 days ago @ 6:45 PM
Posts: 1.9K, Visits: 3.5K
But, is there a way to tell when the ViewerX control has rendered a full screen from the remote server?


There is no way. This is a limitation of the VNC protocol. Basicaly a VNC client receives series of screen updates. It doesn't know if the whole screen has been received or just part of it.

http://www.s-code.com/App_Themes/Default/images/blue_line.gif
Kindest Regards,
SmartCode Solutions Support


Similar Topics


Reading This Topic