Problem with Keys & Mouse locked to one Window

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Craine
Posts: 2
Joined: 06 Dec 2022, 14:50

Problem with Keys & Mouse locked to one Window

Post by Craine » 06 Dec 2022, 15:02

Hi all!

I have an AHK program that controls several windows from several running applications. And based on hotkeys it will perform actions in those various windows. The entire amount of coding is considerable (so no point in pasting examples here). But the program works quite well.

Except that sometimes something odd happens and mouse and keyboard input become locked to one single window. All other Windows applications are still there. And those involved in the AHK program are responding properly to hotkeys. But I can't click on those other windows or even alt-tab to them. The mouse and keyboard focus remain on this one single window.

I have no idea what may be causing this. I have tried:
- With or without Critical On/Off. No change.
- With or without BlockInput On/Off. No change.
- Replace as much of the mouse clicks as possible to Send input. No change.
- With or without running as Admin. No change.
- Changes to SetMouseDelay, SetKeyDelay. No change.
- I have tried to isolate the cause. But the random nature of it makes that very difficult.

Does anybody have an idea what may be causing this?
Or something that can be done to force the release of keyboard and mouse back to normal operation?

Thank you!

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Problem with Keys & Mouse locked to one Window

Post by mikeyww » 06 Dec 2022, 15:25

Welcome to this AutoHotkey forum!
no point in pasting examples here
I would like to disagree with you here: one can always guess, but posting your script, or a similar script demonstrating your specific problem when that script is run, could help in narrowing down the possibilities!

1. Post the script that does not work as expected when the script is run.
2. State the overall goal of the script.
3. Give a specific example-- your description-- of what actually happens, and what should happen instead, when this script is run.

Craine
Posts: 2
Joined: 06 Dec 2022, 14:50

Re: Problem with Keys & Mouse locked to one Window

Post by Craine » 06 Dec 2022, 15:45

Uhm...the entirety of this program consists of well over 5000 lines of AHK code, and some 30 supporting files.
It is a framework I wrote myself in OOP style (as much as one can in AHK), with foundational functions like Logging, File IO, Window management, GUI management, String/Datetime support. On top of this framework is specific program code to manage the several target windows, respond to hotkeys. And all of this in as best of a threaded manner I could do (time sliced really).

I have no idea where in all this is whatever is causing my problem. As I have been unable to isolate it.

What happens is that I have 4 applications open. I work in one of them, press certain hotkeys, at which point the AHK code starts switching to the other windows in succession and push buttons to start functions in those apps. That goes fairly quickly, through 4 windows in less than a second, then repeated until done.
This works fine...for a while.
Then at some random point the window I work in is the only one still responding, and all other applications (including ones not managed by AHK) are not longer accessible by mouse or keyboard or things like alt-tab.

The only other app still responding is the Windows Task Manager. Then I can use Task Manager to kill AHK at which point all applications are accessible again.

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Problem with Keys & Mouse locked to one Window

Post by mikeyww » 06 Dec 2022, 16:05

OK. My imagination about your script's contents is too limited! Others here may have a better idea. Best of luck.

In case helpful: https://www.autohotkey.com/docs/Scripts.htm#debug

Post Reply

Return to “Ask for Help (v1)”