Jump to content

window focus problem from CMD launcher


Recommended Posts

I compiled a script to run a program and send some text to it. It works great if launched manually, but when I try to launch it from a looping batch file, the program comes up but is out of focus. I've tried a few different things to bring it into focus, but it remains unfocused.

I'm running it on WinServ08 box.

None of these seem to work to bring the window into focus.

$PID = Run("theprogram.exe")
WinSetState("program title","",@SW_ENABLE)
WinActive("program title")
WinSetOnTop ("program title","",1)
WinWaitActive("program title")

I'm sure it has to do with the program being launched from CMD batch file, but I'm not sure what to do at this point.

Link to comment
Share on other sites

The Sleep() command did NOT fix the problem as thought.

This is what I'm thinking: I'm running this on WinServer08, and the focus window seems to work fine when I'm looking at it via Remote Desktop, but when I end the remote session and it runs, the script gets stuck on WinWaitActive(). When I tunnel back in, there is NO active windows - I can see it but no windows has focus. When I click on the windows, the script then continues and completes.

So, I'm thinking that it has something to do with the security services in WinServer that is preventing the windows from obtaining focus. If you think about it, why should it? The station is effectively "locked". But batch command files seems to run ok.

Not sure if there's a workaround for this. :D

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...