Jump to content

pasting text into a word processor


banjoman
 Share

Recommended Posts

;)

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?

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

Link to comment
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):

Edit: Missing a pair of empty quotes.

controlSend("WinName", "", "", "^v")
Edited by LxP
Link to comment
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

Link to comment
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!!

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

Link to comment
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?

Link to comment
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?

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


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

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