Hi Guys ! VB.NET question -> I would like to make a program that allows me to see the preview of a window inside a form, so far i have managed to make a program to capture an area of fixed size, but there was one problem, the program crashed as soon as my pc run out of virtual memory. So my problem is simple i need to some how fetch hwnd ( handle ) of a window by name and preview ( not save ) on a form. So far i have added a Picture box and a timer that does an action of screen capture and showing that image, but as i said i had memory problems. Here is the code that i have so far .. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() end sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim graph As Graphics = Nothing Dim bmp As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height) graph = Graphics.FromImage(bmp) graph.CopyFromScreen(50, 59, 59, 59, bmp.Size) PictureBox1.BackgroundImage = bmp End Sub Code (markup): and here it is how it looks like
Hi ! I have now tried a different approach with Sendkeys.send() but the memory problem is still here and the app crashes after a while. Something is telling me that the picturebox is the problem. Here is what i have now Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick AppActivate("Untitled - Notepad") SendKeys.Send("%{PRTSC}") ' this is just like alt+printscr PictureBox1.Image = CType(Clipboard.GetDataObject.GetData("Bitmap"), Image) End Sub Code (markup):