We have recently made some enhancements for our Meditech Client Server Connection to deal with the issues such as its popup menus disappearing when they lose focus and the file download dialog being outside the API.  Also, we developed a facility to run multiple, concurrent C/S scripts.  Before, it was a problem because C/S scripts needed to steal focus in order to operate, so the actions of one script influenced the operation of other scripts.

 

We’ve added two new components:  a SelectIcon subroutine to navigate through a C/S icon field and a SendKey object that allows only one script to grab desktop focus at a time (attached, with documentation, see it for installation and use).

 

We implemented the following script to download a report including a Reset subroutine to move the application to its “anchor position” and a Report subroutine to run the report.  Please note that the script is in the “PauseLoop” format which we find significantly more robust and easier to read than the “Pause:Key:Pause:Key” format directly learned by the WorkStation. 

 

This script was written through a VPN connection, so several of the included Waits could be dramatically reduced on clients running through a local area network.  This also influenced its behavior when running as multiple, concurrent scripts.  In addition, the script is still sensitive to external, user interference.  These enhancements should be considered in a Beta form.  I’d appreciate your comments. 

 

Option Explicit

Const USER = "user"

Const PASSWORD = "password"

Dim S As New CSendKey   ' grabs exclusive use of Desktop's keyboard

 

Sub Reset()  ' loads Meditech Client Server, signs on and moves to Main Desktop

Dim c As Long

    At ""

    Note = "Resetting."

    Do Until At("MEDITECH Admissions Main [EMAIL PROTECTED],1")

        If Not Active Then Connect "", stMeditechCS 'connect if not already

        PauseLoop "@20,34", USER & "~"

        PauseLoop "@21,34", PASSWORD & "~"

        PauseLoop "@6,19", PASSWORD & "~"   ' password location if suspended

        PauseLoop "Outpatient [EMAIL PROTECTED],1", "{esc}"

        If At("[EMAIL PROTECTED],1") Then S.Key "Y"

        If At("Daily List By [EMAIL PROTECTED],1") Then Key "{esc}": Wait 1: S.Key "Y", R.hWnd

        If At("Print [EMAIL PROTECTED],1") Then S.Key "{esc}", R.hWnd

        PauseLoop "Overwrite Existing [EMAIL PROTECTED],1", "N"

        PauseLoop "[EMAIL PROTECTED],1", "~"

        c = c + 1: If c Mod 100 = 99 Then At "": Note = "Retrying..."

        Wait 0.5

    Loop

    At ""

End Sub

 

Sub Report()

Dim c As Long

    Reset

    Note = "Requesting Report."

    Do                  ' go to report page and fill it out

        If At("MEDITECH Admissions Main [EMAIL PROTECTED],1") Then SelectIcon 3, 1

        If At("Outpatient [EMAIL PROTECTED],1") Then SelectIcon 1, 1, "{down}{down}{down}{down}{down}{Enter}{Enter}"

        PauseLoop "@4,11", "~"

        PauseLoop "@6,11", "{F12}"

        If At("Print [EMAIL PROTECTED],1") Then S.Key "D|{Tab}|C:\bss65\down40.txt~", R.hWnd

        PauseLoop "Overwrite Existing [EMAIL PROTECTED],1", "Y"

        If At("[EMAIL PROTECTED],1") Then Key "~{esc}{esc}": Exit Do

        c = c + 1: If c > 100 Then Err.Raise seTimeOut

        Wait 0.5

    Loop

    Reset

End Sub

 

' selects icon positioned an icon field, then sends keys to popup menu

Sub SelectIcon(Down As Integer, Right As Integer, Optional MenuKeys As Variant)   ' top left icon is at 1,1

Dim i As Long, c As Long

    Key "{right}{down}"

    For i = 1 To 7: Key "{up}{left}": Next i    'go to top, left icon

    For i = 1 To Down - 1: Key "{down}": Next i

    For i = 1 To Right - 1: Key "{right}": Next i

    Wait 2 'long wait for a remote connection

    If Not IsMissing(MenuKeys) Then

        S.GetBaton

        Do

            If At("@3,1") Then S.Key "{enter}", R.hWnd: Wait 2 'R.hwnd is handle of Med CS window

            If At("@5,1") Then S.Key (MenuKeys): Exit Do

            c = c + 1

            If c Mod 20 = 19 Then At ""

            If c > 100 Then S.ReleaseBaton: Err.Raise seTimeOut

            Wait 0.5

        Loop

        S.Wait 300

        S.ReleaseBaton

    Else

        Enter

    End If

End Sub

 

Rich McNeil

Boston Software Systems

866 653 5105

www.bostonworkstation.com

 

 

Attachment: SendKey.zip
Description: Zip compressed data

Reply via email to