AutoHotkey Community

It is currently May 25th, 2012, 7:47 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: February 20th, 2005, 10:33 am 
Offline

Joined: February 20th, 2005, 8:15 am
Posts: 4
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2005, 8:21 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2005, 9:58 pm 
Offline

Joined: February 20th, 2005, 8:15 am
Posts: 4
Hello savage,
thanks for your reply :-)
Your absolutly right one can do it. I was only a little bit too lazy to do it ;-)
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 24th, 2005, 9:50 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2005, 11:42 am 
Offline

Joined: February 20th, 2005, 8:15 am
Posts: 4
Hello A.Fischer,
thanks, good idea :-)
Cheers Rudi


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Relayer and 5 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group