Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Getting HTML from Windows clipboard

Get the code for class HtmlClipboard() by Phillip Piper here.

Usage
   1  
   2  >>> cb = HtmlClipboard()
   3  >>> cb.GetAvailableFormats()
   4  [49161, 49562, 49339, 49560, 49561, 13, 1, 49334, 49335, 49333, 49344, 49478, 49171, 16, 7]
   5  >>> cb.HasHtmlFormat()
   6  True
   7  >>> cb.GetFromClipboard()
   8  >>> cb.htmlClipboardVersion
   9  '0.9'
  10  >>> cb.GetFragment()
  11  '<p>Writing to the clipboard is <strong>easy</strong> with this code.</p>'
  12  >>> cb.GetSource()
  13  'http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474121'
  14  >>> 

You can also put a html fragment to the clipboard as well.
See more detials in the recipe.

Transfer files on windows network

From Fadly Tabrani's recipe.
You need his implementation of netcopy, netmove, netdelete.
pywin32 extension required.
   1  
   2  # Copy "c:\documents" folder/file to "c:\transferred" on host "w0001".
   3  netcopy('w0001', 'c:\\documents', 'c:\\transferred')
   4  
   5  # Move with account credentials.
   6  netmove('w0001', 'c:\\documents', 'c:\\transferred', 'admin', 'adminpass')
   7  
   8  # Delete with another account.
   9  netdelete('w0001', 'c:\\transferred', 'testdom\\user1', 'user1pass')

Playing sound in Windows

   1  
   2  >>> from winsound import *
   3  
   4  >>> f = "C:/Windows/Media/chimes.wav"
   5  >>> PlaySound(f, SND_FILENAME)
   6  
   7  >>> PlaySound("SystemExit", SND_ALIAS)

See documentation.

Find the "My Documents" folder on Windows

   1  
   2  from win32com.shell import shell
   3  df = shell.SHGetDesktopFolder()
   4  pidl = df.ParseDisplayName(0, None,  
   5      "::{450d8fba-ad25-11d0-98a8-0800361b1103}")[1]
   6  mydocs = shell.SHGetPathFromIDList(pidl)

Copied from Kevin Dangoor's blog here
http://www.blueskyonmars.com/2005/08/05/finding-a-users-my-documents-folder-on-windows/
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS