Skip to content

Commit

Permalink
OCR/Pixel fixes
Browse files Browse the repository at this point in the history
- remove PixelColorSimple function & import
- just use AHK's `PixelGetColor` function instead
- tweak 1080p pixel values
- note: game must be in fullscreen or borderless window matching the monitor's resolution, otherwise OCR will not capture the correct window areas
  • Loading branch information
Drumstix42 committed May 27, 2023
1 parent f3d13c9 commit 673ac71
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 28 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "temscanner-electron",
"version": "1.0.6",
"version": "1.0.7",
"description": "Temtem UI assistant (local Electron web app) for automatically displaying Wiki/API data using AutoHotkey v1 and OCR text recognition.",
"main": "./out/main/index.js",
"author": "Drumstix42",
Expand All @@ -23,7 +23,7 @@
"@vueuse/core": "^10.1.2",
"axios": "^1.4.0",
"bootstrap": "^5.3.0-alpha3",
"bootstrap-vue-next": "^0.9.0",
"bootstrap-vue-next": "^0.9.1",
"electron-updater": "^5.3.0",
"lodash-es": "^4.17.21",
"pinia": "^2.1.3",
Expand Down
10 changes: 5 additions & 5 deletions resources/AutoHotkey/TemtemOCR.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Menu, Tray, Tip, % "Temtem OCR for Temscanner"
#include %A_ScriptDir%/lib/JSON.ahk
#include %A_ScriptDir%/lib/JSONFile.ahk
#include %A_ScriptDir%/lib/OCRScreenRegion.ahk
#include %A_ScriptDir%/lib/PixelColor.ahk

; ------------------------------
; DIRECTORY
Expand Down Expand Up @@ -57,7 +56,7 @@ global WINDOW_CLIENT_H := NumGet(&RECT, 12, "Int")
; ! Sometimes the window size is the expected size, and sometimes the client is the expected size (based on Windowed vs Borderless)
; * Window resolution table
global r2560x1440 := { "MINIMAP_BLUE_BORDER_X": 2360, "MINIMAP_BLUE_BORDER_Y": 45, "TEM_NAMEPLATE1_X": 2090, "TEM_NAMEPLATE1_Y": 204, "TEM_NAMEPLATE2_X": 1560, "TEM_NAMEPLATE2_Y": 130, "TEM_NAME_WIDTH": 310, "TEM_NAME_HEIGHT": 120, "TEM_NAME1_X_START": 2034, "TEM_NAME1_Y_START": 108, "TEM_NAME2_X_START": 1502, "TEM_NAME2_Y_START": 34 }
global r1920x1080 := { "MINIMAP_BLUE_BORDER_X": 1760, "MINIMAP_BLUE_BORDER_Y": 30, "TEM_NAMEPLATE1_X": 1565, "TEM_NAMEPLATE1_Y": 130, "TEM_NAMEPLATE2_X": 1185, "TEM_NAMEPLATE2_Y": 95, "TEM_NAME_WIDTH": 250, "TEM_NAME_HEIGHT": 90, "TEM_NAME1_X_START": 1517, "TEM_NAME1_Y_START": 76, "TEM_NAME2_X_START": 1134, "TEM_NAME2_Y_START": 23 }
global r1920x1080 := { "MINIMAP_BLUE_BORDER_X": 1760, "MINIMAP_BLUE_BORDER_Y": 30, "TEM_NAMEPLATE1_X": 1557, "TEM_NAMEPLATE1_Y": 150, "TEM_NAMEPLATE2_X": 1185, "TEM_NAMEPLATE2_Y": 95, "TEM_NAME_WIDTH": 250, "TEM_NAME_HEIGHT": 90, "TEM_NAME1_X_START": 1530, "TEM_NAME1_Y_START": 76, "TEM_NAME2_X_START": 1150, "TEM_NAME2_Y_START": 23 }
global RESOLUTIONS_TABLE := { "r2560x1440": r2560x1440, "r1920x1080": r1920x1080 }

global RESOLUTION_WINDOW_KEY := "r" . WINDOW_W . "x" . WINDOW_H
Expand Down Expand Up @@ -105,17 +104,18 @@ global TEM_NAME2_Y_END := TEM_NAME2_Y_START + TEM_NAME_HEIGHT
; FUNCTIONS
; ------------------------------
isTem1Available() {
pxValue := PixelColorSimple(WINDOW_UID, TEM_NAMEPLATE1_X, TEM_NAMEPLATE1_Y)
PixelGetColor, pxValue, TEM_NAMEPLATE1_X, TEM_NAMEPLATE1_Y, RGB
;Tooltip, %pxValue% - resolution: %RESOLUTION_KEY%, 0, 0
return pxValue = TEM_NAMEPLATE_BG_COLOR
}

isTem2Available() {
pxValue := PixelColorSimple(WINDOW_UID, TEM_NAMEPLATE2_X, TEM_NAMEPLATE2_Y)
PixelGetColor, pxValue, TEM_NAMEPLATE2_X, TEM_NAMEPLATE2_Y, RGB
return pxValue = TEM_NAMEPLATE_BG_COLOR
}

isOutOfCombat() {
pxValue := PixelColorSimple(WINDOW_UID, MINIMAP_BLUE_BORDER_X, MINIMAP_BLUE_BORDER_Y)
PixelGetColor, pxValue, MINIMAP_BLUE_BORDER_X, MINIMAP_BLUE_BORDER_Y, RGB
; * minimap doesn't show in combat
return pxValue = MINIMAP_BLUE_BORDER_COLOR
}
Expand Down
Binary file modified resources/AutoHotkey/TemtemOCR.exe
Binary file not shown.
17 changes: 0 additions & 17 deletions resources/AutoHotkey/lib/PixelColor.ahk

This file was deleted.

8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1019,10 +1019,10 @@ boolean@^3.0.1:
resolved "https://registry.yarnpkg.com/boolean/-/boolean-3.2.0.tgz#9e5294af4e98314494cbb17979fa54ca159f116b"
integrity sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==

bootstrap-vue-next@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/bootstrap-vue-next/-/bootstrap-vue-next-0.9.0.tgz#fb528e07666f827acdc3c4927a21bfbddab16c63"
integrity sha512-UXFhK3scyZwhB6NFPwxHHkhaHIJQRFX/Ph3e5a/mNtcKIfUKEehvSIWnNf42J1+xnQgGVFtwruQL+lwx2L7nHQ==
bootstrap-vue-next@^0.9.1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/bootstrap-vue-next/-/bootstrap-vue-next-0.9.1.tgz#8d8753e44841bad7bd6dc6b700f9f8752bff67e2"
integrity sha512-Oxmn6jSER8HpLwoukncAqqeP2mU0PnMy7nh9rKfOo2t48KesHDSbNKcuZi1eddoM/rx9CgVP0KbjyQ5z+8QX9w==
dependencies:
"@floating-ui/vue" "^1.0.0"
"@vueuse/core" "^10.1.2"
Expand Down

0 comments on commit 673ac71

Please sign in to comment.