PDA

View Full Version : SendKeys help (W2K)



gerkspap
02-06-2003, 10:53 AM
I'm new to WHS so I'd appreciate any help. I'm trying to create a script to open my webcam's "monitor" application and start the "monitor" process. The keyboard shortcut to start the process is <CTRL><M>. The script below opens the application but does not start the "monitor" process.

'VBScript Activate Webcam
Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run """C:\Program Files\Creative\WebCam Monitor\Monitor.exe"""
WshShell.AppActivate ("WebCam Monitor")

WScript.Sleep 10000

WshShell.SendKeys "^"
WScript.Sleep 500
WshShell.SendKeys "M"

WScript.Quit


Any help would be appreciated.

ifym
02-07-2003, 05:53 AM
to hold down Control and the M key you have to use "^M" in quotes like that. just change this....

WshShell.SendKeys "^"
WScript.Sleep 500
WshShell.SendKeys "M"

to this ..
wshshell.sendkeys ("^M")

http://www.sometips.com/tips/scripts/168.htm
this is a good link for info on how to use sendkeys

gerkspap
02-08-2003, 07:35 AM
Hi,
Thanks for your help. I realized why the sendkeys command is not working...the window was not being activated. The keyboard shortcuts do not work when I run the program manually until I click on the window. Can you tell me how to "activate" the window in my script?

ifym
02-10-2003, 02:17 PM
alright well i dont think you need the () in appactivate. Try it like this ..

'VBScript Activate Webcam
Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.Run "C:\Program Files\Creative\WebCam Monitor\Monitor.exe"
WScript.Sleep 10000
WshShell.AppActivate "WebCam Monitor"
WshShell.SendKeys ("^m")
WScript.Quit

also notice i put the sleep after you call the program, because thats the time that it'll take for the program to open. i also took out the 2 sets of quotes in the run (not positive but i dont htikn you need it)That should work