71 lines
1.6 KiB
AutoHotkey
71 lines
1.6 KiB
AutoHotkey
integer_of_length(num, num_len) {
|
|
num := RegExReplace(num, "[^\d+]")
|
|
return RegExMatch(num, "^\d{" . num_len . "}$")
|
|
}
|
|
|
|
;; Checks valid 10 digit number supplied (doesnt do checksums)
|
|
valid_nhs_number(patient_nhs) {
|
|
result := integer_of_length(patient_nhs, 10)
|
|
return result
|
|
}
|
|
|
|
test_valid_nhs_number() {
|
|
test1 := valid_nhs_number(1234567890) ;; pass
|
|
test2 := valid_nhs_number("123 456 7890") ;; pass
|
|
test3 := valid_nhs_number("123456789") ;; fail
|
|
|
|
if (test1 and test2 and not test3 ) {
|
|
MsgBox,,"Test","Test Passed: valid_nhs_number"
|
|
} else {
|
|
MsgBox,,"Test","Test Failed: valid_nhs_number"
|
|
}
|
|
}
|
|
|
|
; Returns bool based on presence of 'match' string in window title
|
|
check_in_win_title(match) {
|
|
WinGetTitle, Title, A
|
|
If InStr(Title, match)
|
|
{
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
; From pulovers macro creator
|
|
CenterImgSrchCoords(File, ByRef CoordX, ByRef CoordY)
|
|
{
|
|
static LoadedPic
|
|
LastEL := ErrorLevel
|
|
|
|
Gui, Pict:Add, Pic, vLoadedPic, % RegExReplace(File, "^(\*\w+\s)+")
|
|
GuiControlGet, LoadedPic, Pict:Pos
|
|
Gui, Pict:Destroy
|
|
CoordX += LoadedPicW // 2
|
|
CoordY += LoadedPicH // 2
|
|
ErrorLevel := LastEL
|
|
}
|
|
|
|
FindAndClickCenterOfImage(ImagePath, ErrorMessage:="Image Not Found")
|
|
{
|
|
CoordMode, Pixel, Screen
|
|
MsgBox,,, %ImagePath%
|
|
Sleep 500
|
|
ImageSearch, FoundX, FoundY, 0, 0, 2560, 1440, ImagePath
|
|
MsgBox,,, %FoundX%
|
|
Sleep 500
|
|
CenterImgSrchCoords(ImagePath, FoundX, FoundY)
|
|
If ErrorLevel
|
|
{
|
|
MsgBox, 49, Continue?, %ErrorMessage%`n`nPress OK to continue function.
|
|
IfMsgBox, Cancel
|
|
Return
|
|
}
|
|
If (ErrorLevel = 0)
|
|
{
|
|
CoordMode, Mouse, Screen
|
|
Click, %FoundX%, %FoundY% Left, 1
|
|
Sleep, 10
|
|
SendRaw, %EPSPin%
|
|
}
|
|
} |