Jump to content
Sign in to follow this  
rjdegraff

WinActivate doesn't

Recommended Posts

rjdegraff

I have two apps that have to start automatically when the machine starts up (actually two instances of the same app with different parameters). I have a CMD file that runs the startup code in sequence.

StartVista.cmd

-----------------

cd "d:\vista\server import"

cscript StartServer.vbs

cd "d:\vista\server process"

cscript StartServer.vbs

The two vbScripts are identical except for the value of the variable "server". The first server instance always starts as expected, however, when the second instance starts up, the "Connection Dialog" window never gets activated. The window is displayed but it never gets focus. With the "Active Window Tool" running, even if I manually select the window, it still doesn't register as having focus.

StartServer.vbs

------------------

server = "Import Vista Data"

set wso = CreateObject("Wscript.Shell")

set aut = CreateObject("AutoitX3.Control")

wso.Run "..\exe\svr_app.exe",1,false

title = "Connection Dialog"

aut.Opt "WinTitleMatchMode",2

aut.WinWait title

aut.WinActivate title

aut.WinWaitActive title

aut.ControlSetText title,"","4207","svr_app_admin"

aut.ControlSetText title,"","4215","svr_app_admin"

aut.ControlClick title,"OK","1"

title = "Server Settings"

aut.WinWait title

aut.WinActivate title

aut.WinWaitActive title

aut.ControlClick title,"Manual","128"

aut.Sleep 1000

aut.ControlClick title,"OK","1"

aut.Sleep 2000

SetTitle "Operational Data Processor - Server - [status]",Server

Function SetTitle ( currtitle , newtitle )

on error resume next

wso.Run "cmdow.exe " & """" & currTitle & """" & " /REN """ & newtitle & """", 0, True

if err.Number <> 0 then err.Clear

End Function

Share this post


Link to post
Share on other sites
AutoChris

I have two apps that have to start automatically when the machine starts up (actually two instances of the same app with different parameters). I have a CMD file that runs the startup code in sequence.

StartVista.cmd

-----------------

cd "d:\vista\server import"

cscript StartServer.vbs

cd "d:\vista\server process"

cscript StartServer.vbs

The two vbScripts are identical except for the value of the variable "server". The first server instance always starts as expected, however, when the second instance starts up, the "Connection Dialog" window never gets activated. The window is displayed but it never gets focus. With the "Active Window Tool" running, even if I manually select the window, it still doesn't register as having focus.

StartServer.vbs

------------------

server = "Import Vista Data"

set wso = CreateObject("Wscript.Shell")

set aut = CreateObject("AutoitX3.Control")

wso.Run "..\exe\svr_app.exe",1,false

title = "Connection Dialog"

aut.Opt "WinTitleMatchMode",2

aut.WinWait        title

aut.WinActivate    title

aut.WinWaitActive  title

aut.ControlSetText title,"","4207","svr_app_admin"

aut.ControlSetText title,"","4215","svr_app_admin"

aut.ControlClick  title,"OK","1"

title = "Server Settings"

aut.WinWait        title

aut.WinActivate    title

aut.WinWaitActive  title

aut.ControlClick  title,"Manual","128"

aut.Sleep 1000

aut.ControlClick  title,"OK","1"

aut.Sleep 2000

SetTitle "Operational Data Processor - Server - [status]",Server

Function SetTitle ( currtitle , newtitle )

  on error resume next

  wso.Run "cmdow.exe " & """" & currTitle & """" & " /REN """ & newtitle & """", 0, True

  if err.Number <> 0 then err.Clear

End Function

<{POST_SNAPBACK}>

Methinks thou art posting on thy wrong forum!

Try Experts Exchange for vbscript help. If you wanted to convert your vbscript into AutoIt, then you would have been in the right place.

Share this post


Link to post
Share on other sites
MHz

Methinks thou art posting on thy wrong forum!

Try Experts Exchange for vbscript help. If you wanted to convert your vbscript into AutoIt, then you would have been in the right place.

<{POST_SNAPBACK}>

It is AutoItX3. Correct website, only wrong subforum.

@rjdegraff

Double check the case of the titles as AutoIt is case sensitve. It could be something simple.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.