Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have learned this script

#IfWinActive, ahk_exe chrome.exe
   #u::send ^t
#IfWinActive, ahk_exe notepad.exe
   #u::send ^n
#IfWinActive, ahk_exe notepad++.exe
   #u::send ^!s

So now, I can get the same key to do different actions in different programs. But what about one step further: Different actions in different URL:s in chrome.

For example, on Toggl.com I want ^!e to do action x, and on Checkvist.com I want ^!e to do action y.

I imagine doing something like

Send ^L
set clipboard to send ^c
Look if it matches with "toggl", if it does: do x.
Look if it matches with "checkvist", if it does: do y.
share|improve this question
#IfWinActive, ahk_exe chrome.exe
   ^!vk45:: ; crtl+alt+e
      WinGetTitle, winTitle, % "A"
      If winTitle~="^Toggl\s"
         TrayTip,, % "first action"
      Else If winTitle~="^Checkvist:\s"
         TrayTip,, % "second action"
      Else
         TrayTip,, % "third action"
      winTitle:=""
      Return

Or:

#IfWinActive, ahk_exe chrome.exe
   ^!vk45:: ; crtl+alt+e
      SendEvent, ^{vk4C} ; crtl+l
      clipContent:=ClipboardAll
      SendEvent, ^{Ins}
      ClipWait, .5
      If ErrorLevel
      {
         TrayTip, % "Error", % "Clipboard is empty!",, 3
         Clipboard:=clipContent
         Return
      }
      clipURL:=Clipboard
      Clipboard:=clipContent
      If clipURL~="toggl.com"
         TrayTip,, % "first action"
      Else If clipURL~="checkvist.com"
         TrayTip,, % "second action"
      Else
         TrayTip,, % "third action"
      clipURL:=""
      Return
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .