用扫描仪批量扫描资料时,怎么知道已扫描完(300分)

  • 主题发起人 主题发起人 一生中最爱
  • 开始时间 开始时间

一生中最爱

Unregistered / Unconfirmed
GUEST, unregistred user!
用扫描仪批量扫描资料时,怎么知道已扫描完,有经验的大侠不妨说说,up有分
 
给你一段例子,是用VB写的,可能对你有点帮助。

VERSION 5.00
Object = "{6D940288-9F11-11CE-83FD-02608C3EC08A}#2.1#0"; "IMGEDIT.OCX"
Object = "{84926CA3-2941-101C-816F-0E6013114B7F}#1.0#0"; "IMGSCAN.OCX"
Begin VB.Form frmScan
Caption = "扫描正文"
ClientHeight = 5610
ClientLeft = 60
ClientTop = 345
ClientWidth = 7410
BeginProperty Font
Name = "宋体"
Size = 11.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Icon = "frmScan.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5610
ScaleWidth = 7410
StartUpPosition = 3 '窗口缺省
WindowState = 2 'Maximized
Begin ScanLibCtl.ImgScan scnM
Left = 600
Top = 2040
_Version = 65536
_ExtentX = 1032
_ExtentY = 926
_StockProps = 0
DestImageControl= "ImgEdit1"
Page = 0
StopScanBox = -1 'True
PageOption = 2
MultiPage = -1 'True
ScanTo = 1
End
Begin VB.Frame frmControl
Height = 1200
Left = 45
TabIndex = 1
Top = 0
Width = 7305
Begin VB.CheckBox optScan
Caption = "是否双面扫描"
Height = 375
Left = 195
TabIndex = 8
Top = 720
Width = 1695
End
Begin VB.CommandButton cmdRotate
Caption = "旋转(&R)"
Enabled = 0 'False
Height = 400
Left = 3090
TabIndex = 7
Top = 240
Width = 990
End
Begin VB.CommandButton cmdCancel
Caption = "取消(&C)"
Height = 400
Left = 5070
TabIndex = 6
Top = 240
Width = 990
End
Begin VB.CommandButton cmdOk
Caption = "确定(&O)"
Enabled = 0 'False
Height = 400
Left = 4080
TabIndex = 5
Top = 240
Width = 990
End
Begin VB.CommandButton cmdNext
Caption = "下页(&D)"
Enabled = 0 'False
Height = 400
Left = 2100
TabIndex = 4
Top = 240
Width = 990
End
Begin VB.CommandButton cmdPrevious
Caption = "上页(&U)"
Enabled = 0 'False
Height = 400
Left = 1110
TabIndex = 3
Top = 240
Width = 990
End
Begin VB.CommandButton cmdScan
Caption = "扫描(&S)"
Height = 400
Left = 120
TabIndex = 2
Top = 240
Width = 990
End
Begin VB.Frame frmDegree
Height = 510
Left = 2970
TabIndex = 10
Top = 585
Width = 2220
Begin VB.OptionButton optDegree
Caption = "270"
Height = 225
Index = 2
Left = 1440
TabIndex = 13
Top = 225
Width = 735
End
Begin VB.OptionButton optDegree
Caption = "180"
Height = 225
Index = 1
Left = 720
TabIndex = 12
Top = 225
Width = 780
End
Begin VB.OptionButton optDegree
Caption = "90"
Height = 225
Index = 0
Left = 135
TabIndex = 11
Top = 225
Value = -1 'True
Width = 645
End
End
Begin VB.Frame frmDirection
Height = 510
Left = 5265
TabIndex = 14
Top = 585
Width = 1725
Begin VB.OptionButton optDirection
Caption = "左转"
Height = 225
Index = 1
Left = 855
TabIndex = 16
Top = 210
Width = 780
End
Begin VB.OptionButton optDirection
Caption = "右转"
Height = 225
Index = 0
Left = 45
TabIndex = 15
Top = 210
Value = -1 'True
Width = 780
End
End
Begin VB.Label lblRotate
Caption = "旋转设置:"
Height = 285
Left = 1935
TabIndex = 9
Top = 765
Width = 1095
End
End
Begin ImgeditLibCtl.ImgEdit imgView
Height = 4320
Left = 60
TabIndex = 0
Top = 1260
Width = 7260
_Version = 131073
_ExtentX = 12806
_ExtentY = 7620
_StockProps = 96
BorderStyle = 1
ImageControl = "ImgEdit1"
BeginProperty AnnotationFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Times New Roman"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
UndoBufferSize = 41599232
OcrZoneVisibility= -4044
AnnotationOcrType= 88
End
End
Attribute VB_Name = "frmScan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim miCurrent As Integer '当前显示页
Dim miTotal As Integer '保存双页扫描时第二次扫描的页数、和所有的页数
Dim mbSave As Boolean '是否开始保存文件
Dim mSpath As String '保存文件的目录 默认为app.path+temp
Dim miBuffer As Integer '保存双页扫描时第一次扫描的页数

'============================自定义函数========================

Private Sub u_Save()
'将扫描的图象按顺序生成文件 文件格式为256色的tif文件格式的文件
Dim i As Integer
On Error Resume Next
If optScan.Value = False Then '单面扫描
imgView.Image = mSpath + "scan1.tif"
For i = 1 To miTotal
imgView.Page = i
imgView.Display
imgView.SavePage mSpath + "zw" + Trim(str(i)) + ".bmp", 1, 5, 9, 8, , 1
Next
Else '双面扫描
imgView.Image = mSpath + "scan1.tif"
For i = 1 To miBuffer
imgView.Page = i
imgView.Display
imgView.SavePage mSpath + "zw" + Trim(str(i * 2 - 1)) + ".bmp", 1, 5, 9, 8, , 1
Next
imgView.Image = mSpath + "scan2.tif"
For i = 1 To miTotal
imgView.Page = i
imgView.Display
imgView.SavePage mSpath + "zw" + Trim(str((miTotal - i + 1) * 2)) + ".bmp", 1, 5, 9, 8, , 1
Next
miTotal = miBuffer + miTotal
End If
If Dir(mSpath + "zw1.bmp") <> "" Then
imgView.Image = mSpath + "zw1.bmp"
imgView.Display
cmdPrevious.Enabled = False
If miTotal > 1 Then
cmdNext.Enabled = True
Else
cmdNext.Enabled = False
End If
cmdRotate.Enabled = True
cmdOk.Enabled = True
Else
cmdPrevious.Enabled = False
cmdNext.Enabled = False
cmdRotate.Enabled = False
cmdOk.Enabled = False
End If
If Dir(mSpath + "scan1.tif") <> "" Then
Kill mSpath + "scan1.tif"
End If
If Dir(mSpath + "scan2.tif") <> "" Then
Kill mSpath + "scan2.tif"
End If
cmdScan.Enabled = True
optScan.Enabled = True
miCurrent = 1
imgView.Page = 1
End Sub

'============================窗体事件========================

Private Sub cmdCancel_Click() '取消退出
gbyExit = EXIT_CANCEL
Unload Me
End Sub

Private Sub cmdNext_Click() '显示下页
Dim sFile As String
miCurrent = miCurrent + 1
cmdPrevious.Enabled = True
sFile = mSpath + "zw" + Trim(str(miCurrent)) + ".bmp"
If Dir(sFile) <> "" Then
imgView.Image = sFile
imgView.Display
End If
If miCurrent = miTotal Then
cmdNext.Enabled = False
End If
End Sub

Private Sub cmdOk_Click()
gbyExit = EXIT_OK
Unload Me
End Sub

Private Sub cmdPrevious_Click() '显示上页
Dim sFile As String
miCurrent = miCurrent - 1
cmdNext.Enabled = True
sFile = mSpath + "zw" + Trim(str(miCurrent)) + ".bmp"
If Dir(sFile) <> "" Then
imgView.Image = sFile
imgView.Display
End If
If miCurrent = 1 Then
cmdPrevious.Enabled = False
End If
End Sub

Private Sub cmdRotate_Click() '旋转并保存
If optDirection(0).Value = True Then
If optDegree(0).Value = True Then
imgView.RotateRight 900
ElseIf optDegree(1).Value = True Then
imgView.RotateRight 1800
Else
imgView.RotateRight 2700
End If
Else
If optDegree(0).Value = True Then
imgView.RotateLeft 900
ElseIf optDegree(1).Value = True Then
imgView.RotateLeft 1800
Else
imgView.RotateLeft 2700
End If
End If
imgView.Save
End Sub

Private Sub cmdScan_Click() '扫描
Dim sFile As String
On Error GoTo errHander
miTotal = 0
cmdScan.Enabled = False
optScan.Enabled = False
sFile = Dir(mSpath + "*.*")
Do While True
If sFile = "" Then
Exit Do
Else
Kill mSpath + sFile
End If
sFile = Dir(mSpath + "*.*")
Loop
mbSave = True
If optScan.Value = 1 Then mbSave = False
scnM.Image = mSpath + "scan1.tif"
scnM.StartScan
miBuffer = miTotal
mbSave = True
If optScan.Value = 1 Then '是否双面扫描
MsgBox "请放入要扫描的文件!", , "继续扫描"
scnM.Image = mSpath + "scan2.tif"
scnM.StartScan
End If
Exit Sub
errHander:
MsgBox Err.Description
cmdScan.Enabled = True
optScan.Enabled = True
End Sub

Private Sub Form_Load()
mSpath = App.Path
If Right(App.Path, 1) <> "/" Then mSpath = mSpath + "/"
mSpath = mSpath + "temp/"
gbyExit = EXIT_CANCEL
End Sub

Private Sub Form_Resize()
frmControl.Width = Me.ScaleWidth - frmControl.Left - 80
imgView.Width = Me.ScaleWidth - imgView.Left - 80
imgView.Height = Me.ScaleHeight - imgView.Top - 80
End Sub


Private Sub scnM_PageDone(ByVal PageNumber As Long)
miTotal = PageNumber '记录每次扫描的页数
End Sub

Private Sub scnM_ScanUIDone()
If mbSave = True Then '扫描是否结束
u_Save
End If
End Sub
 
多人接受答案了。
 
后退
顶部