Jump to content
Sign in to follow this  

BlockInput issue?

Recommended Posts

Posted (edited)

I wrote a little script that sends a key into an app at random times. The idea is that I must be able to use my computer while this is being done hence the window switching.

As per the script below, it will:

  1. block user input
  2. save the current active window to a variable
  3. switch to the app window and wait until it is active
  4. send characters
  5. check whether the original active window still exists (and if it's not active) and if so switch back
  6. unblock user input

Opt("WinTitleMatchMode", 3)

While WinExists("app")
    Sleep(Random(15000, 22000))

Func Update()
    $title = WinGetTitle('')
    If WinExists($title) = True And WinActive($title) = False Then


What happens to me, though, is that from time to time my mouse disappears and and I can't use it until I do a CTRL + ALT + DEL which might indicate that there has been some issue unblocking the input. At first I thought that it might be because in my original script I wasn't checking for whether the original window still existed and it might have ceased to exist when the Update function wanted to switch back to the window. But even though I updated the script to check for that, it still "freezes" / hides the mouse from time to time.

The only thing that I can think off that might influence anything is that right when the Update function blocks my input I'm holding a specific key or mouse button, maybe a modifier key or something but I haven't been able to replicate it.

Any ideas?

Edited by Seminko

Share this post

Link to post
Share on other sites
Posted (edited)
26 minutes ago, JohnOne said:

Any reason why you cannot use 



I have been struggling with ControlSend for all my time coding in AutoIt.

The way I understand it is that you can only interact with windows which contain controls identifiable with the AutoIt Window Info tool. A good deal of applications do not have any specific identifiable controls.

Am I missing something?

EDIT: just tried the code below but doesn't work. I'm working with my employer's app and it seems it might have it blocked?

ControlSend("app", "", "", "{ESCAPE}")


Edited by Seminko

Share this post

Link to post
Share on other sites

Well I guess I figured it out. The issue is probably with WinWaitActive. The original active window for some reason disappears and WinWaitActive is blocking the function from finishing and unblocking user's input.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this