Popular Python recipes tagged "meta:requires=win32con"http://code.activestate.com/recipes/langs/python/tags/meta:requires=win32con/2011-08-28T12:25:49-07:00ActiveState Code RecipesCheck PC Power (Python)
2011-08-28T12:25:49-07:00Frank Larkinhttp://code.activestate.com/recipes/users/4179117/http://code.activestate.com/recipes/577861-check-pc-power/
<p style="color: grey">
Python
recipe 577861
by <a href="/recipes/users/4179117/">Frank Larkin</a>
(<a href="/recipes/tags/api/">api</a>, <a href="/recipes/tags/computer/">computer</a>, <a href="/recipes/tags/passing/">passing</a>, <a href="/recipes/tags/pointers/">pointers</a>, <a href="/recipes/tags/power/">power</a>, <a href="/recipes/tags/widows/">widows</a>).
</p>
<p>Call windows API GetSystemPowerStatus to determine if the AC power is on or off. Great example of calling Windows APIs using Ptyhon.</p>
Manage environment variables on Windows (Python)
2011-03-31T18:27:57-07:00Sridhar Ratnakumarhttp://code.activestate.com/recipes/users/4169511/http://code.activestate.com/recipes/577621-manage-environment-variables-on-windows/
<p style="color: grey">
Python
recipe 577621
by <a href="/recipes/users/4169511/">Sridhar Ratnakumar</a>
(<a href="/recipes/tags/environment/">environment</a>, <a href="/recipes/tags/pywin32/">pywin32</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 7.
</p>
<p>This recipe facilitates getting and setting of both "user" and "system" environment variables on Windows. It uses PyWin32 (included in ActivePython) ... and works on both Python 2 and Python 3.</p>
Recursively querying for registry subkeys (Python)
2009-07-28T03:23:29-07:00Heinz Hermannhttp://code.activestate.com/recipes/users/4171265/http://code.activestate.com/recipes/576860-recursively-querying-for-registry-subkeys/
<p style="color: grey">
Python
recipe 576860
by <a href="/recipes/users/4171265/">Heinz Hermann</a>
(<a href="/recipes/tags/regdeletetree/">regdeletetree</a>, <a href="/recipes/tags/registry/">registry</a>, <a href="/recipes/tags/substitute/">substitute</a>, <a href="/recipes/tags/win32api/">win32api</a>).
Revision 2.
</p>
<p>Because the Windows XP API does not support the RegDeleteTree function, the programmer has to query for subkeys of a registry key recursively, before he can delete it. This functions returns all subkeys of a registry key in deleteable order, which means the deepest subkey is the first in the list. </p>
Redate pictures with EXIF (Python)
2009-06-29T03:06:01-07:00Ivan Koblikhttp://code.activestate.com/recipes/users/4168407/http://code.activestate.com/recipes/576822-redate-pictures-with-exif/
<p style="color: grey">
Python
recipe 576822
by <a href="/recipes/users/4168407/">Ivan Koblik</a>
(<a href="/recipes/tags/creation_date/">creation_date</a>, <a href="/recipes/tags/date/">date</a>, <a href="/recipes/tags/exif/">exif</a>, <a href="/recipes/tags/modification_date/">modification_date</a>, <a href="/recipes/tags/picture/">picture</a>, <a href="/recipes/tags/video/">video</a>).
Revision 2.
</p>
<p>Reads creation date from EXIF picture/video file header, and sets it to the file's creation and modification dates. This script differs from other recipes in its ability to work with the creation date in Windows.
The script depends on several libraries: Win32 Extensions, pyexif, exif. <a href="http://koblik.blogspot.com/2009/06/exif-with-python.html">Here's</a> description of what they do and where to get them.</p>
how to create a windows service in python (Python)
2008-08-26T01:32:47-07:00alexander bakerhttp://code.activestate.com/recipes/users/4166679/http://code.activestate.com/recipes/576451-how-to-create-a-windows-service-in-python/
<p style="color: grey">
Python
recipe 576451
by <a href="/recipes/users/4166679/">alexander baker</a>
.
</p>
<p>The following code snippet shows you have to create a windows service from a python script. The most important thing here is the username and password, if you ignore supplying these the server will never start and you will get a message saying that the service has not responded in time, this is a red herring. The default account that the pythonservice wrapper uses is not permissioned to run the service. </p>
export variable on win32 like *nix (Python)
2008-08-18T20:10:34-07:00winterTTr Donghttp://code.activestate.com/recipes/users/4164498/http://code.activestate.com/recipes/576431-export-variable-on-win32-like-nix/
<p style="color: grey">
Python
recipe 576431
by <a href="/recipes/users/4164498/">winterTTr Dong</a>
(<a href="/recipes/tags/register_table/">register_table</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 4.
</p>
<p>Export variable PERMANENTLY on win32 , without needing to reboot system.</p>
<p>EXAMPLE:</p>
<p>import win32export</p>
<p>win32export.export("fooname" , "foovalue")</p>
<p>NOTE: </p>
<p>you need to install "pywin32" if you want to use this .</p>
Treat the Win32 Registry like a Python dict -- updated (again!) (Python)
2008-06-21T08:12:09-07:00Chris Melvillehttp://code.activestate.com/recipes/users/103458/http://code.activestate.com/recipes/573466-treat-the-win32-registry-like-a-python-dict-update/
<p style="color: grey">
Python
recipe 573466
by <a href="/recipes/users/103458/">Chris Melville</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 4.
</p>
<p>This class wraps most of the win32api functions for accessing a registry. It will read and write all win32 registry types, and will de/serialize python objects to registry keys when a string or integer representation is not possible.</p>
<p>This is an update of <a href="http://code.activestate.com/recipes/551761/">recipe 551761</a>, which is in turn an update of 174627, folding in the enhancements listed in the discussion there to allow registry value types to be read and written within the dictionary metaphore if required. It doesnt change how it worked before, it adds a new capability, and shouldnt break existing code using the 551761 version.</p>
Print Tkinter canvas without a postscript printer (Python)
2008-04-28T21:32:47-07:00jesse jameshttp://code.activestate.com/recipes/users/4145727/http://code.activestate.com/recipes/572175-print-tkinter-canvas-without-a-postscript-printer/
<p style="color: grey">
Python
recipe 572175
by <a href="/recipes/users/4145727/">jesse james</a>
.
Revision 2.
</p>
<p>My printer will not accept postscript and all i needed to print was canvas rectangles. So here is something i put together... hope it helps someone else.
-works for polys, recs, and lines-</p>
Treat the Win32 Registry like a Python dict -- updated (Python)
2008-03-11T11:38:50-07:00Don Dwigginshttp://code.activestate.com/recipes/users/2347932/http://code.activestate.com/recipes/551761-treat-the-win32-registry-like-a-python-dict-update/
<p style="color: grey">
Python
recipe 551761
by <a href="/recipes/users/2347932/">Don Dwiggins</a>
.
</p>
<p>This class wraps most of the win32api functions for accessing a registry. It will read and write all win32 registry types, and will de/serialize python objects to registry keys when a string or integer representation is not possible.</p>
<p>This is an update of <a href="http://code.activestate.com/recipes/174627/">recipe 174627</a>, folding in the corrections listed in the discussion there.</p>
Set Process Priority In Windows (Python)
2006-06-02T07:05:41-07:00Bryan Niederbergerhttp://code.activestate.com/recipes/users/2843232/http://code.activestate.com/recipes/496767-set-process-priority-in-windows/
<p style="color: grey">
Python
recipe 496767
by <a href="/recipes/users/2843232/">Bryan Niederberger</a>
(<a href="/recipes/tags/ui/">ui</a>).
</p>
<p>This function allows you to set process priority under windows. It defaults to setting the priority of the current python process but can set anything for which you have a process ID. I find it handy to set a long-running job with lower than normal priority so the computer doesn't feel sluggish while it runs.</p>
PathCatcher - Windows utility for right-click capture of file or folder path (Python)
2008-04-19T17:14:18-07:00Jack Trainorhttp://code.activestate.com/recipes/users/4076953/http://code.activestate.com/recipes/528893-pathcatcher-windows-utility-for-right-click-captur/
<p style="color: grey">
Python
recipe 528893
by <a href="/recipes/users/4076953/">Jack Trainor</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 3.
</p>
<p>PathCatcher is a Windows utility that allows one to right-click on a file or a folder or a group of files and folders in Explorer and save its path to the clipboard.</p>
<p>To install, save the code as PathCatcher.py, then double-click the PathCatcher.py file. Afterwards, PathCatcher will appear in the Explorer right-click menu.</p>
Simplest Registry I/O (Python)
2007-08-24T12:38:48-07:00Jack Trainorhttp://code.activestate.com/recipes/users/4076953/http://code.activestate.com/recipes/528896-simplest-registry-io/
<p style="color: grey">
Python
recipe 528896
by <a href="/recipes/users/4076953/">Jack Trainor</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>Most of the time I just want to either read or write one value to the registry. Here are two functions: ReadRegistryValue and WriteRegistryValue plus a few helpers.</p>
Grab screen on Windows (PrintScreen emulation) (Python)
2006-06-30T09:53:18-07:00Keisuke URAGOhttp://code.activestate.com/recipes/users/668964/http://code.activestate.com/recipes/496853-grab-screen-on-windows-printscreen-emulation/
<p style="color: grey">
Python
recipe 496853
by <a href="/recipes/users/668964/">Keisuke URAGO</a>
(<a href="/recipes/tags/graphics/">graphics</a>).
Revision 2.
</p>
<p>Grab the screen shot on Windows.</p>
Persistent environment variables on Windows (Python)
2007-07-24T18:46:47-07:00Gigi Sayfanhttp://code.activestate.com/recipes/users/101538/http://code.activestate.com/recipes/416087-persistent-environment-variables-on-windows/
<p style="color: grey">
Python
recipe 416087
by <a href="/recipes/users/101538/">Gigi Sayfan</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 4.
</p>
<p>This script allows adding/modifying/removing environment variables persistently on Windows. It also allows adding entries to the PATH environment variable.</p>
Getting SYSTEM environment variable under Windows (Python)
2009-02-10T07:24:02-08:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/473800-getting-system-environment-variable-under-windows/
<p style="color: grey">
Python
recipe 473800
by <a href="/recipes/users/57155/">Denis Barmenkov</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 2.
</p>
<p>As you can see in Windows Control Panel 'System' applet there are two groups of environment variables: USER and SYSTEM.
Here presents function for retrieve SYSTEM variable value.</p>
Changing the background color of the menu bar in a wxPython Windows app (Python)
2005-09-02T19:09:28-07:00Kartic Krishnamurthyhttp://code.activestate.com/recipes/users/2570233/http://code.activestate.com/recipes/440507-changing-the-background-color-of-the-menu-bar-in-a/
<p style="color: grey">
Python
recipe 440507
by <a href="/recipes/users/2570233/">Kartic Krishnamurthy</a>
(<a href="/recipes/tags/ui/">ui</a>).
Revision 2.
</p>
<p>Using win32 API to change the background color of the menubar/menu items in a wxPython app without affecting system-wide settings.</p>
changing file attributes on windows (Python)
2004-09-03T11:54:59-07:00John Nielsenhttp://code.activestate.com/recipes/users/135654/http://code.activestate.com/recipes/303343-changing-file-attributes-on-windows/
<p style="color: grey">
Python
recipe 303343
by <a href="/recipes/users/135654/">John Nielsen</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>The win32api module offers SetFileAttributes whiles allows you to make changes to a file in windows. You can set a file to be read only, archive, hidden, etc. The function is simple and convenient to use.</p>
Remote Shutdown on Windows (Python)
2004-12-24T01:40:56-08:00Fadly Tabranihttp://code.activestate.com/recipes/users/2143621/http://code.activestate.com/recipes/360649-remote-shutdown-on-windows/
<p style="color: grey">
Python
recipe 360649
by <a href="/recipes/users/2143621/">Fadly Tabrani</a>
(<a href="/recipes/tags/network/">network</a>).
</p>
<p>Shuts down or reboots a remote computer.</p>
Parse Command Line String from CommandLine or String given base on windows OS (Python)
2007-05-18T02:01:32-07:00cheeng shu chinhttp://code.activestate.com/recipes/users/163970/http://code.activestate.com/recipes/436187-parse-command-line-string-from-commandline-or-stri/
<p style="color: grey">
Python
recipe 436187
by <a href="/recipes/users/163970/">cheeng shu chin</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
Revision 3.
</p>
<p>This is a way to parse command line from user provided string or try to get the original Argv from Windows OS Platform.</p>
Windows clipboard viewer (Python)
2004-12-04T12:50:56-08:00Georg Nelleshttp://code.activestate.com/recipes/users/2176948/http://code.activestate.com/recipes/355593-windows-clipboard-viewer/
<p style="color: grey">
Python
recipe 355593
by <a href="/recipes/users/2176948/">Georg Nelles</a>
(<a href="/recipes/tags/ui/">ui</a>).
</p>
<p>With the "SetClipboardViewer" function you can add a window to the chain of clipboard viewers. Whenever the content of the clipboard changes, a message is send to the clipboard viewer windows. A clipboard viewer window must process two messages and pass them to the next window in the chain.
With a sample about hooking the window procedure of a wxPython Frame, I made up the following clipboard viewer.</p>