Sheriff Posted April 23, 2007 Share Posted April 23, 2007 I need somebody to help me with this vbs, here i am running the regional setting and then the program wait 7 sec then click tab 4 times then enter.I want the program not to wait 7 sec, but to wait till the regional setting runs (Do while loop) but how, is there is running process?Dim WshShellSet WshShell = WScript.CreateObject("WScript.Shell")WshShell.Run "control.exe intl.cpl,SW_SHOWNORMAL,False"WScript.Sleep(7000)WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{enter}") Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 23, 2007 Share Posted April 23, 2007 I need somebody to help me with this vbs, here i am running the regional setting and then the program wait 7 sec then click tab 4 times then enter.I want the program not to wait 7 sec, but to wait till the regional setting runs (Do while loop) but how, is there is running process?Dim WshShellSet WshShell = WScript.CreateObject("WScript.Shell")WshShell.Run "control.exe intl.cpl,SW_SHOWNORMAL,False"WScript.Sleep(7000)WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{enter}")I sent you a pm on how to do this, but for other members hers is the shorten code. Dim Act :Set Act = CreateObject("Wscript.Shell") Dim App :App = Act.ExpandEnvironmentStrings("%Windir%\System32\intl.cpl") Dim Key :Key = Array("{tab}","{tab}","{tab}","{tab}","{Enter}") Dim StrK Act.Run("control.exe " & App),10,False For Each StrK In Key Act.AppActivate(App) WScript.Sleep 7000 Act.SendKeys(StrK) Next Link to comment Share on other sites More sharing options...
Bezalel Posted April 23, 2007 Share Posted April 23, 2007 I need somebody to help me with this vbs, here i am running the regional setting and then the program wait 7 sec then click tab 4 times then enter.I want the program not to wait 7 sec, but to wait till the regional setting runs (Do while loop) but how, is there is running process?Dim WshShellSet WshShell = WScript.CreateObject("WScript.Shell")WshShell.Run "control.exe intl.cpl,SW_SHOWNORMAL,False"WScript.Sleep(7000)WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{tab}")WshShell.SendKeys ("{enter}")I'm not sure what you're trying to accomplish. It looks like you are just opening the applet and then canceling it. If this is what you are doing you can just send the {esc} key without having to worry that futere versions of the applet will have a different layout. Link to comment Share on other sites More sharing options...
jcarle Posted April 24, 2007 Share Posted April 24, 2007 It's a hell of an odd way to approach this... why don't you use a more reliable method, like changing a registry key, instead of using key output, which can be very unreliable and unpredictable. Link to comment Share on other sites More sharing options...
[deXter] Posted April 24, 2007 Share Posted April 24, 2007 (edited) I agree with jcarle. You shouldn't be using SendKeys in the first place, you should directly set the appropriate registry entries.Exactly what is it that you want to change? Perhaps we could provide you the appropriate registry values.Anyways, as an answer to your original question as to how to wait till a window exists, use this code:Do Until(WshShell.AppActivate ("Regional and Language Options")) = True WScript.Sleep 100LoopThis will wait till the "Regional..." window is open and active. Edited April 24, 2007 by [deXter] Link to comment Share on other sites More sharing options...
kelaniz Posted April 24, 2007 Share Posted April 24, 2007 Anyways, as an answer to your original question as to how to wait till a window exists, use this code:Do Until(WshShell.AppActivate ("Regional and Language Options")) = True WScript.Sleep 100 LoopThis will wait till the "Regional..." window is open and active.Anyone know the way to accomplish this same wait in JScript? I've got a pile of ancient apps and utilities I have to install this way. They're also installed on boxes with widely varying speeds (Think VIA 800MHz to AMD ~3GHz.) Setting a reasonable sleep time fails if there's a delay. And setting it high enough for the slowest box makes all the other setups painfully slow. Kel Link to comment Share on other sites More sharing options...
[deXter] Posted April 24, 2007 Share Posted April 24, 2007 Anyways, as an answer to your original question as to how to wait till a window exists, use this code:Do Until(WshShell.AppActivate ("Regional and Language Options")) = True WScript.Sleep 100 LoopThis will wait till the "Regional..." window is open and active.Anyone know the way to accomplish this same wait in JScript? I've got a pile of ancient apps and utilities I have to install this way. They're also installed on boxes with widely varying speeds (Think VIA 800MHz to AMD ~3GHz.) Setting a reasonable sleep time fails if there's a delay. And setting it high enough for the slowest box makes all the other setups painfully slow. Kelvar WshShell = WScript.CreateObject("WScript.Shell");WshShell.Run("control.exe intl.cpl,SW_SHOWNORMAL,False");do{ WScript.Sleep(100);}while (!(WshShell.AppActivate("Regional and Language Options")));B) Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 24, 2007 Share Posted April 24, 2007 Depending on the app that he running a loop is not always needed.This runs Cmd promt hidden then when it finished the messagebox appears.var Act = WScript.CreateObject("WScript.Shell");Act.Run("%Comspec% /c @Echo Off && ping -n 4 127.0.0.1>nul",0,true);Act.Popup("Completed Ping Cmd",7,"End Cmd",4128); Link to comment Share on other sites More sharing options...
Yzöwl Posted April 24, 2007 Share Posted April 24, 2007 Being pedantic, if the cmd window is being run hidden, then why bother turning echoing off and redirecting output.Act.Run("%Comspec% /c ping -n 4 127.0.0.1",0,true); Link to comment Share on other sites More sharing options...
jcarle Posted April 24, 2007 Share Posted April 24, 2007 Anyways, as an answer to your original question as to how to wait till a window exists, use this code:Do Until(WshShell.AppActivate ("Regional and Language Options")) = True WScript.Sleep 100 LoopThis will wait till the "Regional..." window is open and active.Anyone know the way to accomplish this same wait in JScript? I've got a pile of ancient apps and utilities I have to install this way. They're also installed on boxes with widely varying speeds (Think VIA 800MHz to AMD ~3GHz.) Setting a reasonable sleep time fails if there's a delay. And setting it high enough for the slowest box makes all the other setups painfully slow. KelWouldn't making a silent installer be easier? Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 24, 2007 Share Posted April 24, 2007 (edited) Being pedantic, if the cmd window is being run hidden, then why bother turning echoing off and redirecting output.Act.Run("%Comspec% /c ping -n 4 127.0.0.1",0,true);That was just a example of waiting for something to finish, plus ita habbit that I have for doing VBS to Cmd. The messagebox would not appear until the cmd session was over. Edited April 24, 2007 by gunsmokingman Link to comment Share on other sites More sharing options...
kelaniz Posted April 25, 2007 Share Posted April 25, 2007 Wouldn't making a silent installer be easier?Definitely. 99% of the stuff I install, I've managed to tweak a way to do silently. But there's a few things, specifically apps (usually older) that *require* user input, newer apps that can't be made silent (Eudora 7 Pro), apps that I want to be registered/activated and configured (Photoshop CS2), and things that aren't supposed to be silent, like Windows recovery console. I've managed to get everything silent so far, but the global sleep did become a problem on the slower boxes. This hopefully fixes that. Kel Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now