Skip to content

Instantly share code, notes, and snippets.

@fnx4
Last active April 3, 2021 20:05
Show Gist options
  • Select an option

  • Save fnx4/fa0cbb79a495c6894a402417c078befe to your computer and use it in GitHub Desktop.

Select an option

Save fnx4/fa0cbb79a495c6894a402417c078befe to your computer and use it in GitHub Desktop.

Revisions

  1. fnx4 revised this gist Apr 3, 2021. 6 changed files with 50 additions and 7 deletions.
    2 changes: 2 additions & 0 deletions .gitignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    /_prmt.lnk
    /_absr.lnk
    Binary file added p1.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added p2.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added p3.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    50 changes: 43 additions & 7 deletions prmt.ahk
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,54 @@
    ;CoordMode Mouse, Screen
    Run("new")

    tgtMonitor = 2
    Search("p3.png", tgtMonitor)
    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(srcImg, 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 Could not conduct the search
    MsgBox Exception
    } else if (ErrorLevel = 1) {
    if (srcImg == "p3.png") {
    Search("p2.png", tgtMonitor)
    LegacyTranslate("p2.png", tgtMonitor)
    } else if (srcImg == "p2.png") {
    Search("p1.png", tgtMonitor)
    LegacyTranslate("p1.png", tgtMonitor)
    } else if (srcImg == "p1.png") {
    MsgBox Not found
    }
    @@ -22,4 +57,5 @@ Search(srcImg, tgtMonitor) {
    Click %xi%, %yi%, 0
    }


    }
    5 changes: 5 additions & 0 deletions run.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    @echo off
    start _prmt.lnk
    start _absr.lnk
    start prmt.ahk
    exit
  2. fnx4 created this gist Apr 3, 2021.
    25 changes: 25 additions & 0 deletions prmt.ahk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    ;CoordMode Mouse, Screen

    tgtMonitor = 2
    Search("p3.png", tgtMonitor)

    Search(srcImg, tgtMonitor) {

    SysGet, Mon, Monitor, %tgtMonitor%
    ImageSearch, xi, yi, %MonLeft%, %MonTop%, %MonRight%, %MonBottom%, %A_WorkingDir%\%srcImg%
    if (ErrorLevel = 2) {
    MsgBox Could not conduct the search
    } else if (ErrorLevel = 1) {
    if (srcImg == "p3.png") {
    Search("p2.png", tgtMonitor)
    } else if (srcImg == "p2.png") {
    Search("p1.png", tgtMonitor)
    } else if (srcImg == "p1.png") {
    MsgBox Not found
    }
    } else {
    ;MsgBox Icon %srcImg%: %xi%x%yi%
    Click %xi%, %yi%, 0
    }

    }