Sign in to follow this  
Followers 0
banjoman

pasting text into a word processor

10 posts in this topic

;)

I am making an application with MultiMediaBuilder that contains a word bank, when a word is clicked that word is copied to the windows clipboard

how can I paste this text into a word processor window?

do I have to name the target window or can I search for a word processor window that is open, make it active and then paste into it?

Share this post


Link to post
Share on other sites



;)

I am making an application with MultiMediaBuilder that contains a word bank, when a word is clicked that word is copied to the windows clipboard

how can I paste this text into a word processor window?

do I have to name the target window or can I search for a word processor window that is open, make it active and then paste into it?

<{POST_SNAPBACK}>

Use window spy to get window name and then ControlSend "Ctrl C" like this

ControlSend("WinName","","^C")

Just remember it willl paste at whatever cursor position in Word Processor

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

is8591's on the right track, however this will most likely send Ctrl+Shift+C because of the capital C. This should work for you if that doesn't (actually it should probably be Ctrl+V):

Edit: Missing a pair of empty quotes.

controlSend("WinName", "", "", "^v")
Edited by LxP

Share this post


Link to post
Share on other sites

is8591's on the right track, however this will most likely send Ctrl+Shift+C because of the capital C. This should work for you if that doesn't (actually it should probably be Ctrl+V):

controlSend("WinName","","^v")

<{POST_SNAPBACK}>

Thanks LxP - you absolutely right. Control C is for copying and V is for pasting.

That's what I get for relying on my functions too much - I do all my copy-paste from Excel and actual key sequences are in GetCell and PutCell

Share this post


Link to post
Share on other sites

thanks for that, could you be more specific about window spy - if there is a word processor window open what script command do I use to get its name and then how do I feed that into the ControlSend command?

I envisage this AutoIt script will be compiled in to an .exe file which can then be run from the word bank program, so the AutoIt script will have to do this (I think);

1) detect a word processor window and get its window name

2) activate it (I assume because if the user has clicked the word bank programme that window will be the active one on the desktop?)

3) feed the word processor window name into the ControlSend command

4) carry out the ControlSend command

then, hey presto, the word chosen from the word bank will be pasted into the word processor document at the cursor position!!

Share this post


Link to post
Share on other sites

thanks for that, could you be more specific about window spy - if there is a word processor window open what script command do I use to get its name and then how do I feed that into the ControlSend command?

I envisage this AutoIt script will be compiled in to an .exe file which can then be run from the word bank program, so the AutoIt script will have to do this (I think);

1) detect a word processor window and get its window name

2) activate it (I assume because if the user has clicked the word bank programme that window will be the active one on the desktop?)

3) feed the word processor window name into the ControlSend command

4) carry out the ControlSend command

then, hey presto, the word chosen from the word bank will be pasted into the word processor document at the cursor position!!

<{POST_SNAPBACK}>

Window spy is AutoIt Window Info and comes with AutoIt.

Activate your word processor and then AutoIt Window Info.

Position mouse on word processor window and watch in Window tool:

ControlID

ClassNameNN

Text

when those fields show info about your word processor window press CTRL-ALT-F

that will freeze Window Info.

Now copy & paste ControlID or Classname into "FileName" in ControlSend

either one can be used.

When executing you don't need to activate Word Processor window because ControlSend will work with any window/control even without focus

Share this post


Link to post
Share on other sites

thanks again, it is so good having a responsive forum to get quick answers and advice from

I think I have enough info now to start experimenting

Share this post


Link to post
Share on other sites

;)

hey presto has not worked yet

this works:-

controlSend("Document1 - Microsoft Word","","_WwG1","text in a Word window")

but this does not:-

controlSend("Document1 - Microsoft Word","","_WwG1","^v")

nor this:-

controlSend("Document1 - Microsoft Word","","_WwG1","^V")

I have tried all sorts of ways of sending the paste command (looking up the 'send' command in the AutoIt help file), but have not been successful as yet

any ideas anyone?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

;)

hey presto has not worked yet

this works:-

controlSend("Document1 - Microsoft Word","","_WwG1","text in a Word window")

but this does not:-

controlSend("Document1 - Microsoft Word","","_WwG1","^v")

nor this:-

controlSend("Document1 - Microsoft Word","","_WwG1","^V")

I have tried all sorts of ways of sending the paste command (looking up the 'send' command in the AutoIt help file), but have not been successful as yet

any ideas anyone?

<{POST_SNAPBACK}>

I have tried it and it works as long as Microsoft Word is not minimised.

EDIT

You will find that the first one does not work if Word is minimised.

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

yeah, it does, I must have been trying it with Windows minimized I guess, but did not notice

thanks

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