Jump to content

Clipput () Question... Plz Help!


Recommended Posts

(this is such a funny sample script... :whistle: )

Ok... I'm trying to set variables to clipboard... but it will just copy over $1 as text... not a variable... look...

if winexists("window") then

$1 = InputBox("Question", "What is your name?", "Enter Name")

$2 = InputBox("Question", "Who do you love?", "Who you love")

$3 = InputBox("Question", "Do you love puppies?", "Yes or no")

clipput (Hello. My name is $1. I absolutely love $2. And if you asked me if I love puppies, I would scream $3.)

winactivate ("window")

send ( "^v", 0)

exit

endif

msgbox, 0, "Error", "There was an error."

exit

and when the window is activated and CTRL+v is pressed... It just shows...

Hello. My name is $1. I absolutely love $2. And if you asked me if I love puppies, I would scream $3.)

That's just a sample code I made up just for this. Can someone tell me how I can put variables to clipboard?

Link to comment
Share on other sites

  • Developers

If WinExists("window") Then
   $1 = InputBox("Question", "What is your name?", "Enter Name")
   $2 = InputBox("Question", "Who do you love?", "Who you love")
   $3 = InputBox("Question", "Do you love puppies?", "Yes or no")
   ClipPut("Hello. My name is " & $1 & ". I absolutely love " & $2 & _
         ". And If you asked me If I love puppies, I would scream " & $3 & ".")
   WinActivate("window")
   Send("^v")
   Exit
EndIf
msgbox, 0, "Error", "There was an error."
Exit

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

There is no variable substitution in strings (as there is in many shell and other script languages). You have to explicitly concatenate the fixed and variable text:

clipput ( "Hello. My name is " & $1 & _
           ". I absolutely love " & $2 & _
           ". And if you asked me if I love puppies, " & _
           "I would scream " & $3 & ".")

Note the line continuations.

Your example couldn't have worked, because the text parameter to ClipPut wasn't quoted.

Link to comment
Share on other sites

The problem is in the formatting in the ClipPut line:

if winexists("window") then


$1 = InputBox("Question", "What is your name?", "Enter Name")

$2 = InputBox("Question", "Who do you love?", "Who you love")

$3 = InputBox("Question", "Do you love puppies?", "Yes or no")

clipput ("Hello. My name is " & $1 & ". I absolutely love " & $2 & ". And if you asked me if I love puppies, I would scream " & $3 & ".")
winactivate ("window")

send ( "^v", 0)

exit
endif


msgbox, 0, "Error", "There was an error."
exit

You have to use quotes for the Non variable stuff

We have enough youth. How about a fountain of SMART?

Link to comment
Share on other sites

lol, im still new with autoit so it took me longer to reply...i had to make a code that works so that i could understand why yours didnt.

i think your answer has allready been announced, but here is my solution:

you were making a one long string in the clipput funciton. you should instead be putting a bunch of small strings together. here is what i came up with:

$Q1 = InputBox("Question", "What is your name?", "Enter Name")

$Q2 = InputBox("Question", "Who do you love?", "Who you love")

$Q3 = InputBox("Question", "Do you love puppies?", "Yes or no")




$text=( "Hello. My name is " & $Q1 & ". I absolutely love" & $Q2 & ". And if you asked me if I love puppies, I would scream " & $Q3 & ".")

clipput($text)

the rest of your code i commented out, but you might want to go back and make sure you are using correct syntax for all the functions used. msgbox for example. B)

hope your answer was sovled :whistle:

:cheer: awww...wheres the chick?

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...