setting the clipboard
Brett g Porter
BgPorter at NOartlogicSPAM.com
Mon Oct 29 21:49:58 EST 2001
"Peoter Veliki" <peoter_veliki at hotmail.com> wrote in message
news:6hnD7.320$MT2.19293225 at news.incc.net...
> I see there is a setClipboardText, but there is no getClipboardText. How
> can this be done using getClipboardData?
>
Here's a small script that gets whatever text is on the clipboard and uses
it to do a google query (I've got it aliased to WindowsKey+G -- very handy!)
import os
import urllib
import win32clipboard as clip
clip.OpenClipboard(0)
if clip.IsClipboardFormatAvailable(clip.CF_TEXT):
newText = clip.GetClipboardData(clip.CF_TEXT)
# format the query string, escaping out any URL-unsafe characters.
urlString = 'http://www.google.com/search?q="%s"' % urllib.quote(newText)
# ...this will launch the default browser on the search.
os.startfile(urlString)
clip.CloseClipboard()
More information about the Python-list
mailing list