Jump to content

Copying and Pasting


 Share

Recommended Posts

Hello again, brief question, i want to copy a number from a box on a form to another box on another form (both windows are open) how do i do this? because this does not seem to work First it must generate a number

ControlClick("Form1", "", 1005, "$primary")

Then must copy that number from the box onto the other form:

ControlClick("Form1","",1004, "$primary", 2)
Send("^{C}")

Then it must paste this onto (say a notepad document)

WinActivate("Untitled - Notepad")
Send("^{V}")

Is that how to go about it? or is there another way? because it seems to not want to select the data in the first form - is that because it is clicking too fast to register?

Illuvator

Link to comment
Share on other sites

Assuming you have two documents open in Notepad: Doc1 and Doc2 and that Doc1 has text in it and Doc2 does not, this will copy the text from one instance to the other:

WinActivate("Doc1.txt - Notepad","")
ControlSend ( "Doc1.txt - Notepad", "", "Edit1", "^a" )
$var = ControlCommand ( "Doc1.txt - Notepad", "","Edit1" , "GetSelected", "option" )
MsgBox(1,"$var",$var)
WinActivate("Doc2.txt - Notepad","")
ControlSend("Doc2.txt - Notepad","","Edit1",$var)
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

I think thats where the problem lies, the number is taken from a random number generating .exe file which my friend wrote (may get on to him to ask him actually) and i wanted to copy the numbers generated to notepad to put them into a file (random number generator for selecting random test sites for a piece of coursework) and hence into my work. No problems, thanks for your help, ill get onto him and see if i can take this further :o

Link to comment
Share on other sites

Thanks very much to you all :o (@ theguy) that was what i was looking for, thanks very much :geek:. and @ChrisL in the script

ControlSetText("Form2", "", 1050, "What do i put in here???"

Basically, i have (thanks to theguy got the input on the clipboard, how do i then paste that (not using Send("{V}") using the control set text command?

Thanks again to all of you for your assistance,

Illuvator

Link to comment
Share on other sites

$data = ClipGet()

ControlSetText("Form2", "", 1050, $data)

I still think you would be better not using the clipboard and using ControlGetText(), clipboards can easily get replaced with the wrong data.

ControlGetText() would store the value in a Variable and you would put it into the second app in the way above but without the clipput() and clipget()

So $data = ControlGetText("Form1","",1004)

ControlSetText("Form2", "", 1050, $data)

Edited by ChrisL
Link to comment
Share on other sites

Thanks very much again. :o One last question and then i'll cease to trouble you lol. Is there any way I can copy a selection of the digits in a random number (say the first four, or first five) from a string which is say 14 characters long? Is that possible?

Thanks very much, you're all extremely hepful :geek:

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