Hey all,

I am writing a simple program that's supposed to open a file, maximize the file, take a screenshot, and save the picture to the desktop. It's opening and maximizing the file but when the console takes over to take the screenshot, it minimizes the file, so my screenshot is of the console window and the desktop, instead of the file. How do I get the console to execute commands without minimizing the file in question? Any help would be sincerely appreciated. Here's my code(sorry it didn't paste exacly as it should):

Public bm As Bitmap = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Drawing.Imaging.PixelFormat.Format32bppArgb)
Dim gr As Graphics


<Flags()> Private Enum SHOW_WINDOW As Integer
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_NORMAL = 1
SW_SHOWMINIMIZED = 2
SW_SHOWMAXIMIZED = 3
SW_MAXIMIZE = 3
SW_SHOWNOACTIVATE = 4
SW_SHOW = 5
SW_MINIMIZE = 6
SW_SHOWMINNOACTIVE = 7
SW_SHOWNA = 8
SW_RESTORE = 9
SW_SHOWDEFAULT = 10
SW_FORCEMINIMIZE = 11
SW_MAX = 11
End Enum
Sub Main()

'open file and maximize
Process.Start("excel", FileName1)
For Each p As Process In Process.GetProcessesByName("excel")
ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MAXIMIZE)
Next p
'screenshot
bm = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, _ Drawing.Imaging.PixelFormat.Format32bppArgb)
gr = Graphics.FromImage(bm)
gr.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, New Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height))
Application.DoEvents()
'new file
bm.Save("H:\Profile_DoNotDelete\Desktop\tstimg45.jpg", ImageFormat.Jpeg)

End Sub
End Module