pywin32

Common ways to connect to odbc from python on windows?

What library should I use to connect to odbc from python on windows? Is there a good alternative for pywin32 when it comes to odbc? What about pyodbc? http://code.google.com/p/pyodbc/ Any others? Which one is good documented, robust, actively maintained, what are you guys using? ...

Creating a SQL Server database from Python

I'm using Python with pywin32's adodbapi to write a script to create a SQL Server database and all its associated tables, views, and procedures. The problem is that Python's DBAPI requires that cursor.execute() be wrapped in a transaction that is only committed by cursor.commit(), and you can't execute a drop or create database statemen...

GUI app spawned from a LocalSystem Service (via CreateProcessAsUser) does not have focus

I have created a service which display a sort of splash screen on the desktop of a specific user and only when that user is logged in (kiosk user). That splash screen, once entered a valid code, will tell that to the service and the service goes to sleep for an x amount of time (depending of the code). The splash screen simply quits. N...

How to retrieve the selected text from the active window

I am trying to create a simple open source utility for windows using Python that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut. Usage is partially outlined in the following example: The user selects some text using the mouse o...

Windows XP - mute/unmute audio in programmatically in Python

My machine has two audio inputs: a mic in that I use for gaming, and a line in that I use for guitar. When using one it's important that the other be muted to remove hiss/static, so I was hoping to write a small script that would toggle which one was muted (it's fairly inconvenient to click through the tray icon, switch to my input devic...

Python / ADOX: 'The specified module could not be found.' (win32 extensions)

I'm running pywin32 for python 2.5. I'm following the instructions for python ADO given at http://www.ecp.cc/pyado.html. Creating an ADODB.Recordset object works fine. But when I try to create an ADOX.Catalog object I get an error: >>> cat=win32com.client.Dispatch(r'ADOX.Catalog') Traceback (most recent call last): File "<interact...

CheckedListBox used from Python(pywin32)

Does anyone know how to get the list of items and check/uncheck items in a CheckedListBox from python? I've found this to help me partly on the way. I think I've found the handle for the CheckedListBox(listed as a SysTreeView32 by WinGuiAuto.py). One usage will for my part be to create an autoinstaller that manages to uncheck all checkb...

Python change screen resolution virtual machine

In virtualbox, the screen resolution can be anything - even something strange like 993x451, etc. I tried changing it using pywin32 but I failed:: >>> dm = win32api.EnumDisplaySettings(None, 0) >>> dm.PelsHeight = 451 >>> dm.PelsWidth = 950 >>> win32api.ChangeDisplaySettings(dm, 0) -2L which ends up being: DISP_CHANGE_BADMODE any he...

GetForegroundWindow returns Null when remote desktop is disconnected

I have a test that launches an app and verifies it has launched through calls to GetForegroundWindow(). The test is run on a remote machine that we usually access through remote desktop. When we have a rdp session open to the machine, the test completes and all is well. However, once we close the remote desktop, the test fails because Ge...

Problem with loading win32file.pyd on python 2.6

I can't make py2exe to pack correctly even a simple script that uses win32file I'm constantly getting the following error message: Traceback (most recent call last): File "dependency_checker.py", line 1, in <module> File "win32file.pyc", line 12, in <module> File "win32file.pyc", line 10, in __load ImportError: DLL load failed: Th...

Symlinks on windows?

Does anyone know of a way to make/read symbolic links across versions of win32 from Python? Ideally there should be a minimum amount of platform specific code, as I need my app to be cross platform. ...

Detecting symlinks (mklink) on Vista/7 in Python without Pywin32

Currently the buildout recipe collective.recipe.omelette uses junction.exe on all versions of Windows to create symlinks. However junction.exe does not come with Windows by default and most importantly does not support creating symlinks to files (only directories) which causes a problem with quite a few Python packages. On NT6+ (Vista a...

Windows impersonation for WMI calls via python?

I'm using PyWin32 to make WMI calls to the system in python from my django web application. My goal is to allow users to add printers to the system via a web interface. To do this, I'm using win32print.AddPrinterConnection. This works well running the development server under my user account. I can add all the printers I want. However, ...

python win32 extensions documentation

I'm new to both python and the python win32 extensions available at http://python.net/crew/skippy/win32/ but I can't find any documentation online or in the installation directories concerning what exactly the win32 extensions provide. Where is this information? ...

[Python] Best way to extract .ico from .exe and paint with PyQt?

Hello, I am looking for a way to extract an icon from a .exe file using Python. I know that you can use win32gui's ExtractIconEx function to grab the icon of a .exe but this returns a HIcon resource handle which is no good because I want to paint the icon using PyQt. Also the only example I have seen using win32gui does not have any tr...

Updating MS Word (or Open Office) bookmarks with Python

I'd like to fill MSWord bookmarks from a python script. I can't find such functions in win32com(MSWord) or in PyUno(OpenOffice). Does anyone know how to use bookmarks from Python? ...

On Windows in python, possibly using the Outlook API, how can I get the full name of a user from their smaller login name?

At work, we have short login names, e.g. hastingsg, but Outlook and I believe other parts of the Windows system also have access to a longer name, e.g. Jeff Hastings. In cpython (not IronPython), if I have the shorter login name, how can I get the longer full name? I have pywin32 and ExchangeCDO installed. ...

Python Windows Service Problems - Works when using debug argument but not while started as a service?

Hello all, hopefully someone here can shed some light on my issue :D I've been creating a Windows XP service in python that is designed to monitor/repair selected Windows/Application/Service settings, atm I have been focusing on default DCOM settings. The idea is to backup our default configuration within another registry key for refer...

Get process argument info in windows with python/pywin32?

In linux, I know with 'ps' you can get the arguments that a command was run with. I need the equivalent in windows Right now in python I'm doing Process[i] = subprocess.Popen(cmd + " --daemon --config " + str(i) + ".conf", shell=False) But I'm doing this in a daemon that is meant to be up all (or most) of the time. Since I'm having t...

Use Python to extract ListView items from another application

Hello all, I have an application with a ListView ('SysListView32') control, from which I would like to extract data. The control has 4 columns, only textual data. I have been playing around the following lines (found online somewhere): VALUE_LENGTH = 256 bufferlength_int=struct.pack('i', VALUE_LENGTH) count = win32gui.SendMessage(Targe...