idontknow989 Posted November 28, 2017 Share Posted November 28, 2017 I have a simple script that copies a list of patients in an Allscripts PM database and pastes them into an Excel file. I am having trouble figuring out how to stop the script after it gets to the last person. If anyone could help me with this it would be greatly appreciated. While 1 WinActivate("Allscripts PM") WinWaitActive("Allscripts PM") Send("^c") Sleep(100) Send("{DOWN}") WinActivate("Microsoft Excel - Book1") WinWaitActive("Microsoft Excel - Book1") Send("^v") Sleep(100) Send("{DOWN}") WEnd Link to comment Share on other sites More sharing options...
Earthshine Posted November 28, 2017 Share Posted November 28, 2017 (edited) you should read in all the names to an array, then traverse the array. you could also query the database and check for recordcount, then loop until EOR Also there is an Excel UDF that Water wrote (I think) that is super nice and super easy. But hey, would you try this and see if it works? try a Control A to select all then just past to excel as you do. you may not have to loop WinActivate("Allscripts PM") WinWaitActive("Allscripts PM") Send("^a") Send("^c") Sleep(100) Send("{DOWN}") WinActivate("Microsoft Excel - Book1") WinWaitActive("Microsoft Excel - Book1") Send("^v") Sleep(100) Send("{DOWN}") Edited November 28, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
idontknow989 Posted November 28, 2017 Author Share Posted November 28, 2017 In Allscripts only one patient can be selected at a time, which is why I made the loop to go back and forth between Allscripts and Excel. I am not able to read the list of patients any other way besides loading them up inside of Allscripts. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 28, 2017 Moderators Share Posted November 28, 2017 (edited) @idontknow989 just a couple of questions for clarification. You activate the window, copy the patient name, then hit the down button to move to the next. So: When you reach the last patient record, copy it and then hit down, what is the behavior? Does it just stay on that same line in the app? Are the patient names full names, first names only, etc.? Are they unique enough that you could compare the last string placed on the clipboard and be reasonably sure of the outcome? For example: Notepad with first names: Jim John James Joey Diana Diana ....Should fail here Jim John James Joey Diana ClipPut('') ;Clear the Clipboard Local $sName = "" Local $x = 1 While 1 WinActivate("Untitled - Notepad") Sleep(500) Send("+{END}") ;Shift end to capture whole line Send("^c") ;Copy Send("{DOWN}{HOME}") ;Down arrow then Home button to the beginning of the next line If $sName == ClipGet() Then ;If what was just captured is Case-sensitive equal to what is on the clipboard ConsoleWrite(ClipGet() & " already in the clipboard" & @CRLF) ExitLoop Else $sName = ClipGet() ConsoleWrite("Turn " & $x & ": " & $sName & @CRLF) EndIf $x += 1 WEnd You would have to modify this a bit to fit your needs, but it should give you an idea of a way to go about it. If the application's behavior is different when you reach the last line, please explain in greater detail. If possible, a screenshot would be helpful. Edited November 28, 2017 by JLogan3o13 Earthshine 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Earthshine Posted November 28, 2017 Share Posted November 28, 2017 (edited) Sorry then. Edited November 28, 2017 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
idontknow989 Posted November 28, 2017 Author Share Posted November 28, 2017 @JLogan3o13 When the script gets to the last person it will stay on that person and copy and paste them over and over. The patients are unique enough since it includes names, addresses, payment, etc.; I will give your script a try and see if it works. Link to comment Share on other sites More sharing options...
idontknow989 Posted November 28, 2017 Author Share Posted November 28, 2017 Thank you JLogan3o13 that ended up working. Earthshine 1 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 28, 2017 Moderators Share Posted November 28, 2017 Glad it worked out for you. If in the future you want to get away from the Send commands (which are notoriously unreliable) we can assist with that as well. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now