Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim proc As Process = New Process proc.StartInfo.FileName = "c:\koko.ext" proc.StartInfo.CreateNoWindow = False proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized proc.Start() 'tempo sinon le process name n'existe pas encore MsgBox(proc.ProcessName) Dim f1 As Form = Form.FromHandle(proc.Handle) ' sa il n'aime pas Dim r1 As Rectangle = f1.Bounds 'Dim r1 As Rectangle = f1.RectangleToScreen(f1.ClientRectangle) Dim bmp As Bitmap = New Bitmap(r1.Width, r1.Height, PixelFormat.Format32bppArgb) Using g As Graphics = Graphics.FromImage(bmp) g.CopyFromScreen(r1.Left, r1.Top, 0, 0, r1.Size, CopyPixelOperation.SourceCopy) End Using bmp.Save("D:\resutestimg.bmp")
Public Shared Function CaptureFile(ByVal fileToLaunch As String, ByVal outputImage As String) As Boolean ' si cette erreur de type : System.Runtime.InteropServices ExternalException voir ' http://support.microsoft.com/?id=814675 Try 'lancement du process Dim proc As Process = New Process proc.StartInfo.FileName = fileToLaunch proc.StartInfo.CreateNoWindow = False proc.StartInfo.WindowStyle = ProcessWindowStyle.Maximized proc.Start() proc.WaitForInputIdle() 'on attend que la fenetre soi bien lancé 'on fait un imprim ecran et on prie pour que rien d'autre s'affiche Dim r1 As System.Drawing.Rectangle = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(r1.Width, r1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb) Using g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmp) g.CopyFromScreen(r1.Left, r1.Top, 0, 0, r1.Size, System.Drawing.CopyPixelOperation.SourceCopy) g.Dispose() End Using Lib.Business.Resize(bmp, 800, 600).Save(outputImage) 'bmp.Save(outputImage) bmp.Dispose() proc.CloseMainWindow() proc.Close() GC.Collect() ' la lib gdi++ a un peu de mal a tout liberer Return True Catch ex As Exception Throw ex End Try End Function