DAT
Joined: 01 Dec 2008 Posts: 49 Location: UK
|
Posted: Wed Feb 24, 2010 8:04 pm Post subject: User interface for Oxford English Dictionary software |
|
|
This is pretty much a minority interest, but if you have the Oxford English Dictionary (Second Edition on CD-ROM, Version 4.0) installed on your computer, this script makes it easier to use for quick lookups.
To use the script, make sure that the OED option 'Bypass homepage on start-up' is ticked and that 'Look up words from other applications' is not ticked.
With the script running, you can highlight a word in an application and see its full OED definition by holding Alt and pressing the right-hand Shift key.
If oed.exe is already running the script activates the OED window, types the word into the 'entry list' search box, and you get the definition immediately. Repeating Alt-RghtShift but without highlighting a different word makes the window toggle between minimised and restored states.
If oed.exe is not already running, Alt-RghtShift launches it, and this adds a further 15s before the definition appears. A tooltip warns about the delay.
I included the script in my 'do everything' autohotkey.ahk script and it works fine in XP and Vista.
Note: The different input boxes on the OED window do not show any ClassNN information with the 'Active Window Information' application. The only way I could get the script to use the input box was to simulate clicking on a predefined location relative to the OED window using the Click command. Luckily the input box is at the top left of the window so its coordinates remain valid even if the window is resized.
| Code: | ;;;;;;;;;;;;;;;;;;;;;;;;
; Title: OpenOED
; By: DAT 23-08-2009
;
; Assumes Oxford English Dictionary (Second Edition on CD-ROM, Version 4.0)
; has been installed on the computer in the default location. Also assumes
; the OED option 'Look up words from other applications' is not ticked,
; and 'Bypass homepage on start-up' is ticked.
;
; When activated by the hotkeys, the script stores the first word of any
; highlighted text. It also starts OED.EXE if not already running. If stored
; word is unchanged from last activation, it toggles OED to minimized and
; back, but if selected word has changed, it restores the OED window
; and enters the new word.
;
~!RShift::Gosub , OpenOED ; Defines hotkeys as 'hold down Alt and press RightShift'.
; It's easy to change these to suit personal preferences.
OpenOED:
SearchTermOld := SearchTerm ; Save old value to see if it changes
ClipSaved := ClipboardAll ; Save clipboard content for later restore
sleep , 100 ; These delays seem to be required else it can be unreliable
Clipboard = ; Flush clipboard
Sleep, 100
SendEvent, ^c ; Save highlighted text to clipboard.
sleep , 100
SearchTerm := Clipboard ; Contains selected text
Clipboard := ClipSaved ; Restore Clipboard content
ClipSaved =
StringSplit, word_array, SearchTerm, %A_Space%
SearchTerm = %word_array1% ; save just the first word
StringLeft , SearchTerm , SearchTerm , 40 ; Reduce to realistic length
IfWinNotExist , ahk_class SWHXWindow ; Oxford English Dictionary
{
Run , C:\Program Files\OED v4.0\oed.exe , C:\Program Files\OED v4.0\
Tooltip , Loading OED - takes about 15s
WinWait , ahk_class SWHXWindow , , 120
tooltip
sleep , 100 ; OED window needs extra time to get ready for input
Gosub , EnterWord
Return
}
IfNotEqual , SearchTerm , %SearchTermOld% ; Do this if search word has altered.
{
WinActivate , ahk_class SWHXWindow
Gosub , EnterWord
Return
}
IfEqual , SearchTerm , %SearchTermOld% ; Search word unchanged, so just toggle OED window.
{
IfWinNotActive , ahk_class SWHXWindow
WinActivate , ahk_class SWHXWindow
Else
WinMinimize , ahk_class SWHXWindow
}
Return
EnterWord:
click 44, 83 ; Assumes CoordMode is set to default (ie, relative to active window)
SendInput , ^A%SearchTerm% ; Control-A selects contents of box ready for replacement by new.
Return
;;;;;;;;;;;;;;;;;;;;;; |
|
|