Scripts works fine until I switch application windows.

Get help with using AutoHotkey and its commands and hotkeys
Posts: 59
Joined: 26 Feb 2014, 01:37

Scripts works fine until I switch application windows.

10 May 2014, 13:26

I can't figure this out.

I have a script that contains a bunch of simple replacements like this


These are a block of code inside a script that also contains hot key commands. These were mostly working fine. Sometimes I would notice that these replacement pairs stopped working, even though other commands in that script, as well as in other concurrently running scripts, would continue to work. I didn't think much of this, and would just reload the script.

It turns out that if I load the script, these replacement pairs work fine in a given window, but after switching to another window, they will not work in that window AND they will no longer work in the window they were just working in when I switch back, BUT other code in the same .ahk script continues working.

To test, I removed these pairs and put them in a separate .ahk script of their own, loaded only that one script, and found the same thing was happening: they will work in the first window go to immediately after the load, but if all I do is switch to another window and immediately switch back to the one they were just working finer in, they don't work at all. It doesn't matter what the first program is -- it will work in it, and it doesn't matter what the program I switch to is -- it's the switching itself that is causing the problem.

Then I discovered that this only happens when I switch windows using the Alt+Tab combination. If I switch away and then switch back using the mouse, everything works as expected. But if either of those switches is done with the keyboard, those commands stop working, while other hot key lines I added to the the script still work.

It's probably something obvious, but not to me.

Does anyone have any idea what would cause this?

Thanks much!
Posts: 59
Joined: 26 Feb 2014, 01:37

Re: Scripts works fine until I switch application windows.

14 May 2014, 00:02

Thanks for the reply. Pressing left shift didn't fix it. But I figured out what it was.

I am using an alternative for Alt+Tab window switching, called VistaSwitcher. And that was causing it. It was right around the time I started using that that I noticed that the ahk script was only working intermittently. When I don't run that utility, the AHK script works as expected.

Return to “Ask For Help”

Who is online

Users browsing this forum: anv, DaveT1, effel, MarcelDeZaadcel, Rohwedder, rpnfan and 49 guests