Skip to content

Instantly share code, notes, and snippets.

@fnx4
Last active April 3, 2021 20:05
Show Gist options
  • Save fnx4/fa0cbb79a495c6894a402417c078befe to your computer and use it in GitHub Desktop.
Save fnx4/fa0cbb79a495c6894a402417c078befe to your computer and use it in GitHub Desktop.
ocr to prmt
/_prmt.lnk
/_absr.lnk
Run("new")
Run(mode) {
if (mode == "new") {
Hotkey, !PrintScreen, Search
Hotkey, !Insert, Translate
} else if (mode == "leagcy") {
;CoordMode Mouse, Screen
tgtMonitor = 2
LegacyTranslate("p3.png", tgtMonitor)
}
}
Search() {
if (WinExist("ahk_exe ScreenshotReader.exe")) {
ControlClick, x237 y31, ahk_exe ScreenshotReader.exe
} else {
MsgBox ScreenshotReader.exe not found
}
}
Translate() {
if (WinExist("ahk_exe prmt.exe")) {
WinActivate
ControlClick, x16 y190, ahk_exe prmt.exe,,,3
Sleep 300
Send ^a
Sleep 250
Send {Delete}
Sleep 250
Clipboard = %Clipboard%
;Send Clipboard
Send ^v
Sleep 100
ControlClick, x249 y64, ahk_exe prmt.exe
} else {
MsgBox prmt.exe not found
}
}
LegacyTranslate(srcImg, tgtMonitor) {
SysGet, Mon, Monitor, %tgtMonitor%
ImageSearch, xi, yi, %MonLeft%, %MonTop%, %MonRight%, %MonBottom%, %A_WorkingDir%\%srcImg%
if (ErrorLevel = 2) {
MsgBox Exception
} else if (ErrorLevel = 1) {
if (srcImg == "p3.png") {
LegacyTranslate("p2.png", tgtMonitor)
} else if (srcImg == "p2.png") {
LegacyTranslate("p1.png", tgtMonitor)
} else if (srcImg == "p1.png") {
MsgBox Not found
}
} else {
;MsgBox Icon %srcImg%: %xi%x%yi%
Click %xi%, %yi%, 0
}
}
@echo off
start _prmt.lnk
start _absr.lnk
start prmt.ahk
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment