Introduction

An ultrasimple clipboard application that expects to find a French word on the clipboard and sends it for translation.

Put a shortcut to the script in a Win2K toolbar, or on the desktop if you want to use a keyboard shortcut. Then just highlight the word or phrase to be translated, copy it to the clipboard, then launch the script.

What Objects are Involved

Process Overview

Special Concerns

This is the place to list anything such as

Code Sample

   1 import wx
   2 from win32api import ShellExecute
   3 
   4 if wx.TheClipboard.Open():
   5     if wx.TheClipboard.IsSupported(wxDataFormat(wxDF_TEXT)):
   6         data = wx.TextDataObject()
   7         wx.TheClipboard.GetData(data)
   8         text = data.GetText().strip()
   9     wx.TheClipboard.Close()
  10     if not text:
  11         wx.MessageDialog(None,"No French word specified")
  12 else:
  13     wx.MessageDialog(None,"Can't open clipboard")
  14 
  15 ShellExecute(0, None, 'http://wordreference.com/fr/en/translation.asp?fren=%s' % text, None, 'c:/', 0)

Comments

Unfortunately depends on the MS Windows API. - wbell@mcmaster.ca

ReadClipboardTranslateFrench (last edited 2010-01-14 23:18:20 by 79-65-133-135)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.