AFax - get fax images Was: AFax - device options
"valery_vi" <[email protected]>
| Newsgroups | gmane.comp.windows.autoit.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Next script AFax2.au3:
;Get faxes from the outgoing fax archive and copy theirs into script
folder
; Important note:
; Minimum operating systems Windows XP, Windows Server 2003
Global $FaxServer, $FaxActivity, $FaxDevices, $FaxDevice
Global $MsgTitle = 'Fax Sample'
$FaxServer = ObjCreate('FaxComEx.FaxServer')
if Not IsObj($FaxServer) then
MsgBox(0,$MsgTitle, 'FaxServer was not created!')
exit
endif
; Connect to the local fax server.
$FaxServer.Connect('')
if @Error then
MsgBox(0,$MsgTitle, 'FaxServer was not connected!')
exit
endif
DisplayFaxServerInfo($FaxServer)
;Create the outgoing archive
$FaxOutArchive = $FaxServer.Folders.OutgoingArchive
if Not IsObj($FaxOutArchive) then
MsgBox(0,$MsgTitle, 'FaxOutArchive were not created!')
exit
endif
DisplayOutArchiveInfo($FaxOutArchive)
;Get the outgoing message
$FaxOutgoingMessageIterator = $FaxOutArchive.GetMessages()
if Not IsObj($FaxOutgoingMessageIterator) then
MsgBox(0,$MsgTitle, 'FaxOutgoingMessageIterator were not created!')
exit
endif
$TiffId = 0
;Moving through archive messages
$FaxOutgoingMessageIterator.MoveFirst()
While $FaxOutgoingMessageIterator.AtEOF <> -1
$OutMsg = $FaxOutgoingMessageIterator.Message
if Not IsObj($OutMsg) then
MsgBox(0,$MsgTitle, 'OutgoingMsg were not obtained!')
exit
endif
DisplayOutMsgInfo($OutMsg)
;get and put image of Fax
$OutMsg.CopyTiff(@ScriptDir & '\OutFax_' & $TiffId & '.tif')
$OutMsg = 0
$FaxOutgoingMessageIterator.MoveNext()
$TiffId += 1
wend
exit
;Display Outgoing Msg Info
func DisplayOutMsgInfo($OutMsg)
local $Msg = 'Outgoing Msg Info:' & @CrLf
$Msg &= ' CSID: ' & $OutMsg.CSID & @CrLf
$Msg &= ' TSID: ' & $OutMsg.TSID & @CrLf
$Msg &= ' DeviceName: ' & $OutMsg.DeviceName & @CrLf
$Msg &= ' DocumentName: ' & $OutMsg.DocumentName & @CrLf
$Msg &= ' Id: ' & $OutMsg.Id & @CrLf
$Msg &= ' Pages: ' & $OutMsg.Pages & @CrLf
$Msg &= ' Priority: ' & $OutMsg.Priority & @CrLf
$Msg &= ' Retries: ' & $OutMsg.Retries & @CrLf
$Msg &= ' Size: ' & $OutMsg.Size & @CrLf
$Msg &= ' Subject: ' & $OutMsg.Subject & @CrLf
MsgBox(0,$MsgTitle, 'FaxDevice' & @CrLf & $Msg)
endfunc
;Display Outgoing Archive object Info
func DisplayOutArchiveInfo($FaxOutArchive)
local $Msg = 'Outgoing Archive Info:' & @CrLf
$Msg &= ' AgeLimit: ' & $FaxOutArchive.AgeLimit & @CrLf
$Msg &= ' ArchiveFolder: ' & $FaxOutArchive.ArchiveFolder & @CrLf
$Msg &= ' HighQuotaWaterMark: ' & $FaxOutArchive.HighQuotaWaterMark
& @CrLf
$Msg &= ' LowQuotaWaterMark: ' & $FaxOutArchive.LowQuotaWaterMark &
@CrLf
$Msg &= ' Size: ' & Hex($FaxOutArchive.SizeHigh) & ':' & Hex
($FaxOutArchive.SizeLow) & @CrLf
$Msg &= ' UseArchive: ' & ToBool($FaxOutArchive.UseArchive) & @CrLf
MsgBox(0,$MsgTitle, 'FaxDevice' & @CrLf & $Msg)
endfunc
;Display Fax Server Info
func DisplayFaxServerInfo($FaxServer)
local $Msg = 'Fax Server Info:' & @CrLf
$Msg &= ' API Version: ' & $FaxServer.APIVersion & @CrLf
$Msg &= ' Debug: ' & $FaxServer.Debug & @CrLf
$Msg &= ' Build and version: ' & $FaxServer.MajorBuild & '.' &
$FaxServer.MajorVersion & '.' & $FaxServer.MinorVersion & @CrLf
$Msg &= ' Server Name: ' & $FaxServer.ServerName & @CrLf
MsgBox(0,$MsgTitle, 'FaxDevice' & @CrLf & $Msg)
endfunc
func ToBool($v)
if $v = -1 then return TRUE
return FALSE
endfunc
Thus, you can easy get tiff images (faxes) from outgoingArchive
archive.
Valery
--- In [email protected], "valery_vi" <shehrer1@...> wrote:
> >
> > Hi,
> >
> > Early I had problems with fax sending but today my fax device is
> > working fine (ACorp modem - $20). So I want to automate it's hard
> job
> > by AutoIt.
> >
> > This is first simple AutoFax script which can connect to my
> FaxServer
> > and show it's options:
> >
> > ; Important note:
> > ; Minimum operating systems Windows XP, Windows Server 2003
> >
> > Global $FaxServer, $FaxActivity, $FaxDevices, $FaxDevice
> > Dim $MsgTitle = 'Fax Sample'
> >
> > $FaxServer = ObjCreate('FaxComEx.FaxServer')
> > if Not IsObj($FaxServer) then
> > MsgBox(0,$MsgTitle, 'FaxServer was not created!')
> > exit
> > endif
> >
> > ; Connect to the local fax server.
> > $FaxServer.Connect('')
> > if @Error then
> > MsgBox(0,$MsgTitle, 'FaxServer was not connected!')
> > exit
> > endif
> > MsgBox(0,$MsgTitle, 'FaxServer connected!')
> >
> > $FaxActivity = $FaxServer.Activity
> > if Not IsObj($FaxActivity) then
> > MsgBox(0,$MsgTitle, 'FaxActivity was not created!')
> > exit
> > endif
> > MsgBox(0,$MsgTitle, 'FaxActivity created!')
> >
> > ;Refresh the activity object
> > $FaxActivity.Refresh()
> >
> > ;Retrieves a list of fax devices
> > $FaxDevices = $FaxServer.GetDevices()
> > if Not IsObj($FaxDevices) then
> > MsgBox(0,$MsgTitle, 'FaxDevices were not obtained!')
> > exit
> > endif
> >
> > MsgBox(0,$MsgTitle, 'FaxServer has ' & $FaxDevices.Count & '
> > devices..')
> >
> > $FaxDevice = $FaxDevices.Item(0)
> > if Not IsObj($FaxDevice) then
> > MsgBox(0,$MsgTitle, 'FaxDevice was not obtained!')
> > exit
> > endif
> >
> > $Msg = ''
> > $Msg &= ' CSID: ' & $FaxDevice.CSID & @CrLf
> > $Msg &= ' TSID: ' & $FaxDevice.TSID & @CrLf
> > $Msg &= ' Description: ' & $FaxDevice.Description & @CrLf
> > $Msg &= ' Name: ' & $FaxDevice.DeviceName & @CrLf
> > $Msg &= ' Id: ' & $FaxDevice.Id & @CrLf
> > $Msg &= ' PoweredOff: ' & $FaxDevice.PoweredOff & @CrLf
> > $Msg &= ' ProviderUniqueName: ' & $FaxDevice.ProviderUniqueName &
> > @CrLf
> > $Msg &= ' ReceiveMode: ' & $FaxDevice.ReceiveMode & @CrLf
> > $Msg &= ' SendEnabled: ' & $FaxDevice.SendEnabled & @CrLf
> >
> > MsgBox(0,$MsgTitle, 'FaxDevice' & @CrLf & $Msg)
> >
> > Enjoy,
> > Valery
> >
> > PS. Really my goal is to extract TIFF image from Fax device. I
> would
> > like to use this weird method to convert any text documents into
> > image form.
> > :-)
> >
>