This script comes from Activestate. It exports a variable permanently on win32 – without needing to reboot the system. Note: pywin32 must be installed to run the script.
The following script adjusts the brightness and contrast of an image via COM automation of Adobe Photoshop with Python and the win32com package.
import win32com.client
psApp = win32com.client.Dispatch("Photoshop.Application")
psApp.Open(r"D:\temp\blah.psd") # Opens a PSD file
doc = psApp.Application.ActiveDocument # Get active document object
layer = doc.ArtLayers[0] # Get the bottom-most layer
layer.AdjustBrightnessContrast(20,-15) # Bright +20, Contrast -15
doc.Save()
This comes from http://techarttiki.blogspot.com/2008/08/photoshop-scripting-with-python.html where you can find more excellent examples to automate Adobe Photoshop.
This example comes from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440493. It searches the ModelSpace collection for text objects. Once found it casts them and alter one of the text specific properties. To test this code AutoCAD must be started with a blank file open add at least one dtext object with ‘Spam’ as its value:
import win32com.client
acad = win32com.client.Dispatch("AutoCAD.Application")
doc = acad.ActiveDocument # Document object
ms = doc.ModelSpace # Modelspace "collection"
count = ms.Count # Number of items in modelspace
for i in range(count):
item = ms.Item(i)
if 'text' in item.ObjectName.lower(): # Text objects are AcDbText
# once we know what it is we can cast it
text = win32com.client.CastTo(item, "IAcadText")
if text.TextString == "Spam":
text.TextString = "Maps"
text.Update()
Adrian Holovaty wrote a small Python script to access Microsoft Outlook Web Access. It can do some actions by commandline via screen scraping. The script lets you access your emails (in raw format, with all headers) from the Microsoft Outlook’s webmail interface.
It works by screen-scraping the interface. Possible actions are:
Log into a Microsoft Outlook Web Access account with a given username and password
Retrieve all email IDs from the first page of Inbox
Retrieve full, raw source of the email with a given ID
Delete an email with a given ID (move to”Deleted Items” folder)
This is a PDF Batch Converter extension for Adobe Acrobat and Acrobat 3D. This tool converts 3D CAD models to 3D-PDF as well as Office documents to PDF and works in following modes:
Convert single files
Convert files in a directory in batch
Converts a type of files with wildcards like *.CATPart, *.prt, *.model, …
Works as a deamon which watches into a directory (directory watcher)
If you want to use the source with a Python interpreter, it needs a config.ini with this content:
# Configuration of Acrobat2PDF:
[configsection]
# Only for usage as a server/deamon process
# Poll time is the time in seconds for each loop of conversion
polltime = 10
And here comes the Python source code. Pywin32 needed.
from __future__ import with_statement
"""
Adobe Acrobat2PDF Batch Converter
This tool converts all Office Documents to PDF and a lot of 3D CAD models
to 3D-PDF
Copyright Mustafa Goermezer
http://www.goermezer.de
"""
import getopt
import os
from win32com.client.dynamic import Dispatch
import pythoncom
import win32gui
import time
import sys
import glob
import string
import ConfigParser
import datetime
def LoadConfig(file, config={}):
"""
returns a dictionary with key's of the form
.