Popular recipes tagged "meta:requires=win32api"http://code.activestate.com/recipes/tags/meta:requires=win32api/2015-01-03T02:04:02-08:00ActiveState Code RecipesSnake the game (Python)
2015-01-03T02:04:02-08:00Burak Tandoganhttp://code.activestate.com/recipes/users/4191373/http://code.activestate.com/recipes/578996-snake-the-game/
<p style="color: grey">
Python
recipe 578996
by <a href="/recipes/users/4191373/">Burak Tandogan</a>
(<a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/pygame/">pygame</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/snake/">snake</a>, <a href="/recipes/tags/the/">the</a>).
Revision 3.
</p>
<p>Popular Snake game with Python-Pygame module. <strong>Important:</strong> If you try to run this script without special <strong>png-wav</strong> files it will fail, you have to put following files to a directory with this script. "apple.png","snakehead.png","intro.wav","dead.wav". They are basically apple picture, head of snake, intro sound and dead sound.Without them script will not run. Just make inactive the statements intro.wav and dead.wav, and find a little apple picture and snake head :).Or you can play the game just install it. <strong>Here is the installer:</strong> <a href="http://dosya.co/7c6f15c0f4d04514/Flafel-1.26-win32.rar" rel="nofollow">http://dosya.co/7c6f15c0f4d04514/Flafel-1.26-win32.rar</a>
It will install the game in program files, you can find it in search "Flafel" and click to Flafel.exe. </p>
Creating a single instance application (Python)
2014-11-20T11:59:46-08:00Matteo Bertinihttp://code.activestate.com/recipes/users/4191156/http://code.activestate.com/recipes/578966-creating-a-single-instance-application/
<p style="color: grey">
Python
recipe 578966
by <a href="/recipes/users/4191156/">Matteo Bertini</a>
(<a href="/recipes/tags/threads/">threads</a>).
</p>
<p>Sometimes it is necessary to ensure that only one instance of application is running. This quite simple solution uses mutex to achieve this, and will run only on Windows platform.</p>
Use DebugView utility with standard python logging (Python)
2010-02-10T10:35:59-08:00Christopher Prinoshttp://code.activestate.com/recipes/users/481494/http://code.activestate.com/recipes/577040-use-debugview-utility-with-standard-python-logging/
<p style="color: grey">
Python
recipe 577040
by <a href="/recipes/users/481494/">Christopher Prinos</a>
(<a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/debugview/">debugview</a>, <a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/sysinternals/">sysinternals</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>This is a custom logging.Handler class that lets you use standard logging calls to output messages to SysInternals' DebugView utility.</p>
One-click Copy of CD/DVD for Windows (Python)
2010-03-16T11:35:23-07:00Jack Trainorhttp://code.activestate.com/recipes/users/4076953/http://code.activestate.com/recipes/577118-one-click-copy-of-cddvd-for-windows/
<p style="color: grey">
Python
recipe 577118
by <a href="/recipes/users/4076953/">Jack Trainor</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/shortcut/">shortcut</a>, <a href="/recipes/tags/utility/">utility</a>, <a href="/recipes/tags/windows/">windows</a>).
</p>
<p>CdCopy: Windows utility for copying contents of a CD/DVD to local hard disk with
most free space to a directory named for full name of CD/DVD.</p>
Win Services helper (Python)
2014-09-06T10:35:54-07:00Louis RIVIEREhttp://code.activestate.com/recipes/users/4035877/http://code.activestate.com/recipes/551780-win-services-helper/
<p style="color: grey">
Python
recipe 551780
by <a href="/recipes/users/4035877/">Louis RIVIERE</a>
(<a href="/recipes/tags/services/">services</a>, <a href="/recipes/tags/system/">system</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 4.
</p>
<p>A simple way to implement Windows Service.</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>
Python Program for Windows domain based machines to collect usefull information (admins- software installed) (Python)
2009-07-16T06:49:00-07:00mgarrana Garranahttp://code.activestate.com/recipes/users/4171135/http://code.activestate.com/recipes/576844-python-program-for-windows-domain-based-machines-t/
<p style="color: grey">
Python
recipe 576844
by <a href="/recipes/users/4171135/">mgarrana Garrana</a>
(<a href="/recipes/tags/group_policy_startup_script/">group_policy_startup_script</a>, <a href="/recipes/tags/know_local_administrators_domain_machines/">know_local_administrators_domain_machines</a>, <a href="/recipes/tags/microsoft_inventory_collection/">microsoft_inventory_collection</a>, <a href="/recipes/tags/python_scripts/">python_scripts</a>, <a href="/recipes/tags/software_inventory_domain_machines/">software_inventory_domain_machines</a>).
</p>
<p>this is a python program Python Program for Windows domain based machines to collect usefull information , this can be very customizable to the type of information you'd want to collect.
you can force it to run on all machines using group policy, and each machine would create a file in a specific folder ( for simplicity here , no need to go to a database at this level) with the machine name , and containing such information
for example , this program collects local administrators on the machine( can be very usefull in security assesments or securing the corporate ) , a list of all the software installed on the machine
also other general information like machine name ,current logged on user , system time at script run time and domain that this machine belongs to</p>
<p>i've ran it in practice and i was really amazed by the result , that i couldn't find with any other tool
once you get the idea ... you can go wild with your dreams and do anything you like
i've also written a backend parser which parses the results and prints out a report with the required results
this program needs python for win32 installed
the program uses windows registery , win32 api
if you will run this software by group policy , you don't have to install python and python for windows extenstions onto each clinet machine
there is a tool called py2exe which magically , complies the code into and exe and DLL files , that you can run the exe by group policy as a startup script
please excuse the qualtiy of the code , as i am not a programmer , i am sys admin</p>
subprocess.terminate() not always implemented (Python)
2009-02-25T10:45:01-08:00Gui Rhttp://code.activestate.com/recipes/users/4166241/http://code.activestate.com/recipes/576667-subprocessterminate-not-always-implemented/
<p style="color: grey">
Python
recipe 576667
by <a href="/recipes/users/4166241/">Gui R</a>
(<a href="/recipes/tags/process_management/">process_management</a>, <a href="/recipes/tags/subprocess/">subprocess</a>, <a href="/recipes/tags/terminate/">terminate</a>).
Revision 2.
</p>
<p>The new subprocess module brings clarity and simplicity over the popenXX() functions and os.spawnXX() functions, but some implementations don't have the subprocess.terminate() method, which is crucial for killing a spawned process. This workaround works on both POSIX and Windows.</p>
Searching .dll and .exe files in PATH (Python)
2014-10-06T09:22:53-07:00Michal Niklashttp://code.activestate.com/recipes/users/186902/http://code.activestate.com/recipes/576522-searching-dll-and-exe-files-in-path/
<p style="color: grey">
Python
recipe 576522
by <a href="/recipes/users/186902/">Michal Niklas</a>
(<a href="/recipes/tags/dll/">dll</a>, <a href="/recipes/tags/exe/">exe</a>, <a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/version/">version</a>, <a href="/recipes/tags/windows/">windows</a>).
Revision 7.
</p>
<p>Returns the pathnames of the file (.exe or .dll)
which would be loaded/executed in the current environment.
It uses some dirs from configuration (SystemDir, WindowsDir)
and dirs from PATH.</p>
<p>To obtain version info it uses code from:
<a href="http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/file/tip/win32/Demos/getfilever.py" rel="nofollow">http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/file/tip/win32/Demos/getfilever.py</a></p>
<p>Example of usage:</p>
<pre class="prettyprint"><code> c:\tools\pyscripts\scripts>which_dll.py libpq.dll
2008-06-09 02:58:26 167936 [b] c:\postgresql\8.3\bin\libpq.dll ver:8.3.3.8160
2008-03-17 01:47:50 167936 [b] c:\tools\libpq.dll ver:8.3.1.8075
2008-03-17 01:47:50 167936 [b] g:\public\libpq.dll ver:8.3.1.8075
trying to load "libpq.dll" ...
c:\postgresql\8.3\bin\libpq.dll loaded
</code></pre>
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>
Illustration: Writing a TappedIn.com calendar item from FeedDemon to Google Calendar (Python)
2009-01-03T17:13:46-08:00Bill Bellhttp://code.activestate.com/recipes/users/4168674/http://code.activestate.com/recipes/576604-illustration-writing-a-tappedincom-calendar-item-f/
<p style="color: grey">
Python
recipe 576604
by <a href="/recipes/users/4168674/">Bill Bell</a>
(<a href="/recipes/tags/blog_publisher/">blog_publisher</a>, <a href="/recipes/tags/feeddemon/">feeddemon</a>, <a href="/recipes/tags/google_calendar/">google_calendar</a>, <a href="/recipes/tags/tappedin/">tappedin</a>).
</p>
<p>This recipe is for reference purposes. It indicates how the FeedDemon RSS reader supplies information about a post to a blog publisher application under the default arrangements (ie, without specifying XML), and then how this information can be reformatted for a <a href="http://TappedIn.com" rel="nofollow">TappedIn.com</a> calendar item for submission to the Google Calendar. Nothing unusual but might be useful to people who use FeedDemon and want to record TappedIn sessions on Google (obviously).</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>
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>
a simple way to create and change your registry on windows (Python)
2008-02-24T08:37:05-08:00Pseudonym Pcrlth0nhttp://code.activestate.com/recipes/users/4127650/http://code.activestate.com/recipes/546543-a-simple-way-to-create-and-change-your-registry-on/
<p style="color: grey">
Python
recipe 546543
by <a href="/recipes/users/4127650/">Pseudonym Pcrlth0n</a>
(<a href="/recipes/tags/files/">files</a>).
</p>
Processor and performance matrix gathering (Python)
2008-01-11T02:24:08-08:00trevellyon newellhttp://code.activestate.com/recipes/users/4097787/http://code.activestate.com/recipes/542193-processor-and-performance-matrix-gathering/
<p style="color: grey">
Python
recipe 542193
by <a href="/recipes/users/4097787/">trevellyon newell</a>
.
</p>
<p>most people want to gather data about programs etc. most people will use perfmon. what happens if you want to gather data but have to sit on the machine and set up perfmon counters and such. This is the basis for people to write system information gathering programs/counters.</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>
Creating a single instance application (Python)
2006-02-22T06:37:05-08:00Dragan Jovelichttp://code.activestate.com/recipes/users/2787616/http://code.activestate.com/recipes/474070-creating-a-single-instance-application/
<p style="color: grey">
Python
recipe 474070
by <a href="/recipes/users/2787616/">Dragan Jovelic</a>
(<a href="/recipes/tags/threads/">threads</a>).
</p>
<p>Sometimes it is necessary to ensure that only one instance of application is running. This quite simple solution uses mutex to achieve this, and will run only on Windows platform.</p>