Sign in to follow this  
Followers 0
EasyGoing

Data to one application to another application

7 posts in this topic

I am new to scripting and do not want to use software like automate. I think autoit is easy to use, but need help understanding how to use it.

I have a lot of processes that require moving data from excel to a hospital system. I can use copy\ paste. method or keystroke from excel to the other application.

Does anyone have a good example to show me? or explain how should get started. I do not see any example on the web.

Thank you.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Welcome to the AutoIt forum.

There are much better ways to get data from Excel, but here is a simple way:

Run("Notepad")
WinWait("Untitled - Notepad")

ShellExecute("Excel")
WinWait("Microsoft Excel - Book1")
WinActivate("Microsoft Excel - Book1")
WinWaitActive("Microsoft Excel - Book1")

Send("This{ENTER}")
Sleep(100)
Send("is{ENTER}")
Sleep(100)
Send("test{ENTER}")
Sleep(100)
Send("data{ENTER}")
Sleep(100)
Send("^{HOME}")
Sleep(100)

While 1 ;clear clipboard
    ClipPut("")
    Sleep(50)
    $junk = ClipGet()
    Sleep(50)
    If $junk = "" Then ExitLoop
WEnd

For $i = 1 To 4
    WinActivate("Microsoft Excel - Book1")
    WinWaitActive("Microsoft Excel - Book1")
    Send("^c")
    Sleep(100)
    Send("{DOWN}")

    WinActivate("Untitled - Notepad")
    WinWaitActive("Untitled - Notepad")
    Send("^v")
    Sleep(100)
Next
The Windows clipboard is not the most reliable thing to use. You should really double check any data that you pass thru there. Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

Thank you. You are right this will work for now. I would like to make is clean in the future as my skills improve.

The next thing I need to learn is the "conditon" I have a lot of check boxes that need a "Yes" or "No" before I check them.

Do you have a simple example of this. Something like this.

IF cell in excel a14 = Yes then send({space}) else send({TAB})

Share this post


Link to post
Share on other sites

How did you get the symble next to the c? Send("^c")

I tried to use the clipput and clipget but I think your way is better with copy and paste.

Thank you again for your answer.

Share this post


Link to post
Share on other sites

[Everything works great now.

I need a little. Please point me in the right direct to build code on:

using a "IF" conditon to valuate a fild in excel then use keystroke in another application.

Example

IF WinWaitActive("Microsoft Excel - question.xls") A14 = "Yes" then

WinWaitActive("Microsoft Excel - Answer.xls") esle send({space}) else send({TAB})

Share this post


Link to post
Share on other sites

How did you get the symble next to the c? Send("^c")...

Press and hold the "Shift" key

Press/release the "6" key

Release the "Shift" key...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

...The next thing I need to learn is the "conditon" I have a lot of check boxes that need a "Yes" or "No" before I check them....

I took the easy way out and checked every cell for "yes" just to demo If/Else/EndIf.
Run("Notepad")
WinWait("Untitled - Notepad")

ShellExecute("Excel")
WinWait("Microsoft Excel - Book1")
WinActivate("Microsoft Excel - Book1")
WinWaitActive("Microsoft Excel - Book1")

Send("Conditional{ENTER}")
Sleep(100)
Send("send{ENTER}")
Sleep(100)
Send("based{ENTER}")
Sleep(100)
Send("on{ENTER}")
Sleep(100)
Send("yes{ENTER}")
Sleep(100)
Send("being{ENTER}")
Sleep(100)
Send("in{ENTER}")
Sleep(100)
Send("a{ENTER}")
Sleep(100)
Send("cell{ENTER}")
Sleep(100)
Send("^{HOME}")
Sleep(100)

While 1 ;clear clipboard
    ClipPut("")
    Sleep(50)
    $junk = ClipGet()
    Sleep(50)
    If $junk = "" Then ExitLoop
WEnd

For $i = 1 To 9
    WinActivate("Microsoft Excel - Book1")
    WinWaitActive("Microsoft Excel - Book1")
    Send("^c")
    Sleep(100)
    Send("{DOWN}")

    WinActivate("Untitled - Notepad")
    WinWaitActive("Untitled - Notepad")
    If StringReplace(ClipGet(), @CRLF, "") = "yes" Then
        Send("I found yes in a cell.........{ENTER}")
    Else
        Send("^v")
    EndIf
    Sleep(100)
Next
Post back if this is not what you had in mind.

Edit:

BTW, When you copy the contents of an Excel cell into the Windows clipboard, you get the CRLF at the end of the data... hence the "StringReplace" during the "If" comparison with "yes". Look here for a little bit of info about CF and LF http://www.oualline.com/eol.html

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

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