![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file First, I've created a string using a .vbs file, like this: 'make string out of clipboard contents sText = oHtml.parentwindow.clipboardData.getData("text") Then I've done stuff in other applications. Now I want to grab the string I created and transfer it to the Clipboard so as to paste it into an application, like this: ' Paste sText into document Set oAutoIt = WScript.CreateObject("AutoItX3.Control") oAutoIt.ClipPut(sText) oShell.SendKeys"^v" Question: how do I grab sText that's already been created in one .vbs file, and run a second .vbs file that puts the string in the Clipboard and pastes it? Thanks, Larry |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file "Larry" <larry328NOSPAM@xxxxxx> wrote in message news:OSkGs215JHA.1716@xxxxxx Quote: > > > First, I've created a string using a .vbs file, like this: > > 'make string out of clipboard contents > sText = oHtml.parentwindow.clipboardData.getData("text") > > Then I've done stuff in other applications. > > Now I want to grab the string I created and transfer it to the Clipboard > so as to paste it into an application, like this: > > ' Paste sText into document > Set oAutoIt = WScript.CreateObject("AutoItX3.Control") > oAutoIt.ClipPut(sText) > oShell.SendKeys"^v" > > Question: how do I grab sText that's already been created in one .vbs > file, > and run a second .vbs file that puts the string in the Clipboard and > pastes > it? > > Thanks, > Larry Quote: > Question: how do I grab sText that's already been created in one .vbs > file, > and run a second .vbs file that puts the string in the Clipboard and > pastes - To put a string into the clipboard, check this link: http://www.microsoft.com/technet/scr...4/hey0813.mspx - To make a string from one script available to another script: Write it to a temp file, then read it from there. Alternatively, if Script 2 is invoked from Script 1, pass the string as a parameter surrounded by double quotes. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file The script you've linked me to, by which a string is transferred to the Clipboard, won't help me. I already know how to put a string in the Clipboard, and in fact, my first .vbs file begins with the desired text already in the clipboard, and I make it into a string. Here's the idea. I have text in the clipboard, which I'm planning to paste somewhere. But then I realize that before I can paste it, I've got to copy something else to the clipboard. I don't want to have the initial text wiped out before I've had the chance to paste it, so I make it into a string for the interim. Then, after I've done the other operation which has put other text in the clipboard, I want to retrieve the string I created, and turn it back into Clipboard contents so that I can paste it. The problem is that by the time I get to that last step, the .vbs file where the string was created is no longer running since I have switched to a different application where I was performing other tasks. Therefore the retrieval of the string must be done from a second .vbs file. So my question is, having created a string in .vbs file 1, how do I then retrieve that string using .vbs file 2? To sum up: 1. In .vbs file 1, Clipboard contents is made into string sText. 2. Then I do other stuff in another application, involving putting some other contents into Clipboard. 3. (This is the part I need help with.) Now I want to run .vbs file 2, with which I retrieve sText from .vbs file 1, and turn it into Clipboard contents so that I can paste it. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file "Larry" <larry328NOSPAM@xxxxxx> wrote in message news:OAbxYr45JHA.480@xxxxxx Quote: > > The script you've linked me to, by which a string is transferred to the > Clipboard, won't help me. I already know how to put a string in the > Clipboard, and in fact, my first .vbs file begins with the desired text > already in the clipboard, and I make it into a string. > > Here's the idea. I have text in the clipboard, which I'm planning to paste > somewhere. But then I realize that before I can paste it, I've got to copy > something else to the clipboard. I don't want to have the initial text > wiped > out before I've had the chance to paste it, so I make it into a string > for > the interim. Then, after I've done the other operation which has put other > text in the clipboard, I want to retrieve the string I created, and turn > it > back into Clipboard contents so that I can paste it. > > The problem is that by the time I get to that last step, the .vbs file > where > the string was created is no longer running since I have switched to a > different application where I was performing other tasks. Therefore the > retrieval of the string must be done from a second .vbs file. So my > question is, having created a string in .vbs file 1, how do I then > retrieve > that string using .vbs file 2? > > To sum up: > > 1. In .vbs file 1, Clipboard contents is made into string sText. > > 2. Then I do other stuff in another application, involving putting some > other contents into Clipboard. > > 3. (This is the part I need help with.) Now I want to run .vbs file 2, > with > which I retrieve sText from .vbs file 1, and turn it into Clipboard > contents > so that I can paste it. a simple solution: 1. In .vbs file 1, Clipboard contents is made into string sText, then write sText into a temp file. 2. Then I do other stuff in another application, involving putting some other contents into Clipboard. 3. Run vbs file 2 to retrieve sText from the temp file and to turn it into Clipboard contents so that I can paste it. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file "Pegasus [MVP]" <news@xxxxxx> wrote in message news:#6PLQz45JHA.6004@xxxxxx Quote: > > "Larry" <larry328NOSPAM@xxxxxx> wrote in message > news:OAbxYr45JHA.480@xxxxxx Quote: >> >> The script you've linked me to, by which a string is transferred to the >> Clipboard, won't help me. I already know how to put a string in the >> Clipboard, and in fact, my first .vbs file begins with the desired text >> already in the clipboard, and I make it into a string. >> >> Here's the idea. I have text in the clipboard, which I'm planning to >> paste >> somewhere. But then I realize that before I can paste it, I've got to >> copy >> something else to the clipboard. I don't want to have the initial text >> wiped >> out before I've had the chance to paste it, so I make it into a string >> for >> the interim. Then, after I've done the other operation which has put >> other >> text in the clipboard, I want to retrieve the string I created, and turn >> it >> back into Clipboard contents so that I can paste it. >> >> The problem is that by the time I get to that last step, the .vbs file >> where >> the string was created is no longer running since I have switched to a >> different application where I was performing other tasks. Therefore the >> retrieval of the string must be done from a second .vbs file. So my >> question is, having created a string in .vbs file 1, how do I then >> retrieve >> that string using .vbs file 2? >> >> To sum up: >> >> 1. In .vbs file 1, Clipboard contents is made into string sText. >> >> 2. Then I do other stuff in another application, involving putting some >> other contents into Clipboard. >> >> 3. (This is the part I need help with.) Now I want to run .vbs file 2, >> with >> which I retrieve sText from .vbs file 1, and turn it into Clipboard >> contents >> so that I can paste it. > Your explanation makes it a lot clearer. Using the steps you posted, here > is a simple solution: > > 1. In .vbs file 1, Clipboard contents is made into string sText, then > write > sText into a temp file. > > 2. Then I do other stuff in another application, involving putting some > other contents into Clipboard. > > 3. Run vbs file 2 to retrieve sText from the temp file and to turn it into > Clipboard > contents so that I can paste it. variables, even global ones, go out scope when the script terminates. /Al |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file > The short answer, which the OP has by now come to realize, is that Quote: > variables, even global ones, go out scope when the script terminates. > In Word VBA, you can define variables and put them in a macro where they are permanentely accessible. (I haven't done it in a while, I forget the correct terms for this.) Larry |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file You write: Quote: > Your explanation makes it a lot clearer. Using the steps you posted, here Quote: > a simple solution: > > 1. In .vbs file 1, Clipboard contents is made into string sText, then Quote: > sText into a temp file. > > 2. Then I do other stuff in another application, involving putting some > other contents into Clipboard. > > 3. Run vbs file 2 to retrieve sText from the temp file and to turn it into > Clipboard > contents so that I can paste it. Thanks, Larry |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file "Larry" <larry328NOSPAM@xxxxxx> wrote in message news:%23geGCp75JHA.1372@xxxxxx Quote: > You write: > Quote: >> Your explanation makes it a lot clearer. Using the steps you posted, here Quote: >> a simple solution: >> >> 1. In .vbs file 1, Clipboard contents is made into string sText, then Quote: >> sText into a temp file. >> >> 2. Then I do other stuff in another application, involving putting some >> other contents into Clipboard. >> >> 3. Run vbs file 2 to retrieve sText from the temp file and to turn it >> into >> Clipboard >> contents so that I can paste it. > Ok, how do I write sText into a temp file, and how do I retrieve it? > > Thanks, > Larry WriteLine methods of the File System Object. The help file includes complete examples for both methods. And for reading, it's the ReadLine method! |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file "Larry" <larry328NOSPAM@xxxxxx> wrote in message news:#JHoBp75JHA.1372@xxxxxx Quote: Quote: >> The short answer, which the OP has by now come to realize, is that >> variables, even global ones, go out scope when the script terminates. >> > That's what I figured, but I wondered if there was some way around it. Quote: > In Word VBA, you can define variables and put them in a macro where they > are > permanentely accessible. (I haven't done it in a while, I forget the > correct > terms for this.) maintained by the program that is the "scripting engine", WinWord.exe. Wscript.exe and cscript.exe are much leaner scripting engines, as they do nothing but support a couple of scripting languages, whereas WinWord does at least a couple of other things. /Al |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Grabbing a string that's already been created in one .vbs file and doing stuff with it in a second .vbs file > Download the help file script56.chm and look at the CreateTextFile and the WriteLine methods of the File System Object. The help file includes complete examples for both methods. And for reading, it's the ReadLine method! Isn't there an online resource that gives all the info on VBScript? I seem to remember there used to be one, but I haven't looked it up in a while. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
Used Alt 0160 - And Now I can't Delete File Created - PLEASE HELP! | General Discussion | |||
| How to get teh recentest created file in a folder | VB Script | |||
| Cannot view file date created | Vista file management | |||
| Grabbing a number after the Nth occurence of something within a single string | PowerShell | |||
| create dir, stuff some logs in a new file in that dir | PowerShell | |||