Jump to content

Recommended Posts

Posted

I have a script that loops through a  database in Allscripts PM and clears out patient information. It cycles through the list of patients by pressing the down arrow key and I am having trouble finding a way to have the script stop at the end of the list of patients. Is there a way track when the down arrow key hits the last person in the list?

Posted (edited)

this is done in a browser, is it not? You will most likely need UIAutomation by junkew because I don't think you can know when you hit the bottom. if you could query the database yourself you could get a recordset and loop while not EOR (End Of Record)

The UIAutomation UDF can make automating browsers a reality

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted (edited)

No UIAutomation can automate many apps and things that you just can't do with regular style AutoIt scripting. Do you know what that application is written in perhaps?

in the SciTe editor, in the menu, under Tools there is Au3Info finder tool, use that to see if you can locate the elements you want to click on or automate using that spy tool and post your results here. I can usually tell what it is written in because the data will show what controls and forms are used.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted (edited)

post your script. you need to learn how to use the AU3Info tool. Go read the help and figure that out. run your app and use that tool to point to the list you are automating. it will return you lots of information. screen capture and post that stuff. I need the Window and Control information to see what we can do.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

Here is the script:

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

;Press Esc to terminate script, Pause/Break to "pause"

Global $g_bPaused = False

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ; Shift-Alt-d

While 1
;This script works with Allscripts PM in fullscreen on a 1920x1080 monitor
WinActivate ('Allscripts PM')
;Clicks the patient search button in Registration
Sleep (2000)
MouseClick ('Primary', 503, 200, 1, 0)
;Selects patient from list
Send ('a')
MouseClick ('Primary', 1050, 599, 1, 0)
Send ('{ENTER}{ENTER}{DOWN}{ENTER}')
Sleep (2000)
;If a error window pops up will close that window
MouseClick ('Primary', 1177, 685, 1, 0)
Sleep (2000)
;Clicks the policy tab
MouseClick ('Primary', 490, 100, 1, 0)
;Clicks the Exp Date box
MouseClick ('Primary', 528, 441, 1, 0)
Send ('01/01/2020')
;Enters in Cert No.
MouseClick ('Primary', 385, 252, 1, 0)
MouseClick ('Primary', 362, 533, 1, 0)
Send ('1234')
MouseClick ('Primary', 388, 268, 1, 0)
MouseClick ('Primary', 362, 533, 1, 0)
Send ('1234')
;Clicks the account tab
MouseClick ('Primary', 412, 104, 1, 0)
;Changes contact birthdate for multiple contacts
Sleep (2000)
MouseClick ('Primary', 703, 476, 1, 0)
Send ('01/01/1970')
;Changes contacts gender
MouseClick ('Primary', 801, 455, 1, 0)
MouseClick ('Primary', 802, 484, 1, 0)
Sleep (2000)
MouseClick ('Primary', 402, 311, 1, 0)
Sleep (2000)
MouseClick ('Primary', 703, 476, 1, 0)
Sleep (2000)
Send ('01/01/1970')
;Changes contacts gender
MouseClick ('Primary', 801, 455, 1, 0)
MouseClick ('Primary', 802, 484, 1, 0)
Sleep (2000)
;Clicks ok if a message box pops up
MouseClick ('Primary', 1033, 610, 1, 0)
Sleep (2000)
;Clicks the patient tab
MouseClick ('Primary', 343, 105, 1, 0)
;Clicks the home phone box
MouseClick ('Primary', 714, 261, 1)
Sleep (2000)
Send ('8102300338')
;Clicks the last name box
Sleep (2000)
MouseClick ('Primary', 341, 285, 1)
;Replaces all the patient information
Sleep (2000)
Send ('x x')
Send ('{TAB}')
Send ('x')
Send ('{TAB}')
Send ('x')
Send ('{TAB}')
Send ('x')
Send ('{TAB}')
Sleep (2000)
Send ('x')
;If a change address window pops up
MouseClick ('Primary', 989, 616, 1)
Send ('{TAB}')
Send ('x')
Sleep (2000)
;Clicks the city box
MouseClick ('Primary', 342, 381, 1)
Sleep (2000)
Send ('Flint')
Send ('{TAB}')
Send ('{TAB}')
Send ('48507')
Send ('{Enter}')
Send ('{Down}')
Send ('{Down}')
Send ('{Enter}')
MouseClick ('Primary', 1047, 606, 1)
Sleep (2000)
;Clicks the social security button
MouseClick ('Primary', 576, 256, 1, 0)
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('123456789')
Sleep (2000)
Send ('{ENTER}')
;Clicks the save button
MouseClick ('Primary', 1813, 1010, 1, 0)
;Clicks the Summary tab
MouseClick ('Primary', 269, 104, 1, 0)
Sleep (2000)
WEnd

Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox($MB_SYSTEMMODAL, "", "This is a message.")
EndFunc   ;==>ShowMessage

Window.png

Control.png

Posted (edited)

good. those are VB6 forms no doubt. We need to figure out how to manipulate the flexgrid. can you make the window bigger so I can see all the control text? you can manipulate that direct most likely.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted (edited)

hey, I found this. Looks like that flexgrid does not expose itself to COM for automation. however, check this

Send("^c")
Sleep(250)
Local $Value = ClipGet()
MsgBox(0,"Value",$Value)

see if that gets you the values from each row. then, when the values are null or not changing then you know you are at the bottom

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

There is a part I forgot to mention that happens when all the patients are cleared out for a letter; there is some text that says "(no matching records). I tried using this bit of code:

If ControlGetText ("[CLASS:MSFlexGridWndClass; INSTANCE:1]", "", "(no matching records)") Then
   ExitLoop
EndIf

to check if that text pops up to end the script but ControlGetText is not finding that specific string. I am including a picture of the window and the window info to see if I am possibly overlooking something.

patient lookup.png

Posted (edited)

yes. because the VB6 FlexGrid from MS is not built to allow automation. You are relegated to keystrokes and mouse clicks

If you manually click on the description box you have highlighted and press keys Ctrl-C can you then Ctrl-V to notepad with that text? if so, it's in the clipboard and we need to figure out how to get to it.

that's where to insert that code snippet to see if it works.

use the <> code tags to insert your program so it is readable please. like

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

;Press Esc to terminate script, Pause/Break to "pause"

Global $g_bPaused = False

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ; Shift-Alt-d

While 1
;This script works with Allscripts PM in fullscreen on a 1920x1080 monitor
WinActivate ('Allscripts PM')
;Clicks the patient search button in Registration
Sleep (2000)
MouseClick ('Primary', 503, 200, 1, 0)
;Selects patient from list
Send ('a')
MouseClick ('Primary', 1050, 599, 1, 0)
Send ('{ENTER}{ENTER}{DOWN}{ENTER}')
Sleep (2000)
;If a error window pops up will close that window
MouseClick ('Primary', 1177, 685, 1, 0)
Sleep (2000)
;Clicks the policy tab
MouseClick ('Primary', 490, 100, 1, 0)
;Clicks the Exp Date box
MouseClick ('Primary', 528, 441, 1, 0)
Send ('01/01/2020')
;Enters in Cert No.
MouseClick ('Primary', 385, 252, 1, 0)
MouseClick ('Primary', 362, 533, 1, 0)
Send ('1234')
MouseClick ('Primary', 388, 268, 1, 0)
MouseClick ('Primary', 362, 533, 1, 0)
Send ('1234')
;Clicks the account tab
MouseClick ('Primary', 412, 104, 1, 0)
;Changes contact birthdate for multiple contacts
Sleep (2000)
MouseClick ('Primary', 703, 476, 1, 0)
Send ('01/01/1970')
;Changes contacts gender
MouseClick ('Primary', 801, 455, 1, 0)
MouseClick ('Primary', 802, 484, 1, 0)
Sleep (2000)
MouseClick ('Primary', 402, 311, 1, 0)
Sleep (2000)
MouseClick ('Primary', 703, 476, 1, 0)
Sleep (2000)
Send ('01/01/1970')
;Changes contacts gender
MouseClick ('Primary', 801, 455, 1, 0)
MouseClick ('Primary', 802, 484, 1, 0)
Sleep (2000)
;Clicks ok if a message box pops up
MouseClick ('Primary', 1033, 610, 1, 0)
Sleep (2000)
;Clicks the patient tab
MouseClick ('Primary', 343, 105, 1, 0)
;Clicks the home phone box
MouseClick ('Primary', 714, 261, 1)
Sleep (2000)
Send ('8102300338')
;Clicks the last name box
Sleep (2000)
MouseClick ('Primary', 341, 285, 1)
;Replaces all the patient information
Sleep (2000)
Send ('x x')
Send ('{TAB}')
Send ('x')
Send ('{TAB}')
Send ('x')
Send ('{TAB}')
Send ('x')
Send ('{TAB}')
Sleep (2000)
Send ('x')
;If a change address window pops up
MouseClick ('Primary', 989, 616, 1)
Send ('{TAB}')
Send ('x')
Sleep (2000)
;Clicks the city box
MouseClick ('Primary', 342, 381, 1)
Sleep (2000)
Send ('Flint')
Send ('{TAB}')
Send ('{TAB}')
Send ('48507')
Send ('{Enter}')
Send ('{Down}')
Send ('{Down}')
Send ('{Enter}')
MouseClick ('Primary', 1047, 606, 1)
Sleep (2000)
;Clicks the social security button
MouseClick ('Primary', 576, 256, 1, 0)
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('{BACKSPACE}')
Send ('123456789')
Sleep (2000)
Send ('{ENTER}')
;Clicks the save button
MouseClick ('Primary', 1813, 1010, 1, 0)
;Clicks the Summary tab
MouseClick ('Primary', 269, 104, 1, 0)
Sleep (2000)
WEnd

Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox($MB_SYSTEMMODAL, "", "This is a message.")
EndFunc   ;==>ShowMessage

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted (edited)

If I were you, I would look into OCR autoit scripts so it can recognize the text when it happens.

 

Edited by Earthshine

My resources are limited. You must ask the right questions

 

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
×
×
  • Create New...