r wrote: > more *maybe useful dump? > >>>> for i in dev.Items: > for p in i.Properties: > if not p.IsReadOnly: > print p.Name, '->', p.Value > . . . > Horizontal Resolution -> 200 > Vertical Resolution -> 200 > Horizontal Start Position -> 0 . . . > > Now how to set the values... hmmm? >
How to set the values? This is THE magic question. At least I found out how to set the values in C# : foreach (Property prop in item.Properties){ if (prop.IsReadOnly) continue; if (prop.Name == "Horizontal Resolution") { IProperty iprop = (IProperty)prop; Object val = 75; iprop.set_Value(ref val); } } Below my most recent complete script: (still not able to set params, though I can with C#) import win32com.client, os WIA_COM = "WIA.CommonDialog" WIA_IMG_FORMAT_PNG = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}" WIA_COMMAND_TAKE_PICTURE="{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}" def takePictureOrNot(dev): # cameras have to call TakePicture for command in dev.Commands: if command.CommandID==WIA_COMMAND_TAKE_PICTURE: print "take PICK" foo=dev.ExecuteCommand(WIA_COMMAND_TAKE_PICTURE) def setImgProps(item): # here scan properties should be set for prop in item.Properties: if prop.IsReadOnly: continue if(prop.Name == "Horizontal Resolution"): res = 250 print "trying to set",prop.Name,prop,"to ",res ### unfortunately the next line (if uncommented) fails #prop.set_Value(res) def transferImg(dev): # set properties and scan image i=1 image = None for item in dev.Items: if i==dev.Items.Count: setImgProps(item) image=item.Transfer(WIA_IMG_FORMAT_PNG) break i=i+1 return image def scan_image_wia(): wia = win32com.client.Dispatch(WIA_COM) # CommonDialog object dev = wia.ShowSelectDevice() takePictureOrNot(dev) image = transferImg(dev) return image image = scan_image_wia() fname = 'wia-test.jpg' if os.path.exists(fname): os.remove(fname) image.SaveFile(fname) bye N -- http://mail.python.org/mailman/listinfo/python-list