Skip to content

Commit

Permalink
Autohotkey OCS tool
Browse files Browse the repository at this point in the history
To make full use of autohotkey for chart review, it's essential to read from the display, and recognize the date/person/exam etc...

thus to start, we need autohotkey OCS module
  • Loading branch information
FMDR-YU committed Apr 7, 2022
1 parent 6a3cf85 commit 9af5d77
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions Autohotkey OCS tool.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

#CommentFlag Find the most recent patient visit


;hotkey to activate OCR
+!q::
getSelectionCoords(x_start, x_end, y_start, y_end)
RunWait, C:\documents\mhk\Capture2Text\Capture2Text.exe %x_start% %y_start% %x_end% %y_end%
MsgBox, In area :: x_start: %x_start% --> x_end: %x_end% , y_start: %y_start% --> y_end: %y_end%`n`nFound Text:`n`n%clipboard%
return

; creates a click-and-drag selection box to specify an area
getSelectionCoords(ByRef x_start, ByRef x_end, ByRef y_start, ByRef y_end) {
;Mask Screen
Gui, Color, FFFFFF
Gui +LastFound
WinSet, Transparent, 50
Gui, -Caption
Gui, +AlwaysOnTop
Gui, Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%,"AutoHotkeySnapshotApp"

;Drag Mouse
CoordMode, Mouse, Screen
CoordMode, Tooltip, Screen
WinGet, hw_frame_m,ID,"AutoHotkeySnapshotApp"
hdc_frame_m := DllCall( "GetDC", "uint", hw_frame_m)
KeyWait, LButton, D
MouseGetPos, scan_x_start, scan_y_start
Loop
{
Sleep, 10
KeyIsDown := GetKeyState("LButton")
if (KeyIsDown = 1)
{
MouseGetPos, scan_x, scan_y
DllCall( "gdi32.dll\Rectangle", "uint", hdc_frame_m, "int", 0,"int",0,"int", A_ScreenWidth,"int",A_ScreenWidth)
DllCall( "gdi32.dll\Rectangle", "uint", hdc_frame_m, "int", scan_x_start,"int",scan_y_start,"int", scan_x,"int",scan_y)
} else {
break
}
}

;KeyWait, LButton, U
MouseGetPos, scan_x_end, scan_y_end
Gui Destroy

if (scan_x_start < scan_x_end)
{
x_start := scan_x_start
x_end := scan_x_end
} else {
x_start := scan_x_end
x_end := scan_x_start
}

if (scan_y_start < scan_y_end)
{
y_start := scan_y_start
y_end := scan_y_end
} else {
y_start := scan_y_end
y_end := scan_y_start
}
}

0 comments on commit 9af5d77

Please sign in to comment.