2
votes

I am trying to use the Autohotkey autocomplete script here: http://www.autohotkey.com/board/topic/60998-autocomplete-updated-26713/ but limit it to certain windows. Enclosing the entire script within #IfWinActive does not seem to work. I really like this completion script but would not want it showing up all over the place. Is there a way to limit the autocompletion to specific windows?

1
Please elaborate on your problem. How does the script work? #IfWinActive only applies for hotkeys and hotstrings. Putting it in front of a complex script will certainly almost always fail. Did you have a look at the source? What were your findings? - MCL
I am a bit new to the AHK world so please bear with me. The script uses a master wordlist against which it compares the current keystrokes to suggest the matches. Of course this is great for some applications. But this becomes obtrusive when I try to type in on some inconsequential places (like Start -> Run). - Sundar Venkataraman
Did you have a look at the source code? What were your findings? - MCL

1 Answers

2
votes

A quick study of the source code showed that every keypress results in a call of the Suggest subroutine. This seems to be a good place to check for the active window. I've implemented a minimal change in the source, you can check it out here.
First, you have to define which windows you want to exlude from the functionality, I achieved this by defining a window group:

GroupAdd, excludedWins, ahk_class CabinetWClass ; windows explorer
GroupAdd, excludedWins, ahk_class DV2ControlHost ; start menu search bar
GroupAdd, excludedWins, ahk_class ConsoleWindowClass ; console

Please note that I'm using Windows 7; maybe, the windows have other identifiers in other versions.

Second, you need to tell the Suggest subroutine to ignore these windows:

Suggest:
IfWinActive, ahk_group excludedWins
{
        return
}

It seems to work, but I only tested very superficially and didn't investigate the source code dependencies. Let me know how it works for you.