Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WSF VBS or batch file help

Status
Not open for further replies.

jayjay66

Technical User
Oct 31, 2005
114
Hi,

I need help with a .WSF (Windows Script File) that I need to create. I need the script (macro) to do the following keystroke sequences in the following order:


<CTRL-ALT-G>
<ALT-F>
<TAB>
<TAB>
<P> (the letter)
<ALT-O>
<ENTER>
<ALT-G>
<ENTER>
<Y> (the letter>
<ENTER>


Can anybody help me?

Please, any help would greatly appreciated. Basically, it's for a task that's done daily and I would like to automate it thru a script or batch file.

Please help.

Thanks,
JJ
 
Hi,

That's exaclty what I need, right, but my sript doesn't seem to do what I want it to do:

I want it to do <CTRL-ALT-H>.

I have in my script file"


'VBScript Testing Purposes
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "(^%)H"



It doesn't do anything. Please help
Thanks,
JJ

 


The code :

Wscript.SendKeys "(%F)"

for ALT-F

doesn't do anything either. Is there something wrong with my syntax. It doesn't give me an error, but it doesn't do anything eiter.

please help

thanks
jj
 
What is the Active window when your code send the keystrokes ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
This is my Code:


Set WshShell = WScript.CreateObject("WScript.Shell")
wshshell.run "notepad"
On Error Resume Next
Err.Clear
Wscript.Sleep(500)
Wscript.SendKeys "%F"


The ALT-F (%F) doesn't seem to execute properly.

Pleae help


Thanks,
JJ
 
Seems you haven't read my post stamped 8 Aug 06 12:07 nor the example provided in the link I gave you 7 Aug 06 19:21.
 

Yes, I did read your posts and my code is in the above post. It doesn't seem to work. Can you help me? I can't seem to get it to work. Help would be greatly appreciated.

It seems to be a simple thing I'm asking but my code isn't working. Are you able to help me?

I am new in WSH.

Thnks,JJ


 
WshShell.SendKeys "(^%)H"
get rid of the parantheses make it look like this

wshshell.sendkeys "^%H"
you also need to focus on the app that you're sending these keys onto: example:
WSHShell.Run ("notepad.exe") ' run the app
' put focus on the app's title (that shows up on the bar
WshShell.AppActivate ("untitled - notepad")
after doing these two, then you send your keys.
phv instructed you well, as he showed me how to do it last week. i got it to work.

 
Hi,

OK, I have:

Set WshShell = WScript.CreateObject("WScript.Shell")
WSHShell.Run ("notepad.exe") ' run the app
WshShell.AppActivate ("Untitled - Notepad") ' Focus to notepad
wshshell.sendkeys "%F"

BUT for some reason it's not on the right focus. it's sending the "ALT-F" to the other window. My code seems right. I'm opening notepad, focusing it to opened notepad window but the ALT-F is not going to the right window. See my code above.

Can anybody help me solve this littlw problem.

Thanks,
JJ
 
Why not playing with some WScript.Sleep calls (as in the aforementioned example ...)
 
after you focus on the app, as phv said, you need to wscript.sleep for a second or 2
WshShell.AppActivate ("Untitled - Notepad")
scrtipt.sleep 500 'pause for 1/2 second
wshshell.sendkeys "%F"
scrtipt.sleep 500 'pause for 1/2 second again
...
do your next send key.
 
In case you haven't solved this yet: I had a similar problem and found the solution was using lower case letters for the Ctrl- and Alt- keystroke combinations. For example, to pulldown the 'File' menu, use "%f" not "%F
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top