Every second my program takes a snapshot of the screen,
but there is no mouse on the screen?
Obviously it is hidden, but can it be visible too? I would like to show the mouse.
Code:
(At the very top of my Form1 Class)
And the actual function:Code:#Region "Init" 'tell the bitBlt function to do a exact copy from the source to dest. Private Const SRCCOPY As Integer = &HCC0020 'blit the image from one device context to another device context Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (ByVal hDestDC As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As Integer 'get the windows device context Private Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As IntPtr) As Integer 'release the device context back to windows Private Declare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As IntPtr, ByVal hdc As Integer) As Integer 'get the windows handle from the cursor position Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Integer, ByVal yPoint As Integer) As IntPtr 'whether the timer is paused or active 0 = active, 1 = paused Private doPause As Integer = 0 'create a image buffer for the screenshot Dim bitBuffer As Bitmap = New Bitmap(1024, 768) 'the windows handle to get the screenshot from Private hwnd As IntPtr 'will hold the user defined filename to save the screenshot Dim imageFilename As String #End Region
The question is, how come I can not see the mouse in the images?Code:Public Function Snapshot() As Object Dim dt As DateTime Dim fileName As String = "ScreenShot.jpeg" Do Application.DoEvents() Loop Until Date.Now = Now ''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''' 'create a reference to the buffered image Dim gfx As Graphics = Graphics.FromImage(bitBuffer) 'the windows device context Dim dc As Integer, dc2 As IntPtr dc = GetDC(Nothing) dc2 = gfx.GetHdc BitBlt(dc2.ToInt32, 0, 0, 1024, 768, dc, 0, 0, SRCCOPY) ReleaseDC(hwnd, dc) gfx.ReleaseHdc(dc2) t.Enabled = False bitBuffer.Save(fileName) Return Nothing End Function
Thanks


Reply With Quote