AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Shift+Right-Click online translation with LEO

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
rudolf.noe



Joined: 20 Feb 2005
Posts: 4

PostPosted: Sun Feb 20, 2005 7:54 am    Post subject: Shift+Right-Click online translation with LEO Reply with quote

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 Wink) 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

Code:

;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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group