jefhal Posted September 3, 2005 Share Posted September 3, 2005 Perhaps there is an easier way to get command output into the clipboard, but I couldn't find it. Instead I found this utility to pipe output from a dos command to the clipboard. It's called clipboard.exe and I found it at: Pipe to clipboard utilityI use it a lot with @comspec to pump output directly into a variable, e.g.:run(@comspec & ' /c ' & "ipconfg /all |clipboard") $var = clipget() msgbox(1,"Clipboard contents= ",$var)This avoids the need for a file to be created and saves me a few file handling steps. I don't know anything about the website, but given the extent of the programs he offers, my gut feeling is that the code is legit. I like it and hope some of you find it useful... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
LxP Posted September 4, 2005 Share Posted September 4, 2005 What a fantastic idea! Thanks for sharing! Link to comment Share on other sites More sharing options...
lte5000 Posted September 4, 2005 Share Posted September 4, 2005 (edited) If you use the AutoIt beta, then the example below would be another option.It does not require external programs or temp files to function. Instead, it use the inbuilt StdoutRead() beta function.#include <Constants.au3> Global $cmdOUT = '' $PID = Run("ipconfig /all", "", @SW_HIDE, $STDOUT_CHILD) While NOT @ERROR $cmdOUT &= StdoutRead($PID) Wend MsgBox(1, "IPConfig Output:", $cmdOUT)-KendallEdit: Changed example to w0uter's suggestion.Edit: Spelling.Edit: Code box cleanup. Edited September 4, 2005 by lte5000 Link to comment Share on other sites More sharing options...
w0uter Posted September 4, 2005 Share Posted September 4, 2005 why not use Global $cmdOUT = '' While NOT @ERROR $cmdOUT &= StdoutRead($PID) Wend My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
lte5000 Posted September 4, 2005 Share Posted September 4, 2005 (edited) why not useGlobal $cmdOUT = '' While NOT @ERROR $cmdOUT &= StdoutRead($PID) Wend<{POST_SNAPBACK}>Yep, that would be better. KendallEdit: I didn't realize there was: &= ..'til now. Edit: Spelling. Edited September 4, 2005 by lte5000 Link to comment Share on other sites More sharing options...
jefhal Posted September 4, 2005 Author Share Posted September 4, 2005 (edited) Thanks to w0uter and lte5000. Now I can eliminate one more external program to do my work... Edited September 4, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
theguy0000 Posted September 5, 2005 Share Posted September 5, 2005 srry i dont understand what this program does exactly The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN Link to comment Share on other sites More sharing options...
LxP Posted September 5, 2005 Share Posted September 5, 2005 The top script outputs any information from a DOS session to the clipboard. The remaining ones use functions of the beta to directly read any output into an AutoIt variable, ridding the need for temporary files or damage to current clipboard information. Link to comment Share on other sites More sharing options...
Michel Claveau Posted September 5, 2005 Share Posted September 5, 2005 (edited) Hi ! I have developped a script,with autoit! who do the same work than the clipboard.exe utility (see 1st message). But it's run OK only if the script is passed by Aut2exe (if he is compiled like fclipboard.exe) Here, the source-code : ;fclipboard.au3 --> fclipboard.exe $data = ConsoleRead() ClipPut($data) And, a sample of use : @echo off :: sendclip.bat echo AZERTYUIOP|fclipboard echo Envoyé au clipboard. *sorry for my bad english * Edited September 5, 2005 by Michel Claveau Link to comment Share on other sites More sharing options...
Michel Claveau Posted September 5, 2005 Share Posted September 5, 2005 re-Hi ! Here the release, number 2 The optimization give a twice shorter code : ;fclipboard.au3 --> fclipboard.exe ClipPut(ConsoleRead()) : perhaps, I can to sell this mega-great developpment ? I think .... one million of Euros/Dollars ; what do you think, for that ? Link to comment Share on other sites More sharing options...
jefhal Posted September 24, 2005 Author Share Posted September 24, 2005 Here the release, number 2 perhaps, I can to sell this mega-great developpment ?Awesome!!!!! Such an elegant solution....However, this is very weird, when I run ipconfig /all into your code: ipconfig /all | fclipboard.exethe exact same thing happens as happens with stdout_child. The output gets chopped off. I lose the last 15 or so lines of the output. Does this happen because time runs out? I do not understand... ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
w0uter Posted September 24, 2005 Share Posted September 24, 2005 $s_line = '' While Not @ERROR $s_line &= ConsoleRead() Wend ClipPut($s_line) written straight in the browser, so could be buggy. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
jefhal Posted September 24, 2005 Author Share Posted September 24, 2005 written straight in the browser, so could be buggy.I should have such bugs! Brilliant!! This solves it !!! Thanks to all of you. w0uter, so that I understand Why this works, when will @error be true? Is it TRUE when there is no more output from the process? Am I mistaken, or are there two expressions: &= and =&? &= means concat, =& means by reference? Where can I learn more about by reference, as the examples in the forum and the help file are still confusing me... Thanks! ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
w0uter Posted September 24, 2005 Share Posted September 24, 2005 Is it TRUE when there is no more output from the process?yesAm I mistaken, or are there two expressions: &= and =&?AFAIK there is no =& My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
jefhal Posted September 24, 2005 Author Share Posted September 24, 2005 (edited) w0uter, Michel, et al: Thanks again for the ideas and code. Here's my latest incarnation of clipit. I found that @error was not going to "true", so I added a manual "terminate" and a "timed" one. If I let the timer run for 10 seconds, I could get 529 lines from: dir c:\ /s |clipit In 50 seconds I got 47000 lines of output from the above test (Pentium 4, 2.8Ghz, WinXP) In five seconds I could be sure to get everything that ipconfig puts out. For now, this avoids the "truncation" that happens sometimes with stdout_child. ; This code must be compiled (clipit.exe) and run from the dos window with the "pipe" symbol "|" : e.g.: ; c:>ipconfig /all | clipit.exe ; This will put the output of ipconfig /all into the clipboard. You can then paste it where you like... ; Based on ideas from many authors in thread "Scripts and Scraps" "Pipe to clipboard" #Include <Date.au3> $starttime = TimerInit() ; HotKeySet("{ESC}", "Terminate"); unremark for manually stopping the clipit process $s_line = '' While Not @ERROR $s_line &= ConsoleRead() ; ToolTip($s_line); unremark for debugging If TimerDiff($starttime) > 10000 Then ExitLoop; 10000 = 10 seconds. choose value that gives your process enough time Wend ClipPut($s_line) Func Terminate() Exit 0 EndFunc Question: Since this tool is now buried deep in this thread, should it be posted again in a new thread at the top so that it's easier to find? I'm sure a number of people could use it, not just within AutoIT... Edited September 24, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
w0uter Posted September 24, 2005 Share Posted September 24, 2005 you forgot that @error is for the preveus command only. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
jefhal Posted September 25, 2005 Author Share Posted September 25, 2005 you forgot that @error is for the preveus command only.You are correct, Sir! Thanks again. I just tested the version below at work, and it's fabulous!HotKeySet("{ESC}", "Terminate"); unremark for manually stopping the clipit process $s_line = '' While Not @ERROR $s_line &= ConsoleRead() Wend ClipPut($s_line) Func Terminate() Exit 0 EndFunc ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Matrix112 Posted September 25, 2005 Share Posted September 25, 2005 Hi, nice idea. I will try it next time. I usually use this #include <file.au3> Dim $array Run(@ComSpec & " /c " & 'ipconfig /all >> c:\ipconf.log', "", @SW_HIDE) ProcessWaitClose("cmd.exe") _FileReadToArray("c:\ipconf.log",$array) FileDelete("c:\ipconf.log") ;---------Example for use-------------- For $x = 1 to $array[0] Msgbox(0,'Line ' & $x, $array[$x]) Next Link to comment Share on other sites More sharing options...
jefhal Posted September 26, 2005 Author Share Posted September 26, 2005 (edited) I usually use thisRun(@ComSpec & " /c " & 'ipconfig /all >> c:\ipconf.log', "", @SW_HIDE)Hi Matrix112-I used that same method at first. Then I switched to the stdout_child method as it was much more elegant. However, I kept losing the end of the output. Then I found a shareware program called "clipboard", which worked great except I was relying on code whose source I could not see. Finally, several of us evolved the solution in this thread. Perhaps some day I will either figure out how to use stdout_child to get all of the output or (if I am using it properly) it will be changed to support the complexity of psexec.exe... By the way, why are you capturing ipconfig output? Edited September 26, 2005 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
DaveF Posted September 26, 2005 Share Posted September 26, 2005 Hey, jefhal; Again, it's dangerous to test the value of @error for a conditional loop like the previous example, because any function call that you make could change @error's value. It's easy (at least for me) to forget this and put a MsgBox() in the loop for debug purposes and then waste time debugging why my script broke... The construct that has been traditionally used for XxxYyyRead() has been: While 1 ; Don't seperate the next two lines $foo &= ConsoleRead() If @error = -1 Then ExitLoop WEnd Also, could you post/PM/otherwise direct me to your code that used StdoutRead() that was truncating the output of the child process? Internally StdoutRead() and ConsoleRead() use identical code, so they both should have gotten the same output from the same program; if StdoutRead() is broken in some way I need to know about it... Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now