News123 wrote: > Hi, > > I'm trying to scan a document from a python 2.6 script without user > interaction. > > I found a code snippet, that allows me to scan under Vista, but that > doesn't allow me to select the dpi / color mode / etc.
I'm still stuck. I'll try to look at any solution (visual C++, C#, Basic) first. Then it's perhaps easier to pythonize it via python .net. However I don't know whether python .net exists for 2.6 and whether it is stable enough. N > > The snippet uses win32com.client > > # ##################### script start > import win32com.client,os > > WIA_IMG_FORMAT_PNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" > WIA_COMMAND_TAKE_PICTURE = "{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" > > os.chdir('c:/temp') > wia = win32com.client.Dispatch("WIA.CommonDialog") > dev = wia.ShowSelectDevice() > for command in dev.Commands: > if command.CommandID==WIA_COMMAND_TAKE_PICTURE: > foo=dev.ExecuteCommand(WIA_COMMAND_TAKE_PICTURE) > i=1 > for item in dev.Items: > if i==dev.Items.Count: > image=item.Transfer(WIA_IMG_FORMAT_PNG) > break > i=i+1 > > image.SaveFile("test.png") > ######################### script end > > > My problems are: > > - This script works fine for me under Windows 7, however I'm > unable to specify additional parameters, like dpi and > color mode. > > - The script doesn't work under windows XP, though the scanner driver is > installed. (Gimp finds the scanner (as WIA scanner)). > Perhaps 'WIA.CommonDialig' has another name or I need to install some DLL. > The error message is: > -------------------------------------------------------------------- > Traceback (most recent call last): > File "C:\work\python\minidemos\wia_get_simple.py", line 7, in <module> > wia = win32com.client.Dispatch("WIA.CommonDialog") > File "C:\Python26\lib\site-packages\win32com\client\__init__.py", line > 95, in Dispatch > dispatch, userName = > dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) > File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line > 104, in _GetGoodDispatchAndUserName > return (_GetGoodDispatch(IDispatch, clsctx), userName) > File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line > 84, in _GetGoodDispatch > IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, > pythoncom.IID_IDispatch) > com_error: (-2147221005, 'Invalid class string', None, None) > --------------------------------------------------------------------- > > > As I have no knowledge of Win32com and WIA I would appreciate some help > or good documentation about wincom32 / WIA with python > > > > thanks for your help and bye > > > N > > > > > > -- http://mail.python.org/mailman/listinfo/python-list