Enable hotkey if specific Browser-URL is accessed

Get help with using AutoHotkey and its commands and hotkeys
Banayat
Posts: 10
Joined: 08 Jul 2018, 14:29

Enable hotkey if specific Browser-URL is accessed

18 Aug 2018, 08:52

Hi, I want to replace a mouse key originally set to webbrowsing backwards with my own function:

- enable hotkey if Chrome Browser is active and URL "www.google ..." has been typed into address bar.

I got the following code from TLM (Administrator) which I couldn't get to work though. See link below. The problem is that "IfWinActive" seems not to be able to recognize the Chrome Browser at all. What need to be done to make this one work?

https://autohotkey.com/board/topic/8778 ... dow-title/

Code: Select all

GroupAdd, MyGroup, ahk_class Chrome_WidgetWin_1 && GetWinText("www.google")

GetWinText(t) {
    WinGetText, wText, A
    Return RegExMatch( wText, "s)" t )

#IfWinActive ahk_group MyGroup
$XButton1::
   if A_PriorHotkey <> $XButton1
   {
      KeyWait, XButton1
      return
   }
   if A_TimeSincePriorHotkey > 400
   {
      KeyWait, XButton1
      return
   }
   Msplit()
Return
#IfWinActive

Msplit()
{
Tooltip Yes!
}
User avatar
BriHecato
Posts: 124
Joined: 18 Jul 2017, 07:17

Re: Enable hotkey if specific Browser-URL is accessed

19 Aug 2018, 15:50

Shouldn't the GetWinText function be before GroupAdd ?
Banayat
Posts: 10
Joined: 08 Jul 2018, 14:29

Re: Enable hotkey if specific Browser-URL is accessed

20 Aug 2018, 10:49

Maybe. I guess it does not interfere with other functions in the first place. No success on putting GetWinText to the end of script.
User avatar
jackdunning
Posts: 118
Joined: 01 Aug 2016, 18:17
Facebook: https://www.facebook.com/ComputorEdgeEBooks/posts
Contact:

Re: Enable hotkey if specific Browser-URL is accessed

20 Aug 2018, 16:53

I don't think that you can place a function in the GroupAdd command unless you use a forced expression operator. Maybe try this and forget the function:

GroupAdd, MyGroup, Google - Google Chrome
User avatar
jackdunning
Posts: 118
Joined: 01 Aug 2016, 18:17
Facebook: https://www.facebook.com/ComputorEdgeEBooks/posts
Contact:

Re: Enable hotkey if specific Browser-URL is accessed

20 Aug 2018, 17:15

Here's a test script:

Code: Select all

GroupAdd, MyGroup, Google - Google Chrome

#IfWinActive ahk_group MyGroup
^#g::
   MsgBox, It's Google!
Return

#IfWinActive
^#g::
  MsgBox It's not Google!
Return
User avatar
jackdunning
Posts: 118
Joined: 01 Aug 2016, 18:17
Facebook: https://www.facebook.com/ComputorEdgeEBooks/posts
Contact:

Re: Enable hotkey if specific Browser-URL is accessed

20 Aug 2018, 17:19

Or, if you only need it for Google:

Code: Select all

#IfWinActive Google - Google Chrome
^#g::
   MsgBox, It's Google!
Return

#IfWinActive

^#g::
  MsgBox It's not Google!
Return
Banayat
Posts: 10
Joined: 08 Jul 2018, 14:29

Re: Enable hotkey if specific Browser-URL is accessed

23 Aug 2018, 20:05

The Reason why I am using GroupAdd is that it's more than one window belonging to "#IfWinActive". Whenever I add more to it it does not work. Any Workaround?

Return to “Ask For Help”

Who is online

Users browsing this forum: Albireo, bazrrrr, mikeyww, PlumpSamurai, RubbeH, smbs, XShayanX and 49 guests