Skip to content

Commit

Permalink
设置 gesturez 模块只加载一次 gdip
Browse files Browse the repository at this point in the history
  • Loading branch information
linxinhong committed Dec 14, 2019
1 parent 9d3617a commit 3d59584
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
15 changes: 9 additions & 6 deletions lib/class_gesturez.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class gesturez {
this.gestureList := {}
this.gestruePNGdir := A_ScriptDir "\ges\"
this.gesturePNGSave := false
this.ElapsedTime := 120
this.ElapsedTime := 200
this.OCRMode := false
this.OCRMode_min_direction_count := 1
this.gdip_Token := Gdip_Startup()
}
}

Expand Down Expand Up @@ -79,6 +80,9 @@ class gesturez {
}
}

exit() {
GDIP_Shutdown(gesturez.self.gdip_Token)
}
Recognize() {
Critical
OCRMode := gesturez.self.OCRMode
Expand All @@ -102,13 +106,12 @@ class gesturez {
if (ElapsedTime < gesturez.self.ElapsedTime) {
send {%A_ThisHotkey%}
}
if (IsDrawLine and pToken) {
if (IsDrawLine and gesturez.self.gdip_Token) {
Gdip_DeletePen(pPen)
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
}
if (ElapsedTime >= gesturez.self.ElapsedTime) {
if (OCRMode) {
Expand Down Expand Up @@ -148,7 +151,7 @@ class gesturez {
Gui, gesturez: Show, NA W%Width% H%Height%
Gui, gesturez: Default
hwnd1 := WinExist()
if (not pToken := GDIP_StartUp()) {
if (not gesturez.self.gdip_Token) {
return
}
hbm := CreateDIBSection(Width, Height)
Expand All @@ -175,8 +178,9 @@ class gesturez {
Review() {
pr := gesturez.self.pr
pfile := gesturez.self.gestruePNGdir "GestureZ" A_Now ".png"
If !pToken := Gdip_Startup()
if (not gesturez.self.gdip_Token) {
return
}
width:= pr.xmax - pr.xmin + 20
height:= pr.ymax - pr.ymin + 20
xmin := pr.xmin - 10
Expand All @@ -198,7 +202,6 @@ class gesturez {
Gdip_DeletePen(pPen)
Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G2)
Gdip_Shutdown(pToken)
tooltip 识别手势中...
RunWaitOne( A_ScriptDir "\lib\tesseract.exe " pfile " " A_TEMP "\gesturez.output -l gesture --psm 7 --tessdata-dir " A_ScriptDir "\lib")
FileRead, gestext, %A_TEMP%\gesturez.output.txt
Expand Down
4 changes: 4 additions & 0 deletions lib/class_quickz.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@
; }
FileAppend, % "`n" A_YYYY "/" A_MM "/" A_DD " " A_Hour ":" A_Min ":" A_Sec " [ " string.topic " ] " string.content , % quickz.self.logFile
}

exit() {
gesturez.exit()
}
}
8 changes: 8 additions & 0 deletions user/gesture/gesture.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ WinMaximize() {

calc() {
run calc
}

copy() {
send ^c
}

paste() {
send ^v
}
4 changes: 3 additions & 1 deletion user/gesture/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ gesture:
8: WinMinimize
2: WinMaximize
c: calc
68: calc
68: calc
3: paste
1: copy

0 comments on commit 3d59584

Please sign in to comment.