كود أستخدام لألتقاط صورة من الشاشة

القيصر

New member
26 فبراير 2019
1,003
0
0
كود أستخدام لألتقاط صورة من الشاشة


الأدوات: button عدد 3 +CheckBox1+PictureBox1

كود
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim b As Bitmap = New Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
Dim g As Graphics = Graphics.FromImage(b)
Dim s As Size = New Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height)
If CheckBox1.Checked Then
Me.Hide()
Dim t As DateTime = Now.AddSeconds(1)
Do : Application.DoEvents()
Loop Until Now.Second >= t.Second
g.CopyFromScreen(0, 0, 0, 0, s, CopyPixelOperation.SourceCopy)
Me.Show()
t = Nothing
Else
g.CopyFromScreen(0, 0, 0, 0, s, CopyPixelOperation.SourceCopy)
End If
PictureBox1.Image = b
g.Dispose()
b = Nothing
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim saveDlg As SaveFileDialog = New SaveFileDialog
Dim dlgResult As DialogResult = New DialogResult
saveDlg.Filter = "JPEG Files (*.jpg)|*.jpg"
saveDlg.Title = "Select the file to save the image too."
dlgResult = saveDlg.ShowDialog
If dlgResult = Windows.Forms.DialogResult.OK Then
PictureBox1.Image.Save(saveDlg.FileName)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "ألتقاط"
Button1.Text = "حفظ الصورة"
Button3.Text = "إنهاء"
CheckBox1.Text = "إخفاء"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub
End Class