简体   繁体   中英

AHK Branching KeyWaits in Middle of Hotkey

I work in a doctors office doing billing. The programs made for this job are very basic and are absolutely riddled with bugs, so I repeat parts of my code a lot to make certain they work. I used two programs, one for the billing side, one for the chart. Right now, my hotkey grabs the date of birth and Medical Record Number of the patient from the billing side, goes to the chart side, searches for the patient based on those two things (normally the MRN would be sufficient, but Epic blows, so it's not enough) selects the patient, clicks "Chart Review," then waits for me to select a service date. Upon left click, it tabs back into the billing side so I can copy information to it. the issue is, sometimes the patient did not show up, and I have to record this. If they didn't show, there's no chart to click, and I have to click somewhere else to double check that they didn't show. I need a branching type of keywait where if I click, it tabs into the billing side, or if I hit A or something, it clicks appointments, and past, then tabs back to billing and clicks "Typed Notes". I can manage everything besides the branching part. Getkeystate statements don't seem to work, and I can't use an if statement with keywaits (apparently).

!D::
BlockInput, MouseMoveOff
sleep 100
Winactivate, Hyperspace
sleep 100
sendinput ^w
sleep 300
winactivate, Form billing
sleep 300
BlockInput, MouseMove
mouseclick,, 400, 70
BlockInput, MouseMove
click
sleep 200
sendinput ^c
sleep 400
dob:=Clipboard
sleep 400
BlockInput, MouseMove
mouseclick,, 385, 85
BlockInput, MouseMove
click
sleep 200
sendinput ^c
WinActivate, Hyperspace
sleep 400
sendinput ^3
sleep 400
sendinput ^v
sleep 400
BlockInput, MouseMove
mouseclick,, 200, 145
sleep 400
Clipboard:=dob
sleep 400
StringTrimLeft, dobyear, dob, 6
sleep 50
dobmathd:=A_YYYY-dobyear
sleep 50
StringTrimRight, dobmo, dob, 8
sleep 50
StringTrimRight, dobd, dob, 5
sleep 50
StringTrimLeft, dobday, dobd, 3
sleep 50
if (dobmo >= A_MM) and (dobday >= A_DD)
{
dobmathd--
}
sleep 50
sendinput ^v
sleep 200
sendinput {Enter}
sleep 200
sendinput {Enter}
sleep 1700
BlockInput, MouseMove
mouseclick,, 85, 235
sleep 300
BlockInput, MouseMoveOff
;if (character = a)
;{
;BlockInput, MouseMove
;mouseclick,, 325, 40
;sleep 200
;mouseclick,, 60, 285
;click
;sleep 400
;mouseclick,, 240, 435
;sleep 2000
;winactivate, Form billing
;BlockInput, MouseMoveOff
;return
;}
;if (
tooltip,%dobmathd% Years old, 415, 70
keywait, LButton, D, T200
sleep 200
winactivate, Form billing
return

The commented part was my last attempt, but I've been googling to find a real idea to try for a while. Any help is appreciated!

Edit: Maybe a "if I click here do this, or if I click here do this" kind of statement will work. I can get the dimensions of the Chart Review window vs the toolbar button for appointments. I've been experimenting with this for another task, but it might work here. Help with that would be appreciated too!

Edit: @Bob, Actually, and sorry for the late reply, I found that looping a small statement with a few keywaits of very short lengths works well for me. I'll paste my code below. And this is just a snippet, so it's not the full code.

SendInput, {Enter}
Sleep, 1800
BlockInput, MouseMove
MouseClick,, 85, 235
Sleep, 300
BlockInput, MouseMoveOff
Sleep, 20
Loop
{
    KeyWait, LButton, D, T0.02 ;I've picked a chart, meaning they showed up for their appointment
    If !ErrorLevel
    {
        Sleep, 400
        BlockInput, MouseMoveOff
        WinActivate, Form CMP
        Return
    }
    KeyWait, Escape, D, T0.02
    If !ErrorLevel
        Return
    KeyWait, ., D, T0.02 ;They do not appear to have shown up for their appointment, so check the appointment tab
    If !ErrorLevel
    {
        BlockInput, MouseMove
        MouseClick,, 315, 40
        Sleep, 400
        MouseClick,, 100, 285
        Sleep, 1000
        MouseClick,, 270, 440
        Sleep, 300
        BlockInput, MouseMoveOff
        Loop
        {
            KeyWait, Y, D, T0.02 ;They did not show up for their appointment. Bill appropriately.
            If !ErrorLevel
            {
                BlockInput, MouseMove
                WinActivate, Form CMP
                Sleep, 200
                MouseClick,, 210, 260
                Sleep, 200
                MouseClick,, 100, 400
                Sleep, 200
                SendInput, No Show
                Sleep, 200
                WinActivate, Hyperspace
                Sleep, 500
                MouseClick,, 85, 235
                Sleep 400
                WinActivate, Form CMP
                Sleep, 300
                BlockInput, MouseMoveOff
                Return
            }
            KeyWait, N, D, T0.02 ;Don't see a no show, re-check chart review.
            If !ErrorLevel
            {
                BlockInput, MouseMove
                MouseClick,, 85, 235
                Sleep, 500
                BlockInput, MouseMoveOff
                KeyWait, LButton, D
                Sleep, 400
                WinActivate, Form CMP
                BlockInput, MouseMoveOff                    
                Return
            }
            KeyWait, Escape, D, T0.02
            If !ErrorLevel
                Return
        }
    }
}

I can't use an if statement with keywaits

There is a way to "abuse" Input command with L1 and V (might be good idea to throw in I as well) options to act as (somewhat limited) KeyWait replacement. That should work for your usage case.

(...)
Input,var,L1IV ; will act as KeyWait
if (var="a") {
    foo:=Round(Sqrt(1764))
    TrayTip,,The number is %foo%
}
else if (var="s")
  MsgBox Sssnaaakess 
(...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM