Window Focus

Discussions of applications and operating systems and any problems, tips or suggestions. Win XP, 9x/2k, Linux, NT, photo editing, Virus/Spyware help
Post Reply
User avatar
Pugsley
Posts: 7454
Joined: Mon Aug 19, 2002 11:54 pm
Location: NW Indiana
Contact:

Window Focus

Post by Pugsley »

I have a computer I set up that starts a few apps and i need one window on that machine to have focus after everything is started up. I don't want to have to log in or hook up a keyboard to do this so is there some software out there that looks at windows names and forces them to have focus? Or like some kind of mouse script that runs and clicks the window after so may seconds after boot? I only need to do it once as once its all started up its just a few windows displaying info.

I have a stick computer that runs winamp and ATCS Monitor and when ATCS Monitor starts it opens 2 windows and I want focus to be the larger window so that everything looks right. Its a Railroad Dispatchers display on a stick!

Picked up a Asus vivo stick and a 1080P 32" tv for $240. It all works great except that window focus issue.
User avatar
FlyingPenguin
Flightless Bird
Posts: 32773
Joined: Wed Nov 22, 2000 11:13 am
Location: Central Florida
Contact:

Re: Window Focus

Post by FlyingPenguin »

This batch file will work:

Code: Select all

echo (new ActiveXObject("WScript.Shell")).AppActivate("app name"); > focus.js
cscript //nologo focus.js
del focus.js
Replace "app name" with the title of the window (you need to keep the quotes). Spaces okay. Case is not important, and it acts as if a wildcard is on the end.

So for instance, if the title of the window is Moffsoft Calculator 2 (actually just tested this with that very window on my workstation - it's my go-to calculator), then "moffsoft" is really all you need, although it wouldn't hurt to spell out the entire window name to avoid possible name collisions.

So in my example for the Moffsoft Calculator the code looks like this:

Code: Select all

echo (new ActiveXObject("WScript.Shell")).AppActivate("Moffsoft Calculator 2"); > focus.js
cscript //nologo focus.js
del focus.js
"Turns out I’m 'woke.' All along, I thought I was just compassionate, kind, and good at history. "

Image
User avatar
Pugsley
Posts: 7454
Joined: Mon Aug 19, 2002 11:54 pm
Location: NW Indiana
Contact:

Re: Window Focus

Post by Pugsley »

I take it that batch will have to run later after the window is open? or will it do it when it sees that window if the batch opens first?

Thanks.
User avatar
Pugsley
Posts: 7454
Joined: Mon Aug 19, 2002 11:54 pm
Location: NW Indiana
Contact:

Re: Window Focus

Post by Pugsley »

Stupid question... Figured it out. Man configuring a new computer will wear you out if you haven't done it in a few years.
Post Reply