Winactivate - inconsistent results between computers

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
timg11
Posts: 25
Joined: 10 Dec 2016, 14:09

Winactivate - inconsistent results between computers

06 Oct 2017, 08:16

I have a script that runs on two different Windows 10 / 64 computers, and is interacting with the same application on both. Meta-example:

#!x::
WinActivate TheProgram
Send somekeys...
....
Return

One one computer, the hotkey script using WinActivate works fine.

On the other system, the first time the hotkey for the script above is used, I see TheProgram activate and take focus. Then nothing happens. No keys are sent.
After that, the hotkey has no effect until the script is reloaded.

What are some potential differences that could cause this behavior?

Thanks!
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Winactivate - inconsistent results between computers

06 Oct 2017, 08:58

Try adding "WinWaitActive TheProgram" after the WinActivate line. It may be that it takes longer to activate on one computer than the other, so you're sending the keys before it actually becomes active.
timg11
Posts: 25
Joined: 10 Dec 2016, 14:09

Re: Winactivate - inconsistent results between computers

06 Oct 2017, 12:07

Thanks for the reply. I tried:

#!x::
WinActivate TheProgram
WinWaitActive TheProgram
Send somekeys...
....
Return


The function works once, and activates the window. But it appears no keys are sent. After that, the function does nothing until the script is reloaded.

I put a MsgBox after each statement. All three MsgBox's appear, including the one after Send. so the script is executing all the way.
But the program does not respond. So somehow the keys are not being sent from Send.
But I can use the keyboard, and the program responds to the keys normally?
Why would Send not work?
gregster
Posts: 8990
Joined: 30 Sep 2013, 06:48

Re: Winactivate - inconsistent results between computers

06 Oct 2017, 12:12

Perhaps it is an issue with user rights. Try running the script as admin and see what happens...
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Winactivate - inconsistent results between computers

06 Oct 2017, 14:36

Maybe a certain control needs to have focus, so simply activating the window is not sufficient. It might be helpful for you to tell us what keys you're trying to send and what your actual Send command line looks like in case there are any mistakes in that.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Giresharu, haomingchen1998 and 272 guests