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 offline translation with jDictionay

 
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 9:33 am    Post subject: Shift+Right-Click offline translation with jDictionay Reply with quote

Hello,
here the alternative to the online translation, I posted previously.
This scripts switches to the window of jDictionary (OpenSource Dictionary: http://jdictionary.sourceforge.net/), which has to be already started, and put the word, which was under the mouse when shift-right-clicked, in the edit mask and automatically starts the search.
You maybe have to adapt the coordinates of the edit mask at the end of the script, since shortcuts were not supported.
Cheers
Rudi

PS Please forgive my bad english Wink

Code:
;Translation English<=>German with jDictionary
#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

;jDirectory aktivieren
WinActivate ahk_class info.jdictionary.JDictionaryFrame
WinWaitActive ahk_class info.jdictionary.JDictionaryFrame

;Delete old entry
;Coordinates of the edit mask
MouseClick, L, 368, 198, 2
Send {Del}
SendRaw %Clipboard%

Send {Enter}
return
Back to top
View user's profile Send private message
savage



Joined: 02 Jul 2004
Posts: 207

PostPosted: Mon Feb 21, 2005 7:21 pm    Post subject: Reply with quote

Why don't you just do this?

Code:

;Translation English<=>German with jDictionary
#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

;If the program isn't running, run it
IfWinNotExist, ahk_class info.jdictionary.JDictionaryFrame
{
         Run, pathtojdictionary
}

;jDirectory aktivieren
WinActivate ahk_class info.jdictionary.JDictionaryFrame
WinWaitActive ahk_class info.jdictionary.JDictionaryFrame

;Delete old entry
;Coordinates of the edit mask
MouseClick, L, 368, 198, 2
Send {Del}
SendRaw %Clipboard%

Send {Enter}
return


That way the program runs if it's not already running?
Back to top
View user's profile Send private message AIM Address
rudolf.noe



Joined: 20 Feb 2005
Posts: 4

PostPosted: Tue Feb 22, 2005 8:58 pm    Post subject: Reply with quote

Hello savage,
thanks for your reply Smile
Your absolutly right one can do it. I was only a little bit too lazy to do it Wink
Here is the enhanced code. If jDirectory is not already running a short delay is necessary, since java needs a little time to fully build up the interface after the window is already active.
Cheers
Rudi

Code:

;Translation English German with jDictionary
#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

;If the program isn't running, run it
jDirectoryIsRunning := true
IfWinNotExist, ahk_class info.jdictionary.JDictionaryFrame
{
    jDirectoryIsRunning := false
    Run, pathofJDirectory\start.bat, pathofJDirectory
}

;jDirectory aktivieren
WinActivate ahk_class info.jdictionary.JDictionaryFrame
WinWaitActive ahk_class info.jdictionary.JDictionaryFrame

If (!jDirectoryIsRunning)
{
    Sleep 2000
}
;Delete old entry
;Coordinates of the edit mask
MouseClick, L, 368, 198, 2
Send {Del}
SendRaw %Clipboard%
Send {Enter}
return
Back to top
View user's profile Send private message
A.Fischer
Guest





PostPosted: Thu Feb 24, 2005 8:50 am    Post subject: Extension for keeping old Clipboard Reply with quote

Hello,

I have extend the script for saving the old clipboard content and restoring it after calling jDict.

Code:

;Translation English<=>German with jDictionary
#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
C_ClipboardPrev = %clipboard% ; Save old clipboard
Clipboard =
Send ^c
ClipWait 0.5

;If the program isn't running, run it
jDirectoryIsRunning := true
IfWinNotExist, ahk_class info.jdictionary.JDictionaryFrame
{
    jDirectoryIsRunning := false
    Run, pathofJDirectory\start.bat, pathofJDirectory
}

;jDirectory aktivieren
WinActivate ahk_class info.jdictionary.JDictionaryFrame
WinWaitActive ahk_class info.jdictionary.JDictionaryFrame

If (!jDirectoryIsRunning)
{
    Sleep 2000
}
;Delete old entry
;Coordinates of the edit mask
MouseClick, L, 368, 198, 2
Send {Del}
C_ClipboardStripped = %clipboard%  ; This will trim leading and trailing tabs & spaces.
clipboard = %C_ClipboardPrev%  ; Restore the original clipboard for the user.
SendRaw %C_ClipboardStripped%
Send {Enter}
return
Back to top
rudolf.noe



Joined: 20 Feb 2005
Posts: 4

PostPosted: Thu Feb 24, 2005 10:42 am    Post subject: Reply with quote

Hello A.Fischer,
thanks, good idea Smile
Cheers Rudi
Back to top
View user's profile Send private message
Display posts from previous:   
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