Write Clipboard Data to a Text file

Here is what I'm looking to do.

1) Copy A field of text to the clipboard(I can do that using SendKeys)
2) Write what I just copied to a Text File (No clue how)
3) Move to a new field and copy that to the clipboard (Again using SendKeys)
3) Copy that field of text to a new line in the same text file (No Clue)

I am hoping I can use a VBScript to output the clipboard to the text file so I can just call that script from a dos batch file, which is what I use to fire off the send keys script. Thanks is advance!!
CannibaltroutAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

anvCommented:
hi

i just got this article ... read it and give a try...

Hope It will help you..


*************************************************

Hello Clipboard, WSH is calling you
Many scripters wish to interact with the clipboard. Although WSH doesn't provide methods to do that, you can use a few tricks. Let's go step by step.

The most efficient way will be to write an ActiveX control that provides you with methods allowing you to access Windows clipboard. I wrote such a control and shipped it with the MS Press title Inside Windows Script Host, 2. Ausgabe (and there are also plans that my upcoming English MS Press title Advanced Development with Microsoft Windows Script Host 2.0 will contain this control). But till now I'm not ready to release this stuff in the WSH Bazaar (because the description is still in German). That's odd, but fortunately there are a few way to overcome this situation.

Well, maybe you intend to control two applications using WSH, and your script need to force one program to transfer data to the other. In this case you can force the application to copy data to clipboard and paste it into the document area of the other program. This will be used. The script launches Notepad and Calc, forces Calc to evaluate an expression and transfer the result to Notepad.

'************************************************
' File:   AppActivateWSH2.vbs (WSH 2.0 VBScript sample)  
' Author: (c) G. Born www.borncity.de
'
' Launch Calc and Notepad, use AppActivate to
' switch between applications. Transfers data
' between Calc and Notepad using Clipboard (controlled
' by SendKeys.
' Attention: The script requires WSH 2.0 !!!
'************************************************
Option Explicit

' Define the title strings of the application windows
' Use the title's begin or end, if a file name changes
' Important: strings depend on the localized Windows version
Const Edit_Title = "Notepad"          ' window title
Const Calc_Title = "Calculator"        ' window title

DIM Wsh

' Create the Shell object, required for Run and AppActivate
Set Wsh = WScript.CreateObject("WScript.Shell")

' we try to launch two applications - to assure that the
' last application receives the focus, we delay the script
Wsh.Run "Calc.exe",1     ' launch Windows calculator
WScript.Sleep 300        ' delay, till calc gets the focus
Wsh.Run "Notepad.exe",1  ' launch Windows editor Notepad
WScript.Sleep 300        ' delay, till notepad gets the focus

' set the focus back to the calculator window & calulate
If Wsh.AppActivate (Calc_Title) Then
 Wsh.SendKeys "10"       ' send 10
 Wsh.SendKeys "{+}"      ' send +
 Wsh.SendKeys "2"        ' send 2
 Wsh.SendKeys "="        ' send =

 Wsh.SendKeys "^{c}"     ' send Ctrl+C, copy to clipboard
End if

' set the focus to the editor window
MsgBox "Paste result into editor window?", vbOkOnly + vbSystemModal
If Wsh.AppActivate (Edit_Title) Then
 Wsh.SendKeys "Result of 10 {+} 2 ="
 Wsh.SendKeys "^{v}"     ' send Ctrl+v, paste from clipboard
End if
'* End
 

You can use similar techniques also with other application programs. Then you need to send keystrokes to select portions of the document area (which can be a problem).

*************************************************
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CannibaltroutAuthor Commented:
Const Edit_Title = "Path Group Maintenance"          ' window title
DIM Wsh
Set Wsh = WScript.CreateObject("WScript.Shell")
Wsh.AppActivate (Edit_Title)

That works awsome, hopefully when I switch back and forth 52000 times for what I need it to do it will still be working lol.

Thanks!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.