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 been using this wonderful piece of software for some time now, but for just a few basic things. So I'm wondering if the following would be possible:

  • to use different set of shortcuts for different applications - so one shortcut performs different actions in different places.

  • to make some form of modes for application, where you could use some switch (vim style) and this would change things the shortcat would do

  • if it would be possible to place some caption that indicates which mode you are using - little improvement of previous item

I thank everyone for their answers.

share|improve this question
up vote 1 down vote accepted

Point 1 seems solved. As to point 2 and 3, here is how you could do it; my code may not be very efficient, but it works:

#Persistent                   ;--This needs to come before any
SetTimer, IsActiveTimer, 20   ;--return in the script.

IsActiveTimer:  ;--Below comes what the timer does
if StateIsActive = 1
{
  MouseGetPos, Px, Py   ;--The below creates tooltip when active
  ToolTip, "State is: Active", Px+40, Py+50, 5
}
else
{
ToolTip,,,, 5  ;--Removes tooltip when not active
   }
return

!^#z::   ;--This is the hotkey that toggles the state
         ;--between active and not active.
If StateIsActive = 1
{
StateIsActive := 0
}
else
{
StateIsActive := 1
}
return

!^#a::  ;--Hotkey that types either Zerg or Borg
        ;--depending on active/not active, so that you
        ;--may automatically choose the right party in
        ;--your documents in any potential war
If StateIsActive = 1
{
Sendinput, Zerg
}
Else
{
Sendinput, Borg
}
return
share|improve this answer

Yes.

For different rules for different applications, look into #ifWinActive.

For example:

; Make Ctrl+PageUp and Ctrl+PageDown work in Safari
#ifWinActive ahk_class {1C03B488-D53B-4a81-97F8-754559640193}
^PgUp::Send ^+[
#ifWinActive ahk_class {1C03B488-D53B-4a81-97F8-754559640193}
^PgDn::Send ^+]

#ifWinNotActive ahk_class PuTTY
+Ins::Send ^v
#ifWinNotActive ahk_class PuTTY
+Del::Send ^x
#ifWinNotActive ahk_class PuTTY
^Ins::Send ^c

You right click on the AutoHotkey icon and right click Window Spy to figure out the value of the ahk_class.

Modes like in Vi seem to be possible too. Take a look at Kommand for example.

share|improve this answer
    
You don't need to repeat the same #IfWin directive before each line. The directive stays in effect until the next #IfWin directive is encountered. (From the #IfWinActive page Mikel linked to: The #IfWin directives are positional: they affect all hotkeys and hotstrings physically beneath them in the script. They are also mutually exclusive; that is, only the most recent one will be in effect.) – Bavi_H Dec 22 '10 at 1:34

to make some form of modes for application, where you could use some switch (vim style) and this would change things the shortcat would do

You can make use of the #If statement available in the current distribution of AutoHotkey_L (the one you are expected to download from the site). You can write something like this:

#If Winactive("window_name") and (Mode = Mode1)

F1::MsgBox, Mode1
::mode::Mode1

#If Winactive("window_name") and (Mode = Mode2)

F1::MsgBox, Mode2
::mode::Mode2

You can put bare #If at the end so as to finish all the conditionals.

What do you mean by ‘a caption’? You can make a small toolbar-like window with the name of the mode or an image and refresh it whenever you change the mode or with the help of a timer that tracks current mode.

share|improve this answer

You must log in to answer this question.

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