wildman Posted August 20, 2004 Posted August 20, 2004 Can anyone tell me why sendkeys doesnt work, it opens the device manager, goes to the wireless network card but stops performing commands on the open Network card properties dialogue box. Is there anyway to change focus to it or something?Set WshShell = CreateObject("WScript.Shell")WshShell.Run "devmgmt.msc"While WshShell.AppActivate("Device Manager") = FalseWendWshShell.AppActivate "Device Manager"WshShell.SendKeys "{Tab}"WshShell.SendKeys "Network adpaters"WshShell.SendKeys "{Right}"WshShell.SendKeys "I"WshShell.SendKeys "I"WshShell.SendKeys "{ENTER}"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{RIGHT}"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{ENTER}"
MHz Posted August 20, 2004 Posted August 20, 2004 Set WshShell = CreateObject("WScript.Shell")WshShell.Run "devmgmt.msc"While WshShell.AppActivate("Device Manager") = FalseWendWshShell.AppActivate "Device Manager"WshShell.SendKeys "{Tab}"WshShell.SendKeys "Network adpaters" <======= (Fix Spelling with "adapters")WshShell.SendKeys "{Right}"WshShell.SendKeys "I"WshShell.SendKeys "I" <======= (Remove this)WshShell.SendKeys "{ENTER}"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{RIGHT}"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{ENTER}" I would assume that you are disabling a Network Adapter with this?Seems to look better if these 2
mazin Posted August 20, 2004 Posted August 20, 2004 Set WshShell = CreateObject("WScript.Shell")WshShell.Run "devmgmt.msc"While WshShell.AppActivate("Device Manager") = FalseWendWshShell.AppActivate "Device Manager"WshShell.SendKeys "{Tab}"WshShell.SendKeys "Network adpaters" <======= (Fix Spelling with "adapters")WshShell.SendKeys "{Right}"WshShell.SendKeys "I"WshShell.SendKeys "I" <======= (Remove this)WshShell.SendKeys "{ENTER}"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{RIGHT}"WshShell.SendKeys "{TAB}"WshShell.SendKeys "{ENTER}" I would assume that you are disabling a Network Adapter with this?Seems to look better if these 2That won't work, either!This JScript script MUST work. (save as .js)var WshShell = WScript.CreateObject("WScript.Shell");WshShell.Run("devmgmt.msc");WScript.Sleep(500);WshShell.AppActivate("Device Manager");WScript.Sleep(500);WshShell.SendKeys ("{Tab}");WScript.Sleep(500);WshShell.SendKeys ("n");WScript.Sleep(500);WshShell.SendKeys ("%{Right}");WScript.Sleep(500);WshShell.SendKeys ("{DOWN 2}");WScript.Sleep(500);WshShell.SendKeys ("{ENTER}");WScript.Sleep(1000);WshShell.SendKeys ("{TAB}");WScript.Sleep(500);WshShell.SendKeys ("d");WScript.Sleep(500);WshShell.SendKeys ("{TAB}");WScript.Sleep(500);WshShell.SendKeys ("{ENTER}");
MHz Posted August 21, 2004 Posted August 21, 2004 @MazinSorry, .jsIt does work for .vbs though, which is what i interpreted. I don't use .js much.Little mixup here?
mazin Posted August 21, 2004 Posted August 21, 2004 No!You still have two mistakes in your script.First: (in red)Set WshShell = WScript.CreateObject("WScript.Shell")Second:You haven't put a sleep interval. This is necessary because Device Manager takes time to refresh itself.NB: I used js, only, because I can support it if wildman asks more. My script should work as vbs, too. A few modifications are needed.
MHz Posted August 21, 2004 Posted August 21, 2004 If you put wildman's script into notepad and save it as VBScript. It almost works perfectly. Turning VBScript into JavaScipt is not a good solution at all.Please check out the syntax to "VBScript" in your favorites, in the footers of your posts.A couple of errors does not mean that VBScript should turn to JavaScript, for the sake of your ability of not being able to interpret the language.
mazin Posted August 21, 2004 Posted August 21, 2004 A couple of errors does not mean that VBScript should turn to JavaScript, for the sake of your ability of not being able to interpret the language.Do you think really I'm not able to write a VBScript? Well, here's a working VBS for my version of JS.Set WshShell = WScript.CreateObject("WScript.Shell")WshShell.Run "devmgmt.msc"WScript.Sleep(500)WshShell.AppActivate "Device Manager"WScript.Sleep(500)WshShell.SendKeys "{Tab}"WScript.Sleep(500)WshShell.SendKeys "n"WScript.Sleep(500)WshShell.SendKeys "%{Right}"WScript.Sleep(500)WshShell.SendKeys "{DOWN 2}"WScript.Sleep(500)WshShell.SendKeys "{ENTER}"WScript.Sleep(2000)WshShell.SendKeys "{TAB}"WScript.Sleep(500)WshShell.SendKeys "d"WScript.Sleep(500)WshShell.SendKeys "{TAB}"WScript.Sleep(500)WshShell.SendKeys "{ENTER}"And yes, even a single mistake should prevent a script completely from executing.
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