MSFN Forum: sendkeys - MSFN Forum

Jump to content



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

sendkeys Rate Topic: -----

#1 User is offline   wildman 

  • Group: Members
  • Posts: 2
  • Joined: 11-August 04

Posted 20 August 2004 - 07:44 AM

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


#2 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 20 August 2004 - 11:21 AM

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

#3 User is offline   mazin 

  • MSFN Addict
  • Group: Supreme Sponsor
  • Posts: 1,952
  • Joined: 12-January 04

Posted 20 August 2004 - 02:12 PM

MHz, on Aug 20 2004, 08:21 PM, said:

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)

Quote

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


#4 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 20 August 2004 - 11:34 PM

@Mazin

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

Little mixup here?

#5 User is offline   mazin 

  • MSFN Addict
  • Group: Supreme Sponsor
  • Posts: 1,952
  • Joined: 12-January 04

Posted 21 August 2004 - 12:24 AM

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.

#6 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 21 August 2004 - 12:35 PM

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.

#7 User is offline   mazin 

  • MSFN Addict
  • Group: Supreme Sponsor
  • Posts: 1,952
  • Joined: 12-January 04

Posted 21 August 2004 - 01:16 PM

MHz, on Aug 21 2004, 09:35 PM, said:

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.

save as .vbs said:

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.

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