Avatar billede doctorpurple Nybegynder
18. december 2001 - 13:26 Der er 17 kommentarer og
1 løsning

print screen

hej jeg vil lige høre hvordan man får en timer til at lægge et screenshot i udclipsholderen hvert minut
Avatar billede bennytordrup Nybegynder
18. december 2001 - 13:28 #1
I Timer1_Timer:

frmEtEllerAndet.PrintForm

Timer1.Enabled = True
Timer1.Interval = 60000
Avatar billede bennytordrup Nybegynder
18. december 2001 - 13:28 #2
Timer1 værdierne skal selvfølgelig sættes designtime eller i form_load
Avatar billede doctorpurple Nybegynder
18. december 2001 - 13:43 #3
det du har skrevet benny tager da kun billede af formen gør det ikke det skal tage af hvad der er på skærmen
Avatar billede bennytordrup Nybegynder
18. december 2001 - 13:50 #4
Hvad så med (i et modul):

Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const WM_CHAR = &H102
Private Declare Function PostMessage Lib \"user32\" Alias \"PostMessageA\" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Sub PostKeys(ByVal S As String, Optional ByVal wnd As Long = 0, Optional Now As Boolean = False)
Dim i As Integer
Dim KeyCode As Long
On Error Resume Next
    If wnd = 0 Then
        wnd = frmStartUp.ActiveForm.ActiveControl.hWnd
        If wnd = 0 Then wnd = Screen.ActiveForm.ActiveControl.hWnd
        If wnd = 0 Then Exit Sub
    End If
    For i = 1 To Len(S)
        KeyCode = ASC(Mid(S, i, 1))
        If Now Then
            If (KeyCode >= 32) Or (KeyCode = vbKeyEscape) Then SendMessage wnd, WM_CHAR, KeyCode, 0&
            If (KeyCode = vbKeyTab) Then
                SendMessage wnd, WM_KEYDOWN, KeyCode, 0&
                SendMessage wnd, WM_KEYUP, KeyCode, 0&
            End If
        Else
            If (KeyCode >= 32) Or (KeyCode = vbKeyEscape) Then PostMessage wnd, WM_CHAR, KeyCode, 0&
            If (KeyCode = vbKeyTab) Then
                PostMessage wnd, WM_KEYDOWN, KeyCode, 0&
                PostMessage wnd, WM_KEYUP, KeyCode, 0&
            End If
        End If
    Next i
End Sub



og så kalde denne i Timer1_Timer:

PostKeys Chr(vbKeyPrint)
Avatar billede bennytordrup Nybegynder
18. december 2001 - 13:51 #5
Det vil simulere et tryk på Print Screen
Avatar billede doctorpurple Nybegynder
18. december 2001 - 14:17 #6
jeg synes ikke rigtig jeg kan få modulet til at virke det laver fejl med sendmassage
Avatar billede bennytordrup Nybegynder
18. december 2001 - 14:19 #7
Set den her ind umiddelbart under Private Declare Function PostMessage:

Private Declare Function SendMessage Lib \"user32\" Alias \"SendMessageA\" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Avatar billede doctorpurple Nybegynder
18. december 2001 - 14:26 #8
det virker stadig ikke sådan ser min form ud((( Private Sub Timer1_Timer()
PostKeys Chr(vbKeyPrint)
Picture1.Picture = Clipboard.GetData
End Sub)))
Avatar billede bennytordrup Nybegynder
18. december 2001 - 14:28 #9
Hvis jeg nu havde læst spørgsmålet ordentligt :-( Har du en printer på maskinen? Har du fået et skærmdump ud? Det burde du ifølge min teori. Men efter at have nærlæst spørgsmålet, så er det jo ikke dit problem...
Avatar billede doctorpurple Nybegynder
18. december 2001 - 14:30 #10
jeg har brug for at picture1 for et screendump hvert minut som jeg så kan gemme men alt det kan jeg finde ud af det er bare det med at tage screendumpet
Avatar billede sjh Nybegynder
18. december 2001 - 14:49 #11
husk en Timer på Form1. :-)

\'----------------------------------------- Form1 -----------------------------------------
Const RC_PALETTE As Long = &H100
Const SIZEPALETTE As Long = 104
Const RASTERCAPS As Long = 38

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Type PALETTEENTRY
    peRed As Byte
    peGreen As Byte
    peBlue As Byte
    peFlags As Byte
End Type

Private Type LOGPALETTE
    palVersion As Integer
    palNumEntries As Integer
    palPalEntry(255) As PALETTEENTRY
End Type

Private Type GUID
    Data1 As Long
    Data2 As Integer
    Data3 As Integer
    Data4(7) As Byte
End Type

Private Type PicBmp
    Size As Long
    Type As Long
    hBmp As Long
    hPal As Long
    Reserved As Long
End Type

Private Declare Function OleCreatePictureIndirect Lib \"olepro32.dll\" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Declare Function CreateCompatibleDC Lib \"gdi32\" (ByVal hdc As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib \"gdi32\" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function SelectObject Lib \"gdi32\" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function GetDeviceCaps Lib \"gdi32\" (ByVal hdc As Long, ByVal iCapabilitiy As Long) As Long
Private Declare Function GetSystemPaletteEntries Lib \"gdi32\" (ByVal hdc As Long, ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) As Long
Private Declare Function CreatePalette Lib \"gdi32\" (lpLogPalette As LOGPALETTE) As Long
Private Declare Function SelectPalette Lib \"gdi32\" (ByVal hdc As Long, ByVal hPalette As Long, ByVal bForceBackground As Long) As Long
Private Declare Function RealizePalette Lib \"gdi32\" (ByVal hdc As Long) As Long
Private Declare Function BitBlt Lib \"gdi32\" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function DeleteDC Lib \"gdi32\" (ByVal hdc As Long) As Long
Private Declare Function GetDC Lib \"user32\" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowRect Lib \"user32\" (ByVal hwnd As Long, lpRect As RECT) As Long

Private Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture
Dim R As Long, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID
  With IID_IDispatch
    .Data1 = &H20400
    .Data4(0) = &HC0
    .Data4(7) = &H46
  End With
  With Pic
    .Size = Len(Pic)
    .Type = vbPicTypeBitmap
    .hBmp = hBmp
    .hPal = hPal
  End With
  R = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)
Set CreateBitmapPicture = IPic
End Function

Private Function hDCToPicture(ByVal hDCSrc As Long, ByVal LeftSrc As Long, ByVal TopSrc As Long, ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture
Dim hDCMemory As Long, hBmp As Long, hBmpPrev As Long, R As Long
Dim hPal As Long, hPalPrev As Long, RasterCapsScrn As Long, HasPaletteScrn As Long
Dim PaletteSizeScrn As Long, LogPal As LOGPALETTE

hDCMemory = CreateCompatibleDC(hDCSrc)
hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
hBmpPrev = SelectObject(hDCMemory, hBmp)

RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS)
HasPaletteScrn = RasterCapsScrn And RC_PALETTE
PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE)

  If HasPaletteScrn And (PaletteSizeScrn = 256) Then
    LogPal.palVersion = &H300
    LogPal.palNumEntries = 256
    R = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0))
    hPal = CreatePalette(LogPal)
    hPalPrev = SelectPalette(hDCMemory, hPal, 0)
    R = RealizePalette(hDCMemory)
  End If
R = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)
hBmp = SelectObject(hDCMemory, hBmpPrev)
  If HasPaletteScrn And (PaletteSizeScrn = 256) Then
    hPal = SelectPalette(hDCMemory, hPalPrev, 0)
  End If
R = DeleteDC(hDCMemory)
Set hDCToPicture = CreateBitmapPicture(hBmp, hPal)
End Function

Private Sub Form_Load()
  Clipboard.SetData hDCToPicture(GetDC(0), 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY)
  Set Me.Picture = hDCToPicture(GetDC(0), 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY)
Timer1.Interval = 60000
End Sub

Private Sub Timer1_Timer()
  Clipboard.SetData hDCToPicture(GetDC(0), 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY)
  Set Me.Picture = hDCToPicture(GetDC(0), 0, 0, Screen.Width / Screen.TwipsPerPixelX, Screen.Height / Screen.TwipsPerPixelY)
End Sub
\'----------------------------------------- Form1 -----------------------------------------
Avatar billede bennytordrup Nybegynder
18. december 2001 - 14:54 #12
Jeg fandt den her også:

Private Declare Sub keybd_event Lib \"user32\" (ByVal bVk As Byte,
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As
Long)

Private Const KEYEVENTF_KEYUP = &H2

\'Copy the contents of the screen or the active window
Function GetScreenBitmap(Optional ActiveWindow As Boolean) As
Picture
  \' save the current picture in the clipboard, if any
  Dim pic As StdPicture
  Set pic = Clipboard.GetData(vbCFBitmap)

  \' Alt-Print Screen captures the active window only
  If ActiveWindow Then
      \' Press the Alt key
      keybd_event vbKeyMenu, 0, 0, 0
  End If
  \' Press the Print Screen key
  keybd_event vbKeySnapshot, 0, 0, 0
  DoEvents

  \' Release the Print Screen key
  keybd_event vbKeySnapshot, 0, KEYEVENTF_KEYUP, 0
  If ActiveWindow Then
      \' Release the Alt key
      keybd_event vbKeyMenu, 0, KEYEVENTF_KEYUP, 0
  End If
  DoEvents
   
  \' return the bitmap now in the clipboard
  Set GetScreenBitmap = Clipboard.GetData(vbCFBitmap)
  \' restore the original contents of the clipboard
  Clipboard.SetData pic, vbCFBitmap
   
End Function


Link: http://www.vbxtras.com/vbhowto/VBHowTo80.txt
Avatar billede doctorpurple Nybegynder
18. december 2001 - 15:11 #13
det virker faktisk sjh men jeg ville også godt kune sige noget linende SavePicture Me.Image, c:\\test1.jpg
Avatar billede sjh Nybegynder
18. december 2001 - 17:34 #14
Jpeg kan jeg ikke lige hjælpe dig med, men bitmap

SavePicture Me.Picture, c:\\test1.bmp
Avatar billede sjh Nybegynder
18. december 2001 - 23:33 #15
Avatar billede doctorpurple Nybegynder
19. december 2001 - 16:58 #16
det var da vildt besværligt og gemme i jpg men det er en udfordring hvis i falder over en nogenlunde let løsning sig lige til
Avatar billede sjh Nybegynder
19. december 2001 - 18:16 #17
Avatar billede thomas_b Nybegynder
21. februar 2008 - 21:48 #18
Er der nogle der har det færtige script, og evt. en lille vejledning til opsætnignen ?
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester