New user registration is currently disabled due to spam abuse / Регистрация новых пользователей в настоящее время приостановлена из-за злоупотреблений спаммерами

Workaround for scan popup functionality

General discussion

Workaround for scan popup functionality

Postby oversky » Mon Dec 19, 2011 7:28 am

Scan popup doesn't work with Firefox 4+, Chrome, and Opera.
As discussed in this thread, https://github.com/goldendict/goldendict/pull/26
it is hard to detect the word under the mouse cursor in different browsers.
Suggestion is to copy the word into the clipboard, and use the hotkey to translate the word in the clipboard.

The following ahk code can simplify the whole process, and make it almost as simple as the original scan popup.
1 Install AHK from http://www.autohotkey.com/
2 Save the following code as filename.ahk.
3 Execute the file you saved.
4 Open your browser, press Alt+Left mouse button on the word you want to look up.
5 The scan popup show up.

Don't bother to try Ctrl or Shift +LButton combo,
because these will make the browser choose wrong word when you want to lookup another word.
If you computer is slow, try to change the line "sleep, 250" to a higher value.
The code was tested in Firefox 7, Chrome 13, and Opera 11.6.

============= code start here ==================
!LButton::
{
Click 2
sleep, 250
Sendinput, {ctrl down}cc{ctrl up}
}
=============================================
oversky
 
Posts: 3
Joined: Mon Dec 19, 2011 5:40 am

Re: Workaround for scan popup functionality

Postby stayfi » Mon Dec 19, 2011 11:18 am

Hi,

Tested it, and it works fine on Firefox, will try it on a pdf file,
1. Lingoes "translate selected text" feature is awesome with "double click" left button, how to perform a translation with goldendict on double selecting a word?
2. it seems to work while lingoes is running...

thanks
stayfi
 
Posts: 16
Joined: Mon Dec 19, 2011 11:07 am

Re: Workaround for scan popup functionality

Postby chulai » Sun Jan 01, 2012 4:11 pm

Hi,

It didn't work for me under any program. It does open GoldenDict but it seems that it doesn't copy the text to the clipboard. Any idea?
chulai
 
Posts: 464
Joined: Sat Jan 08, 2011 10:11 pm

Re: Workaround for scan popup functionality

Postby stayfi » Sun Jan 01, 2012 6:21 pm

follow the instructions above, should work, u need only AHK.
stayfi
 
Posts: 16
Joined: Mon Dec 19, 2011 11:07 am

Re: Workaround for scan popup functionality

Postby wlhunag » Wed May 23, 2012 3:36 pm

stayfi wrote:follow the instructions above, should work, u need only AHK.

I just followed the instructions above, but it doesn't work, so I looked up the Official Autohotkey manual.
So I modified the script a little bit , as following

Code: Select all
!~LButton up::
ClipWait,3
Click 1
send ,^c
ClipWait,1
send,{Ctrl down}cc{Ctrl up}

return


The first line
Code: Select all
!~LButton up::

means Alt + Left Click

It works perfectly in the newest Google Chrome (Ver. 19.0.1084.46 m) and Adobe Acrobat Pro (10.1.3)
and in other applications in my PC (Win 7 ,64 bit).

I guess that maybe this kind of technique can partially solve the difficulty to detect the word under mouse cursor.
But it seems that there is no Autohotkey in Linux.........


By the way, if I have to read an webpage in english for a long time.I will edit the script as follow:

Code: Select all
~MButton up::
ClipWait,3
Click 1
send ,^c
;ClipWait,0
send,{Ctrl down}cc{Ctrl up}

return


(Once edit the script ,be sure to right click the green icon that shows H, and choose "Reload The Script")

The first line means click the middle button of mouse(some mouses have MButton), without pressing the Alt key.

SO I just have to click the MButton , and the popup window comes out~
Somewhat more conveniently.(I think it's annoying to press Alt key with my left hand)
wlhunag
 
Posts: 10
Joined: Wed May 23, 2012 3:07 pm

Re: Workaround for scan popup functionality

Postby chulai » Fri May 25, 2012 9:08 pm

I couldn't make it work with those 2 scripts either. But luckily I found that this script does work (uses Ctrl + double click so it select text in all browsers):

Code: Select all
^~LButton up::
{
   If (A_PriorHotkey != A_ThisHotkey OR A_TimeSincePriorHotkey > 500) {
      Return
   }
   clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
   Send ^c ;Ctrl + C
   ClipWait, 1  ; Wait for the clipboard to contain text.
   send,{Ctrl down}cc{Ctrl up}

   return
}
chulai
 
Posts: 464
Joined: Sat Jan 08, 2011 10:11 pm

Re: Workaround for scan popup functionality

Postby wlhunag » Mon Jun 04, 2012 2:38 pm

Hi, chulai:
Your script works for me.
But I don't know why my script doesn't work for you.
I use AutoHotkey - version 1.0.48.05 (latest) :?

Recently I compiled GD from Git in Linux Mint 13.
I found that the scan popup function supports double click a word in browsers.

But when I then compiled the newest GD in Win 7 (Enterprise 64bit) , the scan popup function still doesn't work in Chrome, even double click a word.

After some searching, I found a script that enable GD to work by double click in Chrome, Firefox and other applications that can select and copy words.

The following is the script:
Code: Select all
~LButton::

  Loop {
  LButtonDown := GetKeyState("LButton","P")
  If (!LButtonDown)
     Break
  }

WaitTime:=DllCall("GetDoubleClickTime")/1000
KeyWait, LButton, D T%WaitTime%
If errorlevel=0
   GoSub, Routine
Return

Routine:
   clipboard =
   send ,^c
   ClipWait,1
   send,{Ctrl down}cc{Ctrl up}
Return


I think it is more convenient , because I am too lazy to put my left finger upon the <Alt> or <Ctrl> key~ ;)

As a student in dental school in Taiwan, I have to study a lot of textbooks in English.
When I search a software to look up unfamiliar words, I found GoldenDict!
I think GD surpasses all other dictionary softwares.
I love GD very much!

ikm and chuli and all other developers
Thank you~!
wlhunag
 
Posts: 10
Joined: Wed May 23, 2012 3:07 pm

Re: Workaround for scan popup functionality

Postby chulai » Sat Jun 09, 2012 6:40 pm

I'm using the same exact version as you and this new script doesn't work for me either. Strange. Anyhow, I prefer to use double click with a modifier key like Ctrl or Alt. Just to avoid GoldenDict to popup everytime I want to select a word (I usually use the double clicking to select words).
chulai
 
Posts: 464
Joined: Sat Jan 08, 2011 10:11 pm

Re: Workaround for scan popup functionality

Postby chulai » Sat Jun 09, 2012 6:42 pm

wlhunag wrote:Recently I compiled GD from Git in Linux Mint 13.
I found that the scan popup function supports double click a word in browsers.

But when I then compiled the newest GD in Win 7 (Enterprise 64bit) , the scan popup function still doesn't work in Chrome, even double click a word.

After some searching, I found a script that enable GD to work by double click in Chrome, Firefox and other applications that can select and copy words.


Yes, scan popup does not work in browsers other than Internet Explorer. https://github.com/goldendict/goldendict/issues/29
chulai
 
Posts: 464
Joined: Sat Jan 08, 2011 10:11 pm

Re: Workaround for scan popup functionality

Postby wlhunag » Sun Jun 10, 2012 12:30 am

Thank you for your reply.
I read the thread.

I think using <Ctrl>CC in Chrome is quick enough in most cases. ;)
wlhunag
 
Posts: 10
Joined: Wed May 23, 2012 3:07 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 30 guests