hallo griever,
solche posts kommen glaube ich nicht sehr gut an !
du bist hier bei den fortgeschrittenen !
mein tummelplatz ist eher der für die ein- bzw. umsteiger (und deiner ?!?).
egal, ich konnte nicht schlafen, hab mir ein bier aufgemacht und versucht, ein screenshot tool zu entwerfen, dass deinen vorgaben hoffentlich nahe kommt.
kleine anmerkung:
du willst die eingabe des intervalls in millisekunden, das gibt der code nicht her, ich würde hierfür nicht unter 1sek. gehen (1000ms) immerhin braucht der rechner auch etwas zeit zum speichern.
hier der code
Imports System
Imports System.IO
Public Class Form1
Private WithEvents start As New Button
Private WithEvents enableedittime As New Button
Private WithEvents choosepath As New Button
Private WithEvents edittime As New TextBox
Private WithEvents shoot As New Timer
Private folderpath As New FolderBrowserDialog
Private savepath As String = Nothing
Private count As Integer = My.Settings.fileCount
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As _
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
My.Settings.fileCount = count
My.Settings.Save()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
start.Location = New Point(50, 50)
enableedittime.Location = New Point(50, 100)
choosepath.Location = New Point(50, 150)
edittime.Location = New Point(150, 100)
start.Text = "start"
enableedittime.Text = "time"
choosepath.Text = "path"
edittime.Enabled = False
start.Enabled = False
start.Parent = Me
enableedittime.Parent = Me
choosepath.Parent = Me
edittime.Parent = Me
End Sub
Private Sub start_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles start.Click
If start.Text = "start" Then
start.Text = "stop"
Try
shoot.Interval = CInt(edittime.Text)
Catch ex As Exception
shoot.Interval = 1000
End Try
shoot.Start()
enableedittime.Enabled = False
edittime.Enabled = False
Else
start.Text = "start"
shoot.Stop()
enableedittime.Enabled = True
End If
End Sub
Private Sub enableedittime_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles enableedittime.Click
edittime.Enabled = True
End Sub
Private Sub choosepath_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles choosepath.Click
If folderpath.ShowDialog = Windows.Forms.DialogResult.OK Then
savepath = folderpath.SelectedPath
If Directory.Exists(savepath) = False Then
Directory.CreateDirectory(savepath)
End If
Else
savepath = "C:\"
End If
start.Enabled = True
End Sub
Private Sub shoot_Tick(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles shoot.Tick
Dim s As New Size(Screen.PrimaryScreen.Bounds.Size)
Dim b As New Bitmap(s.Width, s.Height)
Dim g As Graphics = Nothing
'b = New Bitmap(Width, Height)
g = Graphics.FromImage(b)
g.CopyFromScreen(0, 0, 0, 0, b.Size)
Dim file2save = Path.Combine(savepath, "Screenshot_" & count.tostring & _
".jpg")
b.Save(file2save, Imaging.ImageFormat.Jpeg)
g.Dispose()
b.Dispose()
g = Nothing
b = Nothing
count += 1
End Sub
End Class schlaf gut
mikeb69 |