Sign in to follow this  
Followers 0
FredinThailand

chose twain source in filemaker

4 posts in this topic

First of all, i am not a programmer.

What i need to do is find a way to chose the twain device to use to input an image into a Filemaker container.

I use a plug in to do the scan but need to chose which device to use, to use a scanner or a camera.

Thank you in advance

Fred

Share this post


Link to post
Share on other sites



I have noticed that several posts regarding TWAIN devices are lef (partially) unanswered, so here is my contribution. The purpose is only to give an example, so there is much room for improvement.

First of all get eztw32.dll (www.dosadi.com).

Put it in the directory of the script.

Run the script.

The script will:

  • check for the presence of the dll
  • check for the availability of TWAIN
  • lets you select a device
  • lets you acquire an image to a file

There are many other features in the dll not used (like raw data handling). See the information that comes with the dll.

I ran the script on WIN2K with an HP ScanJet 3400C.

This will probably also answer (part of) following topics:

topic 48948

topic 23463

topic 27503

CODE
;Include constants

#include <GUIConstants.au3>

#include <GuiEdit.au3>

;Initialize variables

Global $GUIWidth

Global $GUIHeight

$GUIWidth = 290

$GUIHeight = 250

;Create window

$hwnd = GUICreate("TWAINtest", $GUIWidth, $GUIHeight)

;Create a form with buttons

$button1 = GUICtrlCreateButton("check", 10, 20, 60, 25)

$button2 = GUICtrlCreateButton("select", 10, 60, 60, 25)

$button3 = GUICtrlCreateButton("acquire", 10, 100, 60, 25)

;...and with labels to display messages

$edit1 = GUICtrlCreateLabel("", 80, 25, 200, 25)

$edit2 = GUICtrlCreateLabel("", 80, 45, 200, 25)

$edit3 = GUICtrlCreateLabel("", 80, 65, 200, 25)

$edit4 = GUICtrlCreateLabel("", 80, 105, 200, 25)

;Disable buttons

GUICtrlSetState($button2, $GUI_DISABLE)

GUICtrlSetState($button3, $GUI_DISABLE)

;Show window/Make the window visible

GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

;Destroy the GUI including the controls

GUIDelete()

;Exit the script

Exit

Case $msg = $button1

;Get the DLL version (211 means 2.11, so divide by 100)

$rc = DllCall('EZTW32.DLL','long','TWAIN_EasyVersion')

;@error returns error from DllCall function

if @error <> 0 then

_GUICtrlEdit_SetText($edit1,'eztw32.dll load error')

else

_GUICtrlEdit_SetText($edit1,'eztw32.dll version: ' & $rc[0]/100)

$rc = DllCall("eztw32.dll","long","TWAIN_IsAvailable")

_GUICtrlEdit_SetText($edit2,'TWAIN available: RC = ' & $rc[0])

if $rc[0] <> 0 then

GUICtrlSetState($button2, $GUI_ENABLE)

endif

endif

Case $msg = $button2

;Select image source

;A new window is openened and the select source manageris displayed

;All available TWAIN devices should be in the list

$rc = DllCall("eztw32.dll","long","TWAIN_SelectImageSource",'hwnd',$hwnd)

if $rc[0] <> 0 then

GUICtrlSetState($button3, $GUI_ENABLE)

_GUICtrlEdit_SetText($edit3,'TWAIN device selected')

else

_GUICtrlEdit_SetText($edit3,'no TWAIN device selected')

endif

Case $msg = $button3

;Acquire image to a file

$rc = DllCall("eztw32.dll","long","TWAIN_AcquireToFilename","hwnd",$hwnd,"str","")

_GUICtrlEdit_SetText($edit4,'RC = ' & $rc[0])

EndSelect

WEnd

1 person likes this

Share this post


Link to post
Share on other sites

I have noticed that several posts regarding TWAIN devices are lef (partially) unanswered, so here is my contribution. The purpose is only to give an example, so there is much room for improvement.

...

Hi,

Thank you very much for your snippet. Ready to use, works like a charm ! ^_^

I saw you were using an HP printer. Did you manage to get rid of the HP window that lets you enter your scan parameters, crop the image and so on ? I'm planning to build a little software to manage my bills and refunds (just select bill type and month, click on scan button and it will write an image file in a directory depending on what type of bill and year). It'd really ease my pain if I could just click my button and it will create the file without having to wait for preload and so on.

I checked the eztwain dll source, but I couldn't find a way to disable the printer's window.

Do you have an idea ?

Thx

Share this post


Link to post
Share on other sites

@FredinThailand -

Which Plugin are you using? Which Version of FileMaker?

I have copies of FM here various versions I may be able to help.

Cheers

NBJ

Share this post


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
Sign in to follow this  
Followers 0