Copy and paste user input data

Asked by tjj1981

I have given users the ability to input data that will be used several times throughout the script using the following code:

input(msg="INPUT NUMBER HERE")

I cannot, however, figure out how to actually paste the data they type in. For example, if a user types "12345" and I would like to paste that number in several cells in Excel, how can I go about doing this?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
tjj1981
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

Try this:

msg = input("INPUT NUMBER HERE") # returns the input and stores in msg (may be None!)

now you have to position the cursor in the XLS cells.

switchApp("Excel")

try to use a series of type(Key.DOWN/RIGHT/UP/LEFT) to get to the cell and then type(msg) or paste(msg).
To press ENTER for completion of inputting to the cell try type(Key.ENTER) afterwords.
Another option is: type(msg+"\n") this adds a return key to your msg.

Revision history for this message
tjj1981 (tjanvrin) said :
#2

Thanks RaiMan -- this works perfect! I appreciate the help!