vbscript - how to send keystrokes to internet explorer
I've read every question that came up when I typed my title, as well as
several other web pages, and I still haven't found the answer I'm looking
for. I believe this is fairly straightforward, just must be missing
something as my program doesn't do anything.
Here's what I want it to do (for all practical purposes, let's say I'm
searching for my favorite discussion her on SO):
Have the main SO page loaded (stackoverflow.com/).
Utilize the Open File (CTRL+O) feature of IE to enter the specific address
of the page I'm looking for.
Utilize the Select All (CTRL+A) feature to highlight the entire text to be
copied.
Utilize CTRL+C and CTRL+V to, respectively, copy and paste this into a
word document for presentation purposes.
Here's the code I have so far:
' Sets up the objects.
Dim objIE, WshShell, objWord
Set wshShell = WScript.CreateObject ("WSCript.shell")
Set objIE = CreateObject("InternetExplorer.Application")
Set objWord = Application.CreateObject("Word.Application")
Dim i, strUserID
with CreateObject("InternetExplorer.Application")
wshShell.SendKeys "^O"
.navigate "http://stackoverflow.com/questions/[link of question would go
here]"
wshShell.SendKeys "^A"
wshShell.SendKeys "^C"
AppActivate ("Document1 - Microsoft Word")
wshShell.SendKeys "^V"
end with
For some reason, this isn't working the way I want it to. Any suggestions?
No comments:
Post a Comment