1.

Solve : VBScript not working?

Answer»

I'm using a real basic sendkeys script to create a new file within a program I use on a regular basis. When I first created this script it worked perfectly the first 2 or so times I tried clicking on the icon. Then I tried playing around with creating a shortcut with a combination hotkey that just wouldn't work for me. I deleted the shortcut but now the orginal scripts will not work. I tried creating a new one with the same code but still won't work.

Here is the Code:
Code: [Select]set wshshell = wscript.CreateObject("wscript.shell")
wshshell.AppActivate "Point"
WshShell.SendKeys "ALT f n l p"
As you can see it's very simple but not sure why it's not WORKING... am I missing something?http://msdn.microsoft.com/en-us/library/8c6yea83%28VS.85%29.aspx

the proper sendkeys string would be:

"%fnlp"Quote from: BC_Programmer on March 20, 2010, 09:15:47 AM

http://msdn.microsoft.com/en-us/library/8c6yea83%28VS.85%29.aspx

the proper sendkeys string would be:

"%fnlp"

Okay after reading the link you posted that makes sense..... but it's still not working when I double click on the .vbs file, however, when I create a batch file to run this vbs file it works and that's all I really care about because I will be running 3 scripts total from the batch file. THANKS for the link. Looks like I'll be doing some reading on that today. BC - sometimes the file works and sometimes it doesn't. Without actually being here to see what is going on do you have any ideas on why it doesn't enter that string of keys correctly?

This happens whether I'm clicking on the actual .vbs file or if I use the .bat file I created.

Code: [Select]set wshshell = wscript.CreateObject("wscript.shell")
wshshell.AppActivate "Point"
WshShell.SendKeys "%fnlp"
There was a sample script on the link you posted that had "Sleep 100" in the code. I'm assuming this some kind of pause maybe in mili-seconds. Do I NEED to have some sort of pause inbetween each keystroke?Quote from: Medaitor on March 20, 2010, 10:30:46 AM
There was a sample script on the link you posted that had "Sleep 100" in the code. I'm assuming this some kind of pause maybe in mili-seconds. Do I need to have some sort of pause inbetween each keystroke?

you MIGHT want to pause between activating the application and sending the keys, to MAKE sure they all go to the application.Okay that seems to be working now each time I use the script. Thank you!


Discussion

No Comment Found