Sign in to follow this  
Followers 0
xuzo

How to assign clipboard text to variable using clipget example?

7 posts in this topic

How to assign clipboard text to variable using clipget example?

I've looked at the help files on this but I simply lack the basic, basic skills and syntax to make it work.

Here is my code.

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is text that I will copy, once copied I want to save it to clipboard and then assign a variable to fetch it later as paste variable")
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}{down}")
;Ok this is where I would like to assign the clipboard text to a variable, I think this is the getclip part?
Send(@LF)
Send(@LF)
;I would like the data to be pasted from a variable that was created from copied text to clipboard previously
Send("$var text from clipboard")

Thanks

Share this post


Link to post
Share on other sites



I'm afraid I don't completely understand what you are after but if you want to take the text from the clipboard and place it into a variable then try this.

$Var = ClipGet()

Share this post


Link to post
Share on other sites

I simply want to copy text, save the clipboard to variable and then send variable, all on the same file for a test.

Here is my attempt:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is text that I will copy")
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}{down}")
$Var = ClipGet()
Send(@LF)
Send("$Var")
Send(@LF)
Send("ClipGet")

If you see the result the copied text doesn't get pasted...

I just don't know how to set up the ClipGet code to variable.

Share this post


Link to post
Share on other sites

To my understanding you want something like this?

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("Some Text That You Want To Copy") ; Send some text to notepad.
ClipPut(WinGetText("Untitled - Notepad")) ; Use WinGetText function along with ClipPut to insert notepad text into clipboard.
Send (@LF)
Send (@LF)
Send("Your Text Copied From Notepad: " & ClipGet()) ; Use ClipGet to retreive the text from the clipboard.

Share this post


Link to post
Share on other sites

Try changing one of the Sends to this

Send($Var)

You had the variable inside quotes, that won't send its contents, just its name


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi BrewMan,

Bingo! Yes that is what I was trying to do!

1. Copy the text

2. Put the text into a variable fetched from the clipboard

3. Send the variable

or

a. Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}{down}")

b. $Var = ClipGet()

c. Send($Var)

Thanks for trying also Venix :D

Here is the example for total rookies like me if this question comes up again in the future:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This text is getting copied")
Send("{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}{down}")
$variable_fromclipboard = ClipGet()
Send(@LF)
Send(@LF)
Send($variable_fromclipboard)
MsgBox(0, "The text was pasted ok", "Yep can see it")
Edited by xuzo

Share this post


Link to post
Share on other sites

BTW, using Send("^a^c") should work in place of all the controldown/ups you have now.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
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
Sign in to follow this  
Followers 0