augustspies Posted March 16, 2011 Share Posted March 16, 2011 Hi guys, I found this script a couple days ago but don't remember the thread to reference it so I apologize in advance This script reads 1 line @ a time and then copies it to the clipboard. Is it possible to take this script and make it so that it reads all the lines/entire content and then copies it to clipboard to be pasted somewhere? If so how could I do this? Local Const $File = "D:\file.txt" Global $Handle = FileOpen($File, 0) If $Handle = -1 Then MsgBox(0x10, 'Error', 'Could not open the file:' & @LF & $File) Exit EndIf HotkeySet('^{RIGHT}', 'NextLine') HotkeySet('{ESC}', 'Done') NextLine() While 1 Sleep(0x7FFFFFFF) WEnd Func NextLine() Local $NextLine = FileReadLine($Handle) If @Error Then MsgBox(0x40, 'End of File', 'The end of the file has been reached.', 10) Done() EndIf ClipPut($NextLine) TrayTip('Copied to Clipboard', $NextLine & @LF & @LF & 'Ctrl+Right: Next line' & @LF & 'Esc: Quit', 5, 1) EndFunc Func Done() FileClose($Handle) Exit EndFunc Link to comment Share on other sites More sharing options...
enaiman Posted March 16, 2011 Share Posted March 16, 2011 This puts the whole file content in the clipboard: $File = "D:\file.txt" ClipPut(FileRead($File)) SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
AutoBert Posted March 16, 2011 Share Posted March 16, 2011 Hi augustspies, HotkeySet('^{RIGHT}', '_doCopy') HotKeySet('{ESC}', 'Done') While 1 Sleep(500) WEnd Func _doCopy() $message = "File to Copy in ClipBoard" $var = FileOpenDialog($message, @AppDataCommonDir & "", "Textfiles (*.txt;*.ini))", 1 + 2) If @error Then Return ; $sText = FileRead($var) ClipPut($sText) TrayTip('File is copied to Clipboard', $var & @crlf & 'Esc: Quit' & @CRLF & 'Ctrl-Right: Copy another File', 5, 1) EndFunc ;==>_doCopy Func Done() Exit EndFunc ;==>Done mfg autoBert Link to comment Share on other sites More sharing options...
MattX Posted April 6, 2011 Share Posted April 6, 2011 This puts the whole file content in the clipboard: $File = "D:\file.txt" ClipPut(FileRead($File)) Thanks - those two lines of code have got me out of a mess I've been racking my brain on for the last hour or so.... Link to comment Share on other sites More sharing options...
tanim Posted December 16, 2011 Share Posted December 16, 2011 This puts the whole file content in the clipboard: $File = "D:file.txt" ClipPut(FileRead($File)) Thanks. I was also looking for this and thanks to you in my first post here Link to comment Share on other sites More sharing options...
hg2051 Posted March 12, 2013 Share Posted March 12, 2013 If I get $File like this: $File=FileRead($aXYZ,0) ClipPut puts nothing in the clipboard. Do you see how to overcome this? Link to comment Share on other sites More sharing options...
kylomas Posted March 13, 2013 Share Posted March 13, 2013 Well, it is almost Easter... What is the value in $aXYZ? Show your script including the clipput function. Use code tags to post the script, please. kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Nessie Posted March 13, 2013 Share Posted March 13, 2013 If I get $File like this: $File=FileRead($aXYZ,0) ClipPut puts nothing in the clipboard. Do you see how to overcome this? You have used FileRead, but you have setted to 0 the number of characters to read. That's why you don't see nothing BTW it's a good pratice to use the FileOpen handle in FileRead. $File = @ScriptDir & "\MyFile.txt" $Open = FileOpen($File, 0) $Read = FileRead($Open) ClipPut($Read) FileClose($Open) Hi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
kylomas Posted March 13, 2013 Share Posted March 13, 2013 You have used FileRead, but you have setted to 0 the number of characters to read.Yes, of course, DUH!?!? Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Nessie Posted March 13, 2013 Share Posted March 13, 2013 Yes, of course, DUH!?!?That happens, maybe is this easter time muttleyHi! My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file Link to comment Share on other sites More sharing options...
kylomas Posted March 13, 2013 Share Posted March 13, 2013 Yes, waiting for brain ressurection... Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Nessie Posted March 13, 2013 Share Posted March 13, 2013 Yes, waiting for brain ressurection... [offtopic]That make me laughing out so loud [/offtopic] My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s). My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all! My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file 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