Sign in to follow this  
Followers 0
Illuvator

Copying and Pasting

14 posts in this topic

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

Share this post


Link to post
Share on other sites



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

does this highlight the text ? if so then

Send("^{INS}")

will copy it to the clipboard

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

does this highlight the text ? if so then

Send("^{INS}")

will copy it to the clipboard

thanks for that, and in answer to your question, no it doesnt highlight the text - any ideas how to do that?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ok so much for the easy way. what kind of document or form is the first one?

edit

Edited by pecloe

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

sorry i couldn't help.

Share this post


Link to post
Share on other sites

dont worry about it, thanks for your time :o

Share this post


Link to post
Share on other sites

ClipPut(ControlGetText("Form1","",1004))

:o


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

$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

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

StringLeft ($String, 4) ; leftmost 4

Or, StringRight ($String, 4) ; rightmost 4

Or, StringMid ($String, $StartNum, $Count) ; any number of chars from any initial place. Default $Count is the rest of the string.

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