#include-once #include #include ; #INDEX# ======================================================================================================================= ; Title .........: Easy Twain classic library -> original Dosadi library but should work with new library that requires licensing! ; AutoIt Version : 3.3.14.2 ; Language ......: English ; Description ...: functions of Easy Twain classic library -> http://www.eztwain.com/ ; Author(s) .....: Mylise ; =============================================================================================================================== ; #Functions# ====================================================================================================================== Global $hEZTwain32 Global $ezVersion Global $ezDebug = False ; used to verify if functions are executing Dim $ezState[8] = ['undefined','Source manager not loaded','Source manager loaded but not open','Source manager open but device not open', _ 'Source device open but not enabled','Source device enabled to acquire', _ 'Image ready to transfer','Image in transit'] Dim $ezRCStatus[12] = ['TWRC_SUCCESS', 'TWRC_FAILURE', 'TWRC_CHECKSTATUS', 'TWRC_CANCEL', _ 'TWRC_DSEVENT', 'TWRC_NOTDSEVENT', 'TWRC_XFERDONE', 'TWRC_ENDOFLIST', _ 'TWRC_INFONOTSUPPORTED', 'TWRC_DATANOTAVAILABLE', 'TWRC_BUSY', 'TWRC_SCANNERLOCKED'] ;------------------------------------------------ ; _EZTwain_Start() ; ; Loads DLL library ; Func _EZTwain_Start() $hEZTwain32 = DllOpen("EZTW32.dll") $ezVersion = _EZTwain_Version() EndFunc ;------------------------------------------------ ; _EZTwain_FloatToFix32($ezFloat) ; ; Returns the TW_Fix32 of a float ; Func _EZTwain_FloatToFix32($ezFloat) $aCall = DllCall($hEZTwain32,"long","TWAIN_ToFix32","double",$ezFloat) If($ezDebug) Then $tTemp = DllStructCreate("long;") DllStructSetData($tTemp,1,$aCall[0]) $pTemp = DllStructGetPtr($tTemp) $tTW_FIX32 = DllStructCreate($tagTW_FIX32,$tTemp) ConsoleWrite('--> Float converted to : ' & 'Whole = ' & DllStructGetData($tTW_FIX32,1) & ' Fraction = ' & DllStructGetData($tTW_FIX32,2) &@CRLF) EndIf Return $aCall[0] EndFunc ;------------------------------------------------ ; _EZTwain_Fix32ToFloat($ezFix32) ; ; Returns the TW_Fix32 of a float ; Func _EZTwain_Fix32ToFloat($ezFix32) $aCall = DllCall($hEZTwain32,"double","TWAIN_Fix32ToFloat","long",$ezFix32) If($ezDebug) Then ConsoleWrite('--> Fix32 converted to : ' & 'Float = ' & $aCall[0] &@CRLF) EndIf Return $aCall[0] EndFunc ;------------------------------------------------ ; _EZTwain_Version() ; ; Returns the version number of EZTWAIN.DLL, multiplied by 100. ; Func _EZTwain_Version() $aCall = DllCall($hEZTwain32,"int","TWAIN_EasyVersion") If($ezDebug) Then ConsoleWrite('--> EZTWAIN version: ' & $aCall[0]&@CRLF) EndIf Return $aCall[0] EndFunc ;------------------------------------------------ ; _EZTwain_IsAvailable() ; ; Find out if TWAIN Source Manager is installed on the system ; Returns True if it is available ; Func _EZTwain_IsAvailable() $aCall=DllCall($hEZTwain32,"int","TWAIN_IsAvailable") If($ezDebug) Then ConsoleWrite('--> Source Manager MGR available ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] EndFunc ;------------------------------------------------ ; _EZTwain_VerifyState() ; ; Find out TWAIN State ; Returns the state value. Can use global string variable $ezState for definition ;#define TWAIN_PRESESSION 1 // source manager not loaded ;#define TWAIN_SM_LOADED 2 // source manager loaded ;#define TWAIN_SM_OPEN 3 // source manager open ;#define TWAIN_SOURCE_OPEN 4 // source open but not enabled ;#define TWAIN_SOURCE_ENABLED 5 // source enabled to acquire ;#define TWAIN_TRANSFER_READY 6 // image ready to transfer ;#define TWAIN_TRANSFERRING 7 // image in transit ; Func _EZTwain_VerifyState() $aCall=DllCall($hEZTwain32,"int","TWAIN_State") Return $aCall[0] EndFunc ;------------------------------------------------ ; _EZTwain_LoadSourceManager() ; ; Will load and open Source Manager ; Returns True if it is loaded and opened ; Func _EZTwain_LoadSourceManager() If(_EZTwain_VerifyState() < 2) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_LoadSourceManager") EndIf $aCall=DllCall($hEZTwain32,"int","TWAIN_OpenSourceManager","HWnd",0) If($ezDebug) Then ConsoleWrite('--> Source Manager loaded and opened ? ' & ((($aCall[0]) ? 'Yes':'No')) & @CRLF) EndIf Return $aCall[0] EndFunc ;------------------------------------------------ ; _EZTwain_DeviceSelect() ; ; Will open GUI to select source device. This makes chages to default source found in registry ; Returns True if selected ; Func _EZTwain_DeviceSelect() If(_EZTwain_VerifyState() >= 3) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_SelectImageSource","HWnd",0) If($ezDebug) Then ConsoleWrite('--> Source device selected ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Manager not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceOpen() ; ; Connect Source manager to default source device. ; Returns True if connected ; Func _EZTwain_DeviceOpen() DllCall($hEZTwain32,"none","TWAIN_SetHideUI","int",1) If(_EZTwain_VerifyState() >= 3) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_OpenDefaultSource") If($ezDebug) Then ConsoleWrite('--> Source device opened ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Manager not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_CallMgr($ezDg,$ezDat,$ezMsg,$pData) ; ; Call Source manager with tripplet ; Returns True if successful with updated info in $pData ; Func _EZTwain_CallMgr($ezDg,$ezDat,$ezMsg,$pData) If(_EZTwain_VerifyState() >= 3) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_Mgr","ulong",$ezDg,"word",$ezDat,"word",$ezMsg,"ptr",$pData) If($ezDebug) Then ConsoleWrite('--> Call Source Manager with tripplet ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Manager not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_CallDS($ezDg,$ezDat,$ezMsg,$pData) ; ; Call Source manager with tripplet ; Returns True if successful with updated info in $pData ; Func _EZTwain_CallDS($ezDg,$ezDat,$ezMsg,$pData) If(_EZTwain_VerifyState() >= 4) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_DS","ulong",$ezDg,"word",$ezDat,"word",$ezMsg,"ptr",$pData) If($ezDebug) Then ConsoleWrite('--> Call Source Device with tripplet ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_GetCapValue($ezCap,$ezItemType,$pData) ; ; Do a DAT_CAPABILITY/MSG_GETCURRENT on capability 'Cap' ; Returns True if successful with updated info in $pData of type either ONEVALUE or ENUMERATION ; Func _EZTwain_GetCapValue($ezCap,$ezItemType,$pData) If(_EZTwain_VerifyState() >= 4) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_GetCapCurrent","word",$ezCap,"word",$ezItemType,"ptr",$pData) If($ezDebug) Then ConsoleWrite('--> Call Source Device with Cap Get Current value ?? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetCapValue($ezCap,$ezItemType,$ezItemVal) ; ; Do a DAT_CAPABILITY/MSG_Set on capability 'Cap' ; Returns True if successful ; Func _EZTwain_SetCapValue($ezCap,$ezItemType,$ezItemVal) If(_EZTwain_VerifyState() >= 4) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_SetCapOneValue","word",$ezCap,"word",$ezItemType,"long",$ezItemVal) If($ezDebug) Then ConsoleWrite('--> Call Source Device with Cap Set Current value ?? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceSetDPI($ezDPI) ; ; Sets device dot per inch value ; Returns True if successfully ; Func _EZTwain_DeviceSetDPI($ezDPI = 72) If(_EZTwain_VerifyState() >= 4) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_SetCurrentResolution","double",$ezDPI) If($ezDebug) Then ConsoleWrite('--> DPI set successfully ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) $ezSavedDPI = DllCall($hEZTwain32,"double","TWAIN_GetCurrentResolution") ConsoleWrite('--> DPI value in device = ' & $ezSavedDPI[0] &@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceAcquire_DIB($hWnd = 0. $ezPType) ; ; Gets DIB from devices and loads into memory ; $ezPType can be any from Twain $TWPT_ ie. $TWPT_BW, $TWPT_GRAY, $TWPT_RGB ; Returns header of DIB in memory if successfully ; Func _EZTwain_DeviceAcquire_DIB($hWnd = 0, $ezPType = 0) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_AcquireNative","HWnd",$hWnd,"ulong",$ezPType) If($ezDebug) Then ConsoleWrite('--> Pointer of DIB = 0x' & Hex($aCall[0])&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceAcquire_ClipPut($hWnd = 0. $ezPType) ; ; Gets DIB from devices and loads into memory ; $ezPType can be any from Twain $TWPT_ ie. $TWPT_BW, $TWPT_GRAY, $TWPT_RGB ; Returns header of DIB in memory if successfully ; Func _EZTwain_DeviceAcquire_ClipPut($hWnd = 0, $ezPType = 0) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_AcquireToClipboard","HWnd",$hWnd,"ulong",$ezPType) If($ezDebug) Then ConsoleWrite('--> Acquire to Clipboard ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_Free_DIB($hDib) ; ; Releases memory allocation of DIB ; Returns header of DIB in memory if successfully ; Func _EZTwain_Free_DIB($hDib = 0) If($hDib <> 0) Then DllCall($hEZTwain32,"none","TWAIN_FreeNative","ptr",$hDib) If($ezDebug) Then ConsoleWrite('--> Released DIB at pointer 0x' & Hex($hDib)&@CRLF) EndIf Return 1 Else If($ezDebug) Then ConsoleWrite('--> No DIB header available ' &@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceAcquire_File($ezFilename) ; ; Gets DIB from devices and saves as BMP file. If no filename is provided, it will open a save dialog box. ; For ezFilename: Must provide path, filename, and extension .BMP ; Returns true if successfully saved ; Func _EZTwain_DeviceAcquire_File($ezFilename = Null) DllCall($hEZTwain32,"none","TWAIN_SetHideUI","int",1) If(_EZTwain_VerifyState() >= 4) Then If ($ezFilename == Null) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_AcquireToFilename","HWnd",0,"ptr", Null) If($ezDebug) Then ConsoleWrite('--> Saved with Null ' & @CRLF) EndIf Else Local $stString = DllStructCreate("char[" & StringLen($ezfilename) + 1 & "]") DllStructSetData($stString, 1, $ezfilename) $aCall=DllCall($hEZTwain32,"int","TWAIN_AcquireToFilename","HWnd",0,"ptr", DllStructGetPtr($stString)) If($ezDebug) Then ConsoleWrite('--> Saved with filename ' & $ezFilename&@CRLF) EndIf EndIf Return True Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceUserInterface($hWnd) ; ; Opens manufacturer's GUI interface of Twain device ; Issue with this as sometimes it hangs ; Returns True if user interface was opened successfully ; Func _EZTwain_DeviceUserInterface($hWnd) DllCall($hEZTwain32,"none","TWAIN_SetHideUI","int",0) If(_EZTwain_VerifyState() >= 4) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_OpenDefaultSource","HWnd",$hWnd) WinWaitClose($hWnd) If($ezDebug) Then ConsoleWrite('--> Returned from user interface ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceSetDefault($ezFilename) ; ; Changes default device in registry, device must be closed ; For ezFilename: Must provide path, filename, and extension .DS using backslash as separator ; Returns true if successfully changed ; Func _EZTwain_DeviceSetDefault($ezFilename = Null) If ($ezFilename == Null) Then If($ezDebug) Then ConsoleWrite('--> No filename provided' & @CRLF) EndIf Return 0 ElseIf (FileExists($ezFilename) == 0) Then If($ezDebug) Then ConsoleWrite('--> File does not exists ' & @CRLF) EndIf Return 0 EndIf If (_EZTwain_VerifyState() <= 3 ) Then Local $tKeyName = "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\TWAIN" RegWrite($tKeyName,"Default Source","REG_SZ",$ezFilename) If($ezDebug) Then ConsoleWrite('--> Saved in Registry -->' & $ezFilename &@CRLF) EndIf Return True Else If($ezDebug) Then ConsoleWrite('--> Source device is opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_DeviceClose() ; ; Disconnect Source manager to default source device. ; Returns True if disconnected ; Func _EZTwain_DeviceClose() If(_EZTwain_VerifyState() >= 3) Then $aCall=DllCall($hEZTwain32,"int","TWAIN_CloseSource") If($ezDebug) Then ConsoleWrite('--> Source device closed ? ' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source Manager not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_Stop() ; ; Closes source device and source manager ; Closes DLL library ; Func _EZTwain_Stop() $aCall=DllCall($hEZTwain32,"int","TWAIN_DisableSource") $aCall=DllCall($hEZTwain32,"int","TWAIN_CloseSource") $aCall=DllCall($hEZTwain32,"int","TWAIN_CloseSourceManager","HWnd",0) $aCall=DllCall($hEZTwain32,"int","TWAIN_UnloadSourceManager") DllClose($hEZTwain32) EndFunc ;------------------------------------------------ ; _EZTwain_GetUnits() ; ; Gets Source Units (cm, inches, pixel) ; ; Returns units if successfully ; Func _EZTwain_GetUnits() If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_GetCurrentUnits") If($ezDebug) Then ConsoleWrite('--> Current units = ' & $aCall[0]&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_GetBitDepth() ; ; Gets Source BitDepth ; ; Returns BitDepth if successfully ; Func _EZTwain_GetBitDepth() If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_GetBitDepth") If($ezDebug) Then ConsoleWrite('--> Bit Depth = ' & $aCall[0]&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_GetPixelType() ; ; Gets Source PixelType ; ; Returns PixelType if successfully ; Func _EZTwain_GetPixelType() If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_GetPixelType") If($ezDebug) Then ConsoleWrite('--> Pixel Type = ' & $aCall[0]&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_GetXResolution() ; ; Gets Source Current Horizontal Resolution ; ; Returns X Resolution if successfully ; Func _EZTwain_GetXResolution() If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"double","TWAIN_GetCurrentResolution") If($ezDebug) Then ConsoleWrite('--> X Resolution = ' & $aCall[0]&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_GetYResolution() ; ; Gets Source Current Vertical Resolution ; ; Returns Y Resolution if successfully ; Func _EZTwain_GetYResolution() If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"double","TWAIN_GetYResolution") If($ezDebug) Then ConsoleWrite('--> Y Resolution = ' & $aCall[0]&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetUnits($ezVal) ; ; Sets Source Units (cm, inches, pixel) ; ; Returns true if successfully ; Func _EZTwain_SetUnits($ezVal) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_SetCurrentUnits","int",$ezVal) If($ezDebug) Then ConsoleWrite('--> Current units set ?' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetBitDepth($ezVal) ; ; Sets Source BitDepth ; ; Returns True if successfully ; Func _EZTwain_SetBitDepth($ezVal) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_SetBitDepth","int",$ezVal) If($ezDebug) Then ConsoleWrite('--> Bit Depth set ?' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetPixelType($ezVal) ; ; Sets Source PixelType ; ; Returns True if successfully ; Func _EZTwain_SetPixelType($ezVal) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_SetCurrentPixelType","int",$ezVal) If($ezDebug) Then ConsoleWrite('--> Pixel Type set ?' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetXResolution($ezVal) ; ; Sets Source Current Horizontal Resolution ; ; Returns True if successfully ; Func _EZTwain_SetXResolution($ezVal) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_SetCurrentResolution","double",$ezVal) If($ezDebug) Then ConsoleWrite('--> X Resolution set ?' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetContrast($ezVal) ; ; Sets Source Contrast from -1000 to 1000 ; ; Returns True if successfully ; Func _EZTwain_SetContrast($ezVal) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_SetContrast","double",$ezVal) If($ezDebug) Then ConsoleWrite('--> Contrast set ?' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc ;------------------------------------------------ ; _EZTwain_SetBrightness($ezVal) ; ; Sets Source Brightness from -1000 to 1000 ; ; Returns True if successfully ; Func _EZTwain_SetBrightness($ezVal) If(_EZTwain_VerifyState() >= 4) Then $aCall = DllCall($hEZTwain32,"int","TWAIN_SetBrightness","double",$ezVal) If($ezDebug) Then ConsoleWrite('--> Contrast set ?' & (($aCall[0]) ? 'Yes':'No')&@CRLF) EndIf Return $aCall[0] Else If($ezDebug) Then ConsoleWrite('--> Source device not opened! --> State = ' & _EZTwain_VerifyState() & ' --> ' & $ezState[_EZTwain_VerifyState()]&@CRLF) EndIf Return 0 EndIf EndFunc