MSFN Forum: vbs script help required - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

vbs script help required help me with this script Rate Topic: -----

#1 User is offline   Sheriff 

  • Group: Members
  • Posts: 6
  • Joined: 16-April 07

Posted 23 April 2007 - 02:25 PM

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 WshShell
Set 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}")


#2 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 23 April 2007 - 03:33 PM

View PostSheriff, on Apr 23 2007, 10:25 PM, said:

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 WshShell
Set 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.

Quote

 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


#3 User is offline   Bezalel 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 591
  • Joined: 11-October 05

Posted 23 April 2007 - 04:46 PM

View PostSheriff, on Apr 23 2007, 04:25 PM, said:

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 WshShell
Set 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.

#4 User is offline   jcarle 

  • MSFN Master
  • Group: Developers
  • Posts: 2,569
  • Joined: 14-August 04

Posted 23 April 2007 - 08:15 PM

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.

#5 User is offline   [deXter] 

  • The Lord of the Scripts
  • PipPipPip
  • Group: Members
  • Posts: 308
  • Joined: 08-May 04

Posted 23 April 2007 - 09:45 PM

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 100
Loop

This will wait till the "Regional..." window is open and active.

This post has been edited by [deXter]: 23 April 2007 - 09:46 PM


#6 User is offline   kelaniz 

  • Junior
  • Pip
  • Group: Members
  • Posts: 76
  • Joined: 27-December 06

Posted 24 April 2007 - 02:09 AM

View Post[deXter], on Apr 23 2007, 10:45 PM, said:

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
 Loop

This 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

#7 User is offline   [deXter] 

  • The Lord of the Scripts
  • PipPipPip
  • Group: Members
  • Posts: 308
  • Joined: 08-May 04

Posted 24 April 2007 - 04:08 AM

View Postkelaniz, on Apr 24 2007, 02:09 AM, said:

View Post[deXter], on Apr 23 2007, 10:45 PM, said:


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
 Loop

This 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



var 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)

#8 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 24 April 2007 - 08:19 AM

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.

Quote

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);


#9 User is offline   Yzöwl 

  • Wise Owl
  • Group: Super Moderator
  • Posts: 4,195
  • Joined: 13-October 04
  • OS:Windows 7 x64

Posted 24 April 2007 - 08:35 AM

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);
;)

#10 User is offline   jcarle 

  • MSFN Master
  • Group: Developers
  • Posts: 2,569
  • Joined: 14-August 04

Posted 24 April 2007 - 08:42 AM

View Postkelaniz, on Apr 24 2007, 04:09 AM, said:

View Post[deXter], on Apr 23 2007, 10:45 PM, said:


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
 Loop

This 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

Wouldn't making a silent installer be easier?

#11 User is offline   gunsmokingman 

  • MSFN Master
  • Group: Super Moderator
  • Posts: 2,020
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 24 April 2007 - 12:42 PM

View PostYzöwl, on Apr 24 2007, 04:35 PM, said:

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 it
a habbit that I have for doing VBS to Cmd. The messagebox would
not appear until the cmd session was over.

This post has been edited by gunsmokingman: 24 April 2007 - 12:44 PM


#12 User is offline   kelaniz 

  • Junior
  • Pip
  • Group: Members
  • Posts: 76
  • Joined: 27-December 06

Posted 25 April 2007 - 04:18 PM

View Postjcarle, on Apr 24 2007, 09:42 AM, said:

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy