Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Shift+Right-Click online translation with LEO


  • Please log in to reply
1 reply to this topic
rudolf.noe
  • Members
  • 4 posts
  • Last active: Feb 22 2005 08:59 PM
  • Joined: 20 Feb 2005
Hello,
with the following script you can query the online dictionary LEO (http://dict.leo.org) with a simple Shift-Right-Click over the word you do not know.
It should (hopefully ;-)) work with the IE and Firefox.
By setting the variable htmlString to another URL you can adapt this script for querying any other online dictionary. If you do this you also have to asign the variable titleSearchString a part of the tiltle of that online dictionary. This is nessecary for reusing always the same browser window for querying the dictionary.
Cheers
Rudi

;Translation English German with LEO 
#SingleInstance force

;Hotkey combination is Shift+RightMouseButton
+RButton::

;Wait for Shift key is released
KeyWait, Shift, T1

;Double Click to select the word under the mouse
MouseClick,L,,,2

;Clear the clipboard and copy to it
Clipboard = 
Send ^c
ClipWait 0.5
;LEO
;htmlString = http://dict.leo.org/?lp=ende&lang=de&searchLoc=0&search=%Clipboard%
;titleSearchString = LEO

;TU-Chemitz
htmlString = http://dict.tu-chemnitz.de/dings.cgi?lang=de&noframes=1&query=%Clipboard%
titleSearchString = Chemnitz

;How many FireFox-Windows are open?
WinGet, browserWins, List, ahk_class MozillaWindowClass
fireFoxOpen := false
if %browserWins%
{
    GoSub, f_showInFirefox
    return
}

;How many Leo IE-Windows are open?
WinGet, browserWins, List, ahk_class IEFrame
if %browserWins%
{
    GoSub, f_showInIE
    return
}
Run %htmlString%
return


f_showInIE:
    ;Is Leo Win already open
    leoWinFound := false
    browserWinCounter = 0
    SetTitleMatchMode 2
    WinGet browserId, ID, %titleSearchString%
    if %browserId%
    {
        WINACTIVATE ahk_id %browserId%
        WinWaitActive ahk_id %browserId%
    }
    else
    {
        Run IExplore
        WinWait ahk_class IEFrame
    }
    Send ^{Tab}
    Sleep 20
    SetKeyDelay 0
    SendRaw %htmlString%
    Send {Enter}
    SetKeyDelay 10
return

f_showInFirefox:
    WinActivate ahk_class MozillaWindowClass 
    WinWaitActive ahk_class MozillaWindowClass 
    WinGetActiveTitle firstActiveWindowTitle
    Gosub f_goThroughTabs
    if(!leoFound)
    {
        Send ^t
        Sleep 800
    }
    else
    {
        ;to focus the edit mask
        Send {F6}
    }
    ;Speed up a lit bit :-)
    SetKeyDelay 0
    Send %htmlString%
    Send {Enter}
    SetKeyDelay 10
return

f_goThroughTabs:
;MsgBox 1 %firstActiveWindowTitle%
;MsgBox 2 %activeTitle%
WinGetActiveTitle activeTitle
IfInString activeTitle, %titleSearchString%
{
    leoFound := true
    return
}
Send ^`t        
Sleep 100
WinGetActiveTitle activeTitle
;MsgBox 3 %activeTitle%
if(activeTitle==firstActiveWindowTitle) 
{
    leoFound := false
    return
}
Gosub f_goThroughTabs   
return


florian
  • Guests
  • Last active:
  • Joined: --
Very helpful!