Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

#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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.