Jump to content

ConsoleWrite Text to Clipboard


Recommended Posts

Hallo

sometimes i use the ConsoleWrite Function in my Script. How can i put the text from the ConsolWrite Function

into the clipboard and at the end of the script all text from the ConsoleWrite Functions writes to a File.

Example:

ConsoleWrite("only a test"

ConsoleWrite("also only a test"

When the script is ready , it should create a file ==> log.txt with following content.

only a test

also only a test

thx for the support

Link to comment
Share on other sites

Hallo

sometimes i use the ConsoleWrite Function in my Script. How can i put the text from the ConsolWrite Function

into the clipboard and at the end of the script all text from the ConsoleWrite Functions writes to a File.

Example:

ConsoleWrite("only a test"

ConsoleWrite("also only a test"

When the script is ready , it should create a file ==> log.txt with following content.

only a test

also only a test

thx for the support

Hi,

try this:

ClipPut ("") ;reset Clipboard

_mywrite ("only a test") ; see Function
_mywrite ("also only a test") ;see Function
$file = FileOpen ("C:\log.txt", 2) ; Open Textfile in Writemode, erasing contents
FileWrite ($file, ClipGet ()) ; Write Clipboard to File
FileClose ($file) ; Close File
ShellExecute ("c:\log.txt") ; Show File

Func _mywrite ($string)
    ConsoleWrite ($string)
    If ClipGet () <> "" Then ; If Clipboard isn't empty
        $oldvalue = ClipGet () ; save ClipBoard content
        ClipPut ($oldvalue & @CRLF & $string) ; Write to Clipboard, If you don't need a LineFeed just change to ClipPut ($oldvalue & $string)
    Else ; Clipboard is empty
        ClipPut ($string)
    EndIf
EndFunc

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...