Author Topic: focus lost immediatly after Displaying window  (Read 2677 times)

ErikderFreak

  • Newbie
  • *
  • Posts: 14
focus lost immediatly after Displaying window
« on: April 23, 2021, 03:29:34 PM »
When I use the display window function to switch to a window it immediatly loses focus.
This seems to only occure when I have VoiceAttack open as a window, but it is still annoying.
I can't test new things without minimizing va to tray and I can't have it open to look at what the log says.
Is there a way to prevent this from happening?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: focus lost immediatly after Displaying window
« Reply #1 on: April 23, 2021, 03:30:40 PM »
Are there any other actions in your command? Do you have the "Set command to target this window" option enabled?

ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #2 on: April 23, 2021, 06:51:38 PM »
This is one example (attached screenshot).
It doesn't matter if I have "Send command to this target" on or off, if VA is open, the League client will get out of focus and the mouse movement will occur on the window that was last in focus instead of the league client.
It wont even always be the VA window, it also can be like for example the firefox browser, if that was the last thing in focus before.
It's like it "alt tabs" back to the last in focus and then executes the mouse movement and click.
But all that only if VA is open as a window and not hid as tray.
It's so strange.

If I put "Stop command if target window focus lost" on, the command will cancel cause it got out of focus.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: focus lost immediatly after Displaying window
« Reply #3 on: April 23, 2021, 07:05:19 PM »
Do you have VoiceAttack set to be "Always on Top"?

Does this happen with any other target applications?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: focus lost immediatly after Displaying window
« Reply #4 on: April 23, 2021, 07:39:48 PM »
Just shooting from the hip - I would try putting a short pause between the actions:

Focus window
Pause 1 second
Move mouse to x, y
Pause 1 second
Click


It could be that your actions are occurring too quickly for the app to react.

If that works, try playing with different pause values to see what works best.



Edit -

Also, in the 'Display Window' action, there's 'Pause up to x seconds for the window/process to be available'.  That might be the missing piece, as VA is executing your action and immediately going on to the next action without waiting around (as it's instructed to do).


ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #5 on: April 23, 2021, 10:21:16 PM »
Where do I set it to be not always on top? (I don't think thats the problem, cause it also switches back to other programs, as long as VA is open as a window)

Yes happens with other applications, league client just was an example.

Tried with pause times, still same thing.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: focus lost immediatly after Displaying window
« Reply #6 on: April 23, 2021, 10:26:08 PM »
The "Always on Top" option is in the context menu for the main window's title bar. Right-click the title bar, or click the VoiceAttack logo in the top left corner.


Does the target application retain focus if you use a command only containing a "Perform a Window Function" action?

Are you using any third-party plugins? Are any command running in the background?

iceblast

  • Sr. Member
  • ****
  • Posts: 372
Re: focus lost immediatly after Displaying window
« Reply #7 on: April 24, 2021, 07:10:35 PM »
Under perform a Windows function to display window.

I would use Show, instead of Normal. For me, Normal always takes the window out of maximize mode.

I had a similar problem, and unchecking Set command to target this window solved it for me.

You could also put a little delay, and then check if the Active windows is correct, and if not, display window again, Like this.

Code: [Select]
Display window 'League of Legends' as [Show]
Pause 0.5 seconds
Begin Text Compare : [{ACTIVEWINDOWTITLE}] Does Not Equal 'League of Legends'
    Display window 'League of Legends' as [Show]
End Condition
Move mouse to x, y
Pause 0.5 seconds
Left Click


ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #8 on: April 25, 2021, 10:22:06 AM »
Ok so heres a new problem. The whole thing just happens sometimes and some other time not, so I am currently in the process of looking what causes the change to then troubleshoot the rest :D

VA is not always on top

I changed it to show, but I don't know if it changes something cause it workes fine atm.

I turned every other program or process off. (except nvidia)

I'm gonna look if it stays fixed now with the "show" instead of "normal". If it breaks again im gonna write here again.

Thx for all the help and ideas!

ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #9 on: April 26, 2021, 08:12:49 AM »
I just found out what the problem is (well one of them)
So I have also this script (attached screenshot)

It works as intended, but ONLY if I have opened the LCore.exe my self at least once and clicked it at least once after starting my PC.
If I just start my PC and try the command, without opening it manually, it will get out of focus immediately.

Any ideas why that could be?

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: focus lost immediatly after Displaying window
« Reply #10 on: April 26, 2021, 08:40:10 AM »
Can you post a screenshot of your, 'Run an application' screen as it stands in that command?

ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #11 on: April 26, 2021, 11:41:34 AM »
Here

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2824
Re: focus lost immediatly after Displaying window
« Reply #12 on: April 26, 2021, 11:57:27 AM »
Check the box, 'Wait until launched application is started before continuing' and also, 'Set command to target launched application'.

What is happening is you are launching the application and then immediately invoking commands against a process that hasn't had a chance to start yet.


ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #13 on: April 26, 2021, 01:45:07 PM »
OK, tried with both on.
Still same problem.
It works fine when I opened it manually before, but otherwise not.

Just to note, the L-Core software runs as soon as I start windows.
I use the "Run-application" because it is minimized as system tray and can't be accessed by the "display window" function.

ErikderFreak

  • Newbie
  • *
  • Posts: 14
Re: focus lost immediatly after Displaying window
« Reply #14 on: April 28, 2021, 02:26:40 PM »
So I still don't know why it happens, but I found a workaround.

I just opened the programm and moved it to a specific position.
After that I made a mouse movement with screen coordinates instead of window coordinates.