Public Class Form1 Dim sPathUser As String Public Shared Function CapturerBureauWindows() As Bitmap Dim tailleTotale As Rectangle ' Taille totale du bureau de Windows Dim image As Bitmap ' Capture de l'écran ' Récupérer la taille totale du bureau de Windows tailleTotale = Screen.AllScreens(0).Bounds For i As Integer = 1 To Screen.AllScreens.Length - 1 tailleTotale = Rectangle.Union(tailleTotale, Screen.AllScreens(i).Bounds) Next ' Créer une image de la taille du bureau de Windows image = New Bitmap(tailleTotale.Width, tailleTotale.Height) ' Créer un Graphics à partir de l'image et faire la capture dans celui-ci Using g As Graphics = Graphics.FromImage(image) g.CopyFromScreen(tailleTotale.Location, Point.Empty, tailleTotale.Size) End Using Return image End Function Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork sPathUser = Environ$("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen\Images" BackgroundWorker1.WorkerSupportsCancellation = True Dim capture As Bitmap capture = CapturerBureauWindows() Dim captur As Object captur = Label2.Text capture.Save(dossierlocal & captur & ".jpg") End Sub Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged If (ComboBox1.Text.Trim() = "") Then MsgBox("Indiquez le nombre d'images par seconde") If CheckBox1.Checked = True Then CheckBox2.BackColor = Color.Red Label2.Text = "0" End If ElseIf CheckBox2.Checked = True Then CheckBox2.BackColor = Color.Lime ComboBox1.Enabled = False CheckBox2.Text = "Stopper la capture" Timer1.Interval = 1000 / ComboBox1.Text Timer1.Start() Timer2.Interval = 1000 / ComboBox1.Text Timer2.Start() ElseIf CheckBox2.Checked = False Then CheckBox2.BackColor = Color.Red BackgroundWorker1.CancelAsync() ComboBox1.Enabled = True CheckBox2.Text = "Démarrer la capture" Timer1.Enabled = False Timer1.Stop() Timer2.Enabled = False Timer2.Stop() Label2.Text = "0" End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick BackgroundWorker1.RunWorkerAsync() End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Label2.Text += 1 End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing sPathUser = Environ$("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen" If My.Computer.FileSystem.DirectoryExists(dossierlocal) = True Then My.Computer.FileSystem.DeleteDirectory(dossierlocal, FileIO.DeleteDirectoryOption.DeleteAllContents) Else MsgBox("Le dossier à déjà était supprimé.") End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load sPathUser = Environ$("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen\Images" If System.IO.Directory.Exists(dossierlocal) = False Then Try System.IO.Directory.CreateDirectory(dossierlocal) Catch ex As Exception MsgBox(ex.Message) End Try End If End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = True Then If CheckBox2.Checked = True Then CheckBox1.Text = "Reprendre" CheckBox1.BackColor = Color.Lime Timer1.Enabled = False Timer1.Stop() Timer2.Enabled = False Timer2.Stop() Else MsgBox("Vous n'avez pas démarré la capture") End If ElseIf CheckBox1.Checked = False Then If CheckBox2.Checked = True Then CheckBox1.BackColor = Color.Red CheckBox1.Text = "Pause" Timer1.Interval = 1000 / ComboBox1.Text Timer1.Start() Timer2.Interval = 1000 / ComboBox1.Text Timer2.Start() Else MsgBox("Vous n'avez pas démarré la capture") End If End If End Sub End Class
CapturerBureauWindows().Save(IO.path.combine(dossierlocal , captur & ".jpg")
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim captur As Object captur = Label2.Text
Dim captur As String captur = Label2.Text
Label2.Text += 1
Label2.Text = CStr(CSng(Label2.Text) + CSng(1))
Public Class Form1 Dim sPathUser As String Public Shared Function CapturerBureauWindows() As Bitmap Dim tailleTotale As Rectangle ' Taille totale du bureau de Windows Dim image As Bitmap ' Capture de l'écran ' Récupérer la taille totale du bureau de Windows tailleTotale = Screen.AllScreens(0).Bounds For i As Integer = 1 To Screen.AllScreens.Length - 1 tailleTotale = Rectangle.Union(tailleTotale, Screen.AllScreens(i).Bounds) Next ' Créer une image de la taille du bureau de Windows image = New Bitmap(tailleTotale.Width, tailleTotale.Height) ' Créer un Graphics à partir de l'image et faire la capture dans celui-ci Using g As Graphics = Graphics.FromImage(image) g.CopyFromScreen(tailleTotale.Location, Point.Empty, tailleTotale.Size) End Using Return image End Function Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBplaystop.CheckedChanged If (ComboBox1.Text.Trim() = "") Then MsgBox("Indiquez le nombre d'images par seconde") If CBpausereprendre.Checked = True Then CBplaystop.BackColor = Color.Lime Label2.Text = "0" End If ElseIf CBplaystop.Checked = True Then CBplaystop.BackColor = Color.Red ComboBox1.Enabled = False CBpausereprendre.Enabled = True CBplaystop.Text = "Stopper la capture" Timer1.Interval = CInt(CStr(CSng(1000) / CSng(ComboBox1.Text))) Timer1.Start() Timer2.Interval = CInt(CStr(CSng(1000) / CSng(ComboBox1.Text))) Timer2.Start() ElseIf CBplaystop.Checked = False Then CBplaystop.BackColor = Color.Red ComboBox1.Enabled = True CBpausereprendre.BackColor = Color.Lime CBpausereprendre.Enabled = False CBpausereprendre.Text = "Pause" CBplaystop.Text = "Démarrer la capture" Timer1.Enabled = False Timer1.Stop() Timer2.Enabled = False Timer2.Stop() Label2.Text = "0" End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick sPathUser = Environ$("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen\Images" Dim captur As String captur = Label2.Text CapturerBureauWindows().Save(IO.Path.Combine(dossierlocal, captur & ".jpg")) End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Label2.Text = CStr(CSng(Label2.Text) + CSng(1)) End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing sPathUser = Environ$("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen" If My.Computer.FileSystem.DirectoryExists(dossierlocal) = True Then My.Computer.FileSystem.DeleteDirectory(dossierlocal, FileIO.DeleteDirectoryOption.DeleteAllContents) Else MsgBox("Le dossier à déjà était supprimé.") End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CBpausereprendre.Enabled = False sPathUser = Environ$("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen\Images" If System.IO.Directory.Exists(dossierlocal) = False Then Try System.IO.Directory.CreateDirectory(dossierlocal) Catch ex As Exception MsgBox(ex.Message) End Try End If End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBpausereprendre.CheckedChanged If CBpausereprendre.Checked = True Then If CBplaystop.Checked = True Then CBpausereprendre.Text = "Reprendre" CBpausereprendre.BackColor = Color.Red Timer1.Enabled = False Timer1.Stop() Timer2.Enabled = False Timer2.Stop() Else MsgBox("Vous n'avez pas démarré la capture") End If ElseIf CBpausereprendre.Checked = False Then If CBplaystop.Checked = True Then CBpausereprendre.BackColor = Color.Lime CBpausereprendre.Text = "Pause" Timer1.Interval = CInt(CStr(CSng(1000) / CSng(ComboBox1.Text))) Timer1.Start() Timer2.Interval = CInt(CStr(CSng(1000) / CSng(ComboBox1.Text))) Timer2.Start() Else MsgBox("Vous n'avez pas démarré la capture") End If End If End Sub Private Sub ApperçuDuFilmToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ApperçuDuFilmToolStripMenuItem.Click Apperçu.Show() End Sub End Class
sPathUser = Environ$("USERPROFILE")
FileIO.DeleteDirectoryOption.DeleteAllContents)
sPathUser = Environment.GetEnvironmentVariable("USERSPROFILE")
Delete(dossierlocal)
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed sPathUser = Environment.GetEnvironmentVariable("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen" If My.Computer.FileSystem.DirectoryExists(dossierlocal) = True Then Delete(dossierlocal) Else MessageBox.Show("Le dossier à déjà était supprimé.") End If End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing sPathUser = Environment.GetEnvironmentVariable("USERPROFILE") Dim dossierlocal = sPathUser & "\AppData\Roaming\RecordScreen" If My.Computer.FileSystem.DirectoryExists(dossierlocal) Then Try System.IO.Directory.Delete(dossierlocal) Catch ex As Exception MessageBox.Show(ex.Message) End Try End If End Sub
My.Computer.FileSystem.DeleteDirectory(dossierlocal, Microsoft.VisualBasic.FileIO.DeleteDirectoryOption.DeleteAllContents)