找回密码
 加入
搜索
查看: 2197|回复: 4

[系统综合] 这个问题没人解,有关摄像头?

[复制链接]
发表于 2010-12-20 11:18:18 | 显示全部楼层 |阅读模式
发表于 2010-12-20 13:29:16 | 显示全部楼层
运用定时器吧。

_Timer_SetTimer("",250,"find",-1)
 楼主| 发表于 2010-12-20 17:05:46 | 显示全部楼层
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Res_Comment=摄像头小工具
#AutoIt3Wrapper_Res_Description=摄像头小工具
#AutoIt3Wrapper_Res_Fileversion=0.1.0.3
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=PCbar 2008.10.16
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <webcam.au3>

FileInstall("km.wav", @TempDir & '\km.wav')
#Region ### START Koda GUI section ### Form=
$title = "摄像头预览"
$Form1 = GUICreate($title, 300, 260, -1, -1)
$Button1 = GUICtrlCreateButton("拍照", 24, 230, 65, 25, 0)
$Button2 = GUICtrlCreateButton("录像", 116, 230, 65, 25, 0)
$Button3 = GUICtrlCreateButton("退出", 210, 230, 65, 25, 0)
$Label1 = GUICtrlCreateLabel("By Pcbar", 232, 0, 68, 22)
GUICtrlSetFont(-1, 10, 800, 0, "Arial Black")
GUICtrlSetState(-1, $GUI_DISABLE)
$Label2 = GUICtrlCreateLabel("正在录像", 30, 195)
$webid = _webcamopen($Form1, 20, 20, 260, 195)

If $webid = -1 Then
        MsgBox(64, "出错", "创建预览窗口失败,请检查摄像头是否连接正常!", 20)
        Exit
EndIf
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button3
                        _webcamclose($webid)
                        If GUICtrlRead($Button2) = "停止" Then endrec()
                        Exit
                Case $Button1
                        #Region --- CodeWizard generated code Start ---
                        ;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Height=130
                        If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer
                        $sInputBoxAnswer = InputBox("拍照", "请输入保存的文件名(不含扩展名).", "Snap_" & @HOUR & @MIN & @SEC, " ", "-1", "130", "-1", "-1")
                        Select
                                Case @error = 0 ;OK - The string returned is valid

                                Case @error = 1 ;The Cancel button was pushed
                                        ContinueLoop
                                Case @error = 3 ;The InputBox failed to open

                        EndSelect
                        #EndRegion --- CodeWizard generated code Start ---
                        SoundPlay(@TempDir & '\km.wav')
                        _webcamsnap($webid, $sInputBoxAnswer & '.bmp')
                        
                Case $Button2
                        If GUICtrlRead($Button2) = "录像" Then
                                GUICtrlSetData($Button2, "停止")
                                TraySetState(4)
                                WinSetTitle($title, "", "正在录像...")
                                $avifile=@ScriptDir & '\Avi_' & @HOUR & @MIN & @SEC & '.avi'
                                _WebcamRecordStart($avifile, $webid)
        
                        Else
                                endrec()
                        EndIf
                        
                EndSwitch
WEnd

Func endrec()
        GUICtrlSetData($Button2, "录像")
        TraySetState(8)
        WinSetTitle("正在录像...", "", $title)
        _WebcamRecordStop($webid)
        TrayTip("Camera Tool","视频已保存至"&$avifile,10)
EndFunc   ;==>endrec
代码如上,在WIN7下运行时就有链接处的贴子所描述的问题了,定时器在这上如何用能说明一下吗?
 楼主| 发表于 2010-12-21 13:00:23 | 显示全部楼层
自己顶下,可别沉下去了,相信这样的问题后来者都会遇到
 楼主| 发表于 2010-12-23 14:31:36 | 显示全部楼层
本帖最后由 My2009 于 2010-12-30 13:16 编辑

自己顶下,可别沉下去了,相信这样的问题后来者都会遇到自己顶下,可别沉下去了,相信这样的问题后来者都会遇到
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-11 13:31 , Processed in 0.078819 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表