I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ByeWind
Posts: 3
Joined: 13 May 2019, 03:29

I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?

13 May 2019, 03:37

I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?
I used the ControlClick command to click on the corresponding coordinates for "translate this page", but it failed. How to resolve it?
Snipaste_2019-05-13_16-33-24.png
Snipaste_2019-05-13_16-33-24.png (54.53 KiB) Viewed 1551 times
AviationGuy
Posts: 188
Joined: 17 Jan 2019, 10:13

Re: I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?

14 May 2019, 02:39

Hi there,

You can use ImageSearch

Code: Select all

^t::
FilePath:="C:\Path.png"
loop
	ImageSearch, FoundX, FoundY, 0, 0, A_Screenwidth, A_Screenheight, %FilePath%
Until !ErrorLevel
	MouseClick,, FoundX, FoundY
return
Hope this helps!
ByeWind
Posts: 3
Joined: 13 May 2019, 03:29

Re: I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?

14 May 2019, 07:53

AviationGuy wrote:
14 May 2019, 02:39
Hi there,

You can use ImageSearch

Code: Select all

^t::
FilePath:="C:\Path.png"
loop
	ImageSearch, FoundX, FoundY, 0, 0, A_Screenwidth, A_Screenheight, %FilePath%
Until !ErrorLevel
	MouseClick,, FoundX, FoundY
return
Hope this helps!
I can't test it now on the MAC. This method requires saving an image. It's not very rational.
In addition, How can I use AutoHotKey on my MAC?
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?

14 May 2019, 11:42

The popup window of the Chrome extension is a different window than the main window of Chrome, their hwnds are different. So if you're using ControlClick but not aware of this fact you probably did it wrong.

Example 1:

Code: Select all

F9::TranslateThisPage()

TranslateThisPage() {
	if !WinExist("ahk_class Chrome_WidgetWin_1")
		throw "chrome not found!"
	
	WinGetTitle, ExcludeTitle ; Omit WindowTitle makes AHK to use the last found window, this can also improve performance.
	ControlClick, x1757 y59,,,,, NA ; Click "Google Translate" extension icon

	; Wait another Chrome_WidgetWin_1 window with a different title (The extension window has no title)
	WinWait, % "ahk_class Chrome_WidgetWin_1",,, % ExcludeTitle
	
	ControlClick, x65 y75 ; Click "Translate This Page"
}
Example 2:
Using acc.ahk to click the "Google Translate" extension icon.
Spoiler
Last edited by tmplinshi on 14 May 2019, 16:44, edited 10 times in total.
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: I want to set the shortcut key for "translate this page" of Google translation plugin. How do I do it?

14 May 2019, 11:43

ByeWind wrote:
14 May 2019, 07:53
In addition, How can I use AutoHotKey on my MAC?
You can't. AutoHotkey is for Windows only.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mesutakcan, mexican scientist, mikeyww and 131 guests