Вам нужно изменить строку:
PictureBox1.Image.Save(dtmTestX, System.Drawing.Imaging.ImageFormat.Jpeg)
до:
PictureBox1.Image.Save(dtmTestSaveLocation, System.Drawing.Imaging.ImageFormat.Jpeg)
Вы также должны встраивать свои графические элементы в теги, чтобы обеспечить их правильное расположение:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
Dim dtmTest As Date
Dim bounds As Rectangle
Dim dtmTestSaveLocation As String
dtmTest = TimeValue(Now)
dtmTestSaveLocation = "D:\test" & dtmTest.ToShortTimeString.Replace(":", "_") & ".jpg"
bounds = Screen.PrimaryScreen.Bounds
Using screenshot As New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
Using graph As Graphics = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
screenshot.Save()
PictureBox1.Image.Save(dtmTestSaveLocation, System.Drawing.Imaging.ImageFormat.Jpeg)
End Using
End Using
Catch theException As Exception
Console.WriteLine(theException.ToString)
' Note: In production code, you would want to do something useful with the exception
' here, such as showing it to the user in a messagebox or writing it to a log
End Try
End Sub