473,770 Members | 6,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cathing the Mouse in a Screen Capture in Vb.Net

http://www.geocities.com/krishnapg/screencap.html

This article gives a pretty good background on various ways to capture the
screen. I have some code to do it the GDI way below, but I cant figure out
how to get the Mouse in there. I am frustrated and looking at Direct X. I
am may have to try the Windows Media API , but know nothing about it.

Anyone have a way to get the mouse in my screen capture, any examples would
be great (GDI, DirectX, or Windows Media API)?

Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal
lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As
String, ByVal lpInitData As String) As Integer

Private Declare Function CreateCompatibl eDC Lib "GDI32" (ByVal hDC As
Integer) As Integer

Private Declare Function CreateCompatibl eBitmap Lib "GDI32" (ByVal hDC As
Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer

Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceC aps"
(ByVal hdc As Integer, ByVal nIndex As Integer) As Integer

Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer,
ByVal hObject As Integer) As Integer

Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal
srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As
Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As
Integer, ByVal op As Integer) As Integer

Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As
Integer

Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As
Integer

Const SRCCOPY As Integer = &HCC0020

Private oBackground As System.Drawing. Bitmap

Private FW, FH As Integer

Public Sub CaptureScreen()

Dim hSDC, hMDC As Integer

Dim hBMP, hBMPOld As Integer

Dim r As Integer

hSDC = CreateDC("DISPL AY", "", "", "")

hMDC = CreateCompatibl eDC(hSDC)

FW = GetDeviceCaps(h SDC, 8)

FH = GetDeviceCaps(h SDC, 10)

hBMP = CreateCompatibl eBitmap(hSDC, FW, FH)

hBMPOld = SelectObject(hM DC, hBMP)

r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)

hBMP = SelectObject(hM DC, hBMPOld)

r = DeleteDC(hSDC)

r = DeleteDC(hMDC)

oBackground = System.Drawing. Image.FromHbitm ap(New IntPtr(hBMP))

DeleteObject(hB MP)

DeleteObject(hB MPOld)
Nov 20 '05 #1
4 6382
Sorry. "Catching" The mouse.... Thats what I am after.
"gregory_ma y" <None> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
http://www.geocities.com/krishnapg/screencap.html

This article gives a pretty good background on various ways to capture the
screen. I have some code to do it the GDI way below, but I cant figure out how to get the Mouse in there. I am frustrated and looking at Direct X. I am may have to try the Windows Media API , but know nothing about it.

Anyone have a way to get the mouse in my screen capture, any examples would be great (GDI, DirectX, or Windows Media API)?

Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal
lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As
String, ByVal lpInitData As String) As Integer

Private Declare Function CreateCompatibl eDC Lib "GDI32" (ByVal hDC As
Integer) As Integer

Private Declare Function CreateCompatibl eBitmap Lib "GDI32" (ByVal hDC As
Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer

Private Declare Function GetDeviceCaps Lib "gdi32" Alias "GetDeviceC aps"
(ByVal hdc As Integer, ByVal nIndex As Integer) As Integer

Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer,
ByVal hObject As Integer) As Integer

Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As
Integer, ByVal op As Integer) As Integer

Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As
Integer

Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer

Const SRCCOPY As Integer = &HCC0020

Private oBackground As System.Drawing. Bitmap

Private FW, FH As Integer

Public Sub CaptureScreen()

Dim hSDC, hMDC As Integer

Dim hBMP, hBMPOld As Integer

Dim r As Integer

hSDC = CreateDC("DISPL AY", "", "", "")

hMDC = CreateCompatibl eDC(hSDC)

FW = GetDeviceCaps(h SDC, 8)

FH = GetDeviceCaps(h SDC, 10)

hBMP = CreateCompatibl eBitmap(hSDC, FW, FH)

hBMPOld = SelectObject(hM DC, hBMP)

r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)

hBMP = SelectObject(hM DC, hBMPOld)

r = DeleteDC(hSDC)

r = DeleteDC(hMDC)

oBackground = System.Drawing. Image.FromHbitm ap(New IntPtr(hBMP))

DeleteObject(hB MP)

DeleteObject(hB MPOld)

Nov 20 '05 #2
Bob
You may want to try sending the Alt-PrntScrn keystroke and copy from the
clipboard. I used to know how to do this in VB6 and I believe it can be done in
..Net as well.

Bob

Nov 20 '05 #3
Thanks!.

I dont think this catches the mouse though.

g.

"Bob" <no*****@nospam .net> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
You may want to try sending the Alt-PrntScrn keystroke and copy from the
clipboard. I used to know how to do this in VB6 and I believe it can be done in .Net as well.

Bob

Nov 20 '05 #4
This has been answered already over on microsoft.publi c.platformsdk.g di:
http://groups.google.co.uk/groups?se...TNGP10.phx.gbl

Thanks Mike!
"gregory_ma y" <None> wrote in message
news:uR******** *****@tk2msftng p13.phx.gbl...
Thanks!.

I dont think this catches the mouse though.

g.

"Bob" <no*****@nospam .net> wrote in message
news:uX******** ******@TK2MSFTN GP12.phx.gbl...
You may want to try sending the Alt-PrntScrn keystroke and copy from the
clipboard. I used to know how to do this in VB6 and I believe it can be

done in
.Net as well.

Bob


Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
13531
by: Me Mine | last post by:
i, I have trying to code a small console app that will allow a user to select a window and then create a screen capture of the window. I haven't been able to figure out how to do the screen capture part. The code is as follows, the commented out lines at the end are things I have tried, but don't work. Whenever I try to create a compatibe Bitmap or DC it comes back with an error as win32ui: CreateCompatibleDC failed
5
2383
by: TerryWilson | last post by:
I am developing a web based service tool using asp.net that we will distribute with our product. This service tool will be used for remotely configuring the product, problem determination, etc. One thing that I would like to be able to do is display a screen capture of our product running. I have the code to get the screen capture of the desktop and I also know how to send the image back to the client to be displayed. The problem is that...
0
907
by: D Sheldon | last post by:
Has anyone ever created a screen capture method for ASP.Net? What I have in mind is adding a method to my custom error logging class that will take a screen capture of the user's browser and then stores it locally. This way, I can actually see what the user see's when they encounter a problem. Is this possible?
2
2220
by: Eddie Dunn | last post by:
I have one here that I cannot find anything on in my searching. I am implementing a screen capture functionality into my Visual Basic ..NET application. The code I am using calls the bitblt function in gdi32.dll to achieve its magic as follows: Public Function CreateScreenshot() As Bitmap
2
2415
by: py | last post by:
I need to take a screen shot of the computer screen. I am trying to use PIL and I saw there is ImageGrab...however it only works on Windows. Is there a platform-independent ability to work around this? thanks
2
6624
by: dumbledad | last post by:
Hi All, I'm using ASP.Net web services to provide the logic required for a Flash based prototype. The Flash and the ASP .Net run together on the client machine. One of the functions I'd like to offer is public void StoreLogEntry(string tag, string description, bool screenshotRequired)
1
4508
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get an image of that web site so that it can be displayed later as a thumbnail image. I have code for taking a normal screen capture using GDI+ which works fine. What I am now trying to do is to modify it so the screen capture is of a remote...
0
1255
by: Jim McGivney | last post by:
I have goggled "Asp.net Screen Capture" and looked at many articles, but have never succeeded in a screen capture. Has anyone been able to accomplish Screen Capture in 2005 VWD C# ? Let me know of the article or sample code. Thanks, Jim
2
2818
by: raylopez99 | last post by:
Beware newbies: I spent a day before I figured this out: copying a bitmap (image) file to file is not quite like copying a text file--you have to do some tricks (see below), like using a "Graphics" object to wrap around the image (!). It's not so simple as shown in most examples (where they have a simple image file and hard copy it into a harddrive along the lines of : image.Save(@"C:\\temp\\myimage.pgn"); That will work, but it's a...
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10225
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9867
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.