Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

WebCam example


  • Please log in to reply
84 replies to this topic

#1 rysiora

rysiora

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 20 June 2006 - 09:29 PM

AutoIt         
$WM_CAP_START = 0x400 $WM_CAP_UNICODE_START = $WM_CAP_START +100 $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW $WM_CAP_ABORT = $WM_CAP_START + 69 $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 $WM_CAP_EDIT_COPY = $WM_CAP_START + 30 $WM_CAP_END = $WM_CAP_UNICODE_END $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 $WM_CAP_GET_STATUS = $WM_CAP_START + 54 $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 $WM_CAP_PAL_OPENA = $WM_CAP_START + 80 $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 $WM_CAP_PAL_PASTE = $WM_CAP_START + 82 $WM_CAP_SEQUENCE = $WM_CAP_START + 62 $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 $WM_CAP_SET_SCALE = $WM_CAP_START + 53 $WM_CAP_SET_SCROLL = $WM_CAP_START + 55 $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 $WM_CAP_STOP = $WM_CAP_START + 68 #include <GUIConstants.au3> $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") $snapfile = @ScriptDir & "\scrshot.bmp" $Main = GUICreate("Camera",350,270) $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "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_SHOW) HotKeySet("{INSERT}", "SnapShot"); Press 'Insert' to make a SnapShot ! While 1     $msg = GUIGetMsg()     If $msg = $GUI_EVENT_CLOSE Then     ;DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SET_CALLBACK_FRAME, "int", 0, "int", 0)         DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_END, "int", 0, "int", 0)         DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_DISCONNECT, "int", 0, "int", 0)     ;DllClose($avi)         DllClose($user)         Exit     EndIf     Sleep(1) Wend Func SnapShot()     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) EndFunc


Maybe someone would find it useful. Insert is the HotKey for making photos.

Edited by rysiora, 14 July 2006 - 03:11 PM.








#2 nfwu

nfwu

    I'm not active on these forums

  • Active Members
  • PipPipPipPipPipPip
  • 1,234 posts

Posted 21 June 2006 - 01:34 AM

Interesting... Stick this into Valuater's PC LOCKOUT and there you go! You can actually take a pic of who was trying to break in!

My laptop has a embedded webcam, so i can make use of this.

#)

Edited by nfwu, 21 June 2006 - 01:35 AM.


#3 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 21 June 2006 - 07:07 AM

@rysiora

Only a black screen comes up using my WebCam ?

#4 GtaSpider

GtaSpider

    Polymath

  • Active Members
  • PipPipPipPip
  • 226 posts

Posted 21 June 2006 - 12:32 PM

Hello.

Nice Script. But how i can record to a avi (or better mpg)??

www.AutoIt.de - Moderator of The German AutoIt FroumPosted Image


#5 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 21 June 2006 - 03:12 PM

This is amazing! I've wondered how to do this for ages...
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#6 Lazycat

Lazycat

    Coding cat

  • MVPs
  • 1,174 posts

Posted 21 June 2006 - 05:19 PM

Very nice! Just tried, this also work fine with my TV Tuner. Though it's initialization take a lot time.
Koda homepage (http://www.autoitscript.com/fileman/users/lookfar/formdesign.html) (Bug Tracker)My Autoit script page (http://www.autoitscript.com/fileman/users/Lazycat/)

#7 rysiora

rysiora

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 22 June 2006 - 12:19 AM

Only a black screen comes up using my WebCam ?

Are you sure you have drivers installed and your cam is working in other programs? Or maybe you have your cam connected with other computer and using it by network - if so I can't help you yet.

You can try to change
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 1, "int", 0)

To 1,2 or other number if you have few devices/drivers of this type and your video driver is not the first one(index 0 is default).


Nice Script. But how i can record to a avi (or better mpg)??

Here is a sample of capturing to avi. It's not working perfectly, its very slow and sometimes stopping but it should work

;SIMPLY ADD THIS TO PREVIOUS SCRIPT FROM MY FIRST POST. HotKeySet("{HOME}", "StartRecording"); Press 'Home' to start recording ! Func StartRecording()     WinSetTitle($Main, "", "WebCam - Capturing...")     HotKeySet("{HOME}", "StopRecording")     DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $moviefile)     DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0) EndFunc Func StopRecording()     DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_STOP, "int", 0, "int", 0)     WinSetTitle($Main, "", "WebCam - Ready")     HotKeySet("{HOME}", "StartRecording") EndFunc

Edited by rysiora, 14 July 2006 - 03:14 PM.


#8 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 22 June 2006 - 12:19 PM

Indead there seems something wrong with the driver.

I will have to fix that first.

Excuse meee !

EDIT : WORKS PERFECT after fixing the driver problem on my machine

Great job !!

Edited by ptrex, 22 June 2006 - 12:54 PM.


#9 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 22 June 2006 - 03:17 PM

The video recording works nice but a bit slow.
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#10 rambo3889

rambo3889

    It is I

  • Active Members
  • PipPipPipPipPipPip
  • 802 posts

Posted 22 June 2006 - 05:17 PM

Dude this is awesome !
My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

#11 PezoFaSho

PezoFaSho

    Adventurer

  • Active Members
  • PipPip
  • 132 posts

Posted 22 June 2006 - 05:26 PM

This is awesome!! I doubt its possible but making an EyeToy type game with autoit would pwn
50% of the time, it works all the time

#12 WTS

WTS

    Polymath

  • Active Members
  • PipPipPipPip
  • 247 posts

Posted 22 June 2006 - 05:34 PM

OH MY GOD!!! I was looking for a program that can take snapshots and record video with my camera (it didn't include software/ or even say it can record video everything i found.. blatently sucked.. and TOO think this could be done with autoit is freaking incredible! it even records sound with the video , thanks for sharing rysiora!! :D

#13 WTS

WTS

    Polymath

  • Active Members
  • PipPipPipPip
  • 247 posts

Posted 22 June 2006 - 07:09 PM

can somebody make this into a UDF, pretty please

#14 rambo3889

rambo3889

    It is I

  • Active Members
  • PipPipPipPipPipPip
  • 802 posts

Posted 22 June 2006 - 07:13 PM

@nfwu suggested to put in Valuaters lockout
Here is some code i writted press numpad 2 and it will take some pictures when a person push a button on the keyboard press 2 again and it will ask for a password that if it is correct will turn off the capturing of images
Please report if i made something wrong in this code
Plain Text         
$WM_CAP_START = 0x400 $WM_CAP_UNICODE_START = $WM_CAP_START +100 $WM_CAP_PAL_SAVEA = $WM_CAP_START + 81 $WM_CAP_PAL_SAVEW = $WM_CAP_UNICODE_START + 81 $WM_CAP_UNICODE_END = $WM_CAP_PAL_SAVEW $WM_CAP_ABORT = $WM_CAP_START + 69 $WM_CAP_DLG_VIDEOCOMPRESSION = $WM_CAP_START + 46 $WM_CAP_DLG_VIDEODISPLAY = $WM_CAP_START + 43 $WM_CAP_DLG_VIDEOFORMAT = $WM_CAP_START + 41 $WM_CAP_DLG_VIDEOSOURCE = $WM_CAP_START + 42 $WM_CAP_DRIVER_CONNECT = $WM_CAP_START + 10 $WM_CAP_DRIVER_DISCONNECT = $WM_CAP_START + 11 $WM_CAP_DRIVER_GET_CAPS = $WM_CAP_START + 14 $WM_CAP_DRIVER_GET_NAMEA = $WM_CAP_START + 12 $WM_CAP_DRIVER_GET_NAMEW = $WM_CAP_UNICODE_START + 12 $WM_CAP_DRIVER_GET_VERSIONA = $WM_CAP_START + 13 $WM_CAP_DRIVER_GET_VERSIONW = $WM_CAP_UNICODE_START + 13 $WM_CAP_EDIT_COPY = $WM_CAP_START + 30 $WM_CAP_END = $WM_CAP_UNICODE_END $WM_CAP_FILE_ALLOCATE = $WM_CAP_START + 22 $WM_CAP_FILE_GET_CAPTURE_FILEA = $WM_CAP_START + 21 $WM_CAP_FILE_GET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 21 $WM_CAP_FILE_SAVEASA = $WM_CAP_START + 23 $WM_CAP_FILE_SAVEASW = $WM_CAP_UNICODE_START + 23 $WM_CAP_FILE_SAVEDIBA = $WM_CAP_START + 25 $WM_CAP_FILE_SAVEDIBW = $WM_CAP_UNICODE_START + 25 $WM_CAP_FILE_SET_CAPTURE_FILEA = $WM_CAP_START + 20 $WM_CAP_FILE_SET_CAPTURE_FILEW = $WM_CAP_UNICODE_START + 20 $WM_CAP_FILE_SET_INFOCHUNK = $WM_CAP_START + 24 $WM_CAP_GET_AUDIOFORMAT = $WM_CAP_START + 36 $WM_CAP_GET_CAPSTREAMPTR = $WM_CAP_START + 1 $WM_CAP_GET_MCI_DEVICEA = $WM_CAP_START + 67 $WM_CAP_GET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 67 $WM_CAP_GET_SEQUENCE_SETUP = $WM_CAP_START + 65 $WM_CAP_GET_STATUS = $WM_CAP_START + 54 $WM_CAP_GET_USER_DATA = $WM_CAP_START + 8 $WM_CAP_GET_VIDEOFORMAT = $WM_CAP_START + 44 $WM_CAP_GRAB_FRAME = $WM_CAP_START + 60 $WM_CAP_GRAB_FRAME_NOSTOP = $WM_CAP_START + 61 $WM_CAP_PAL_AUTOCREATE = $WM_CAP_START + 83 $WM_CAP_PAL_MANUALCREATE = $WM_CAP_START + 84 $WM_CAP_PAL_OPENA = $WM_CAP_START + 80 $WM_CAP_PAL_OPENW = $WM_CAP_UNICODE_START + 80 $WM_CAP_PAL_PASTE = $WM_CAP_START + 82 $WM_CAP_SEQUENCE = $WM_CAP_START + 62 $WM_CAP_SEQUENCE_NOFILE = $WM_CAP_START + 63 $WM_CAP_SET_AUDIOFORMAT = $WM_CAP_START + 35 $WM_CAP_SET_CALLBACK_CAPCONTROL = $WM_CAP_START + 85 $WM_CAP_SET_CALLBACK_ERRORA = $WM_CAP_START + 2 $WM_CAP_SET_CALLBACK_ERRORW = $WM_CAP_UNICODE_START + 2 $WM_CAP_SET_CALLBACK_FRAME = $WM_CAP_START + 5 $WM_CAP_SET_CALLBACK_STATUSA = $WM_CAP_START + 3 $WM_CAP_SET_CALLBACK_STATUSW = $WM_CAP_UNICODE_START + 3 $WM_CAP_SET_CALLBACK_VIDEOSTREAM = $WM_CAP_START + 6 $WM_CAP_SET_CALLBACK_WAVESTREAM = $WM_CAP_START + 7 $WM_CAP_SET_CALLBACK_YIELD = $WM_CAP_START + 4 $WM_CAP_SET_MCI_DEVICEA = $WM_CAP_START + 66 $WM_CAP_SET_MCI_DEVICEW = $WM_CAP_UNICODE_START + 66 $WM_CAP_SET_OVERLAY = $WM_CAP_START + 51 $WM_CAP_SET_PREVIEW = $WM_CAP_START + 50 $WM_CAP_SET_PREVIEWRATE = $WM_CAP_START + 52 $WM_CAP_SET_SCALE = $WM_CAP_START + 53 $WM_CAP_SET_SCROLL = $WM_CAP_START + 55 $WM_CAP_SET_SEQUENCE_SETUP = $WM_CAP_START + 64 $WM_CAP_SET_USER_DATA = $WM_CAP_START + 9 $WM_CAP_SET_VIDEOFORMAT = $WM_CAP_START + 45 $WM_CAP_SINGLE_FRAME = $WM_CAP_START + 72 $WM_CAP_SINGLE_FRAME_CLOSE = $WM_CAP_START + 71 $WM_CAP_SINGLE_FRAME_OPEN = $WM_CAP_START + 70 $WM_CAP_STOP = $WM_CAP_START + 68 #include <GUIConstants.au3> #include <Misc.au3> Local $states $pw="password" $avi = DllOpen("avicap32.dll") $user = DllOpen("user32.dll") $snapfile = @ScriptDir & "\scrshot-" HotKeySet("{NUMPAD2}","change") $Main = GUICreate("Camera",350,350) $cap = DllCall($avi, "int", "capCreateCaptureWindow", "str", "cap", "int", BitOR($WS_CHILD,$WS_VISIBLE), "int", 15, "int", 15, "int", 320, "int", 240, "hwnd", $Main, "int", 1) $label=GUICtrlCreateLabel("You have been filmed",15,260) $input=GUICtrlCreateInput("",15,280,200,25,$ES_PASSWORD) $stop=GUICtrlCreateButton("Stop filming",215,280,90,25) 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_HIDE) While 1     $msg = GUIGetMsg()     Switch $msg         Case $stop         checkforpass() EndSwitch if $states = 1 Then for $1=30 To 49     sleep(2) if _IsPressed($1) Then for $1=0 to 20000 if FileExists(@ScriptDir&"\scrshot-"&$1&".bmp") Then Else SnapShot($1) ExitLoop EndIf Next EndIf Next for $1=50 To 59     sleep(2) if _IsPressed($1) Then for $1=0 to 20000 if FileExists(@ScriptDir&"\scrshot-"&$1&".bmp") Then Else SnapShot($1) ExitLoop EndIf Next EndIf Next ;========== for $1=60 To 69 sleep(2) if _IsPressed($1) Then for $1=0 to 20000 if FileExists(@ScriptDir&"\scrshot-"&$1&".bmp") Then Else SnapShot($1) ExitLoop EndIf Next EndIf Next ;========== for $1=0 to 5 sleep(2) Local $char=65+$1 if  _IsPressed(4&Chr($char)) Then for $1=0 to 20000 if FileExists(@ScriptDir&"\scrshot-"&$1&".bmp") Then Else SnapShot($1) ExitLoop EndIf Next EndIf Next Else ;Do nothing EndIf Sleep(1) Wend Func SnapShot($para) 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&$para&".bmp") EndFunc Func wronganswer() For $1=0 to 20000       if FileExists(@ScriptDir&"\scrshot-"&$1&".bmp") Then Else 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&$1&".bmp") ExitLoop EndIf Next EndFunc Func change() if $states = 1 Then GUISetState(@SW_SHOW) Else ToolTip("Ready",0,0) Sleep(500) ToolTip("",4000,0) Global $states=1 GUISetState(@SW_HIDE) EndIf   EndFunc Func checkforpass() if GUICtrlRead($input) = $pw Then     MsgBox(0,"","Welcome back. Filming stopped"&@CRLF&"Program will be running ready for filming in background")     Global $states=0     GUISetState(@SW_HIDE)     Else     wronganswer()     MsgBox(0,"","Password Wrong. A picture have been added")     GUISetState(@SW_HIDE) EndIf EndFunc

My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

#15 Uten

Uten

    stupid is as stupid does..

  • Active Members
  • PipPipPipPipPipPip
  • 1,989 posts

Posted 22 June 2006 - 11:30 PM

Works like a charm on windows 2000 professional with SP 4 and a Logitech Quick Cam Express (USB 1.1).
Really nicly done. :D

#16 slipperylobster

slipperylobster

    Adventurer

  • Active Members
  • PipPip
  • 139 posts

Posted 23 June 2006 - 04:43 AM

:D I gotta make a security cam that will email pics of who is logging on my computer..
thanks for the webcam stuff here.

#17 ConsultingJoe

ConsultingJoe

    ConsultingJoe.com

  • Active Members
  • PipPipPipPipPipPip
  • 1,669 posts

Posted 25 June 2006 - 06:34 PM

:D I gotta make a security cam that will email pics of who is logging on my computer..
thanks for the webcam stuff here.

great idea, I havent tested it yet with my cams but I wana see if there is a way to make a motion sensing cam or even better a motion tracking cam.

Thanks man

#18 slipperylobster

slipperylobster

    Adventurer

  • Active Members
  • PipPip
  • 139 posts

Posted 25 June 2006 - 07:26 PM

I wana see if there is a way to make a motion sensing cam or even better a motion tracking cam.


:D go man go!!

#19 ConsultingJoe

ConsultingJoe

    ConsultingJoe.com

  • Active Members
  • PipPipPipPipPipPip
  • 1,669 posts

Posted 26 June 2006 - 11:28 AM

Are you sure you have drivers installed and your cam is working in other programs? Or maybe you have your cam connected with other computer and using it by network - if so I can't help you yet.

You can try to change
DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_DRIVER_CONNECT, "int", 1, "int", 0)

To 1,2 or other number if you have few devices/drivers of this type and your video driver is not the first one(index 0 is default).
Here is a sample of capturing to avi. It's not working perfectly, its very slow and sometimes stopping but it should work

;SIMPLY ADD THIS TO PREVIOUS SCRIPT FROM MY FIRST POST. HotKeySet("{HOME}", "StartRecording"); Press 'Home' to start recording ! Func StartRecording()     DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_FILE_SET_CAPTURE_FILEA, "int", 0, "str", $moviefile)     DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_SEQUENCE, "int", 0, "int", 0)     WinSetTitle($Main, "", "WebCam - Capturing...")     HotKeySet("{HOME}", "StopRecording") EndFunc Func StopRecording()     DllCall($user, "int", "SendMessage", "hWnd", $cap[0], "int", $WM_CAP_STOP, "int", 0, "int", 0)     WinSetTitle($Main, "", "WebCam - Ready")     HotKeySet("{HOME}", "StartRecording") EndFunc

This works but very laggy, it doesnt want to stop. do you know if it sits at the dll call or what?

Thanks, I love this

#20 eitan

eitan

    Seeker

  • Active Members
  • 21 posts

Posted 02 July 2006 - 12:47 PM

works great !!!!

is it possible to save the image as a jpg and not a bmp
so that the resulting image will be much smaller in size?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users