Jump to content

Recommended Posts

Posted

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") = False

Wend

WshShell.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}"


Posted

Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "devmgmt.msc"

While WshShell.AppActivate("Device Manager") = False

Wend

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

Posted
Set WshShell = CreateObject("WScript.Shell")

WshShell.Run "devmgmt.msc"

While WshShell.AppActivate("Device Manager") = False

Wend

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

That 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}");

Posted

@Mazin

Sorry, .js

It does work for .vbs though, which is what i interpreted. I don't use .js much.

Little mixup here?

Posted

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.

Posted

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.

Posted
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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...