forked from wgwjifeng/op
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f190df3
commit cfb496a
Showing
17 changed files
with
209 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,77 @@ | ||
|
||
from win32com.client import Dispatch | ||
#创建com对象 | ||
op=Dispatch("op.opsoft"); | ||
#输出插件版本号 | ||
print("op ver:",op.Ver()); | ||
#测试窗口接口 | ||
hwnd=op.FindWindow("","op_test.txt - 记事本"); | ||
#ocr-设置字库 | ||
r=op.SetDict(0,"test.dict"); | ||
print("SetDict:",r); | ||
r=0; | ||
if hwnd: | ||
r=op.BindWindow(hwnd,"gdi","normal","windows",0); | ||
if r: | ||
print("bind ok."); | ||
r=op.Sleep(1000); | ||
print("try screencap"); | ||
r=op.Capture(0,0,100,100,"screen.bmp"); | ||
r,x,y=op.FindColor(0,0,121,159,"000000-050505",0.9,1); | ||
print(r,x,y); | ||
if r: | ||
op.MoveTo(x,y); | ||
op.LeftClick(); | ||
print("ocr:",op.Ocr(0,0,100,100,"000000",1.0)); | ||
print(op.GetColor(165,164)); | ||
print("wait key 65"); | ||
op.WaitKey(65,5000); | ||
op.UnBindWindow(); | ||
else: | ||
print("bind false."); | ||
else: | ||
print("invalid window."); | ||
class Demo: | ||
def __init__(self): | ||
#创建com对象 | ||
self.op=op=Dispatch("op.opsoft"); | ||
self.hwnd=0; | ||
self.send_hwnd=0; | ||
|
||
def test_base(self): | ||
#输出插件版本号 | ||
print("op ver:",self.op.Ver()); | ||
r=self.op.WinExec("notepad",1); | ||
print("Exec notepad:",r); | ||
|
||
|
||
|
||
def test_window_api(self): | ||
#测试窗口接口 | ||
|
||
self.hwnd = self.op.FindWindow("","无标题 - 记事本"); | ||
print("parent hwnd:",self.hwnd); | ||
if self.hwnd: | ||
self.send_hwnd=self.op.FindWindowEx(self.hwnd,"Edit",""); | ||
print("child hwnd:",self.send_hwnd); | ||
return 0; | ||
|
||
def test_bkmode(self): | ||
r=self.op.BindWindow(self.hwnd,"gdi","normal","windows",0); | ||
if r == 0: | ||
print("bind false"); | ||
return r; | ||
|
||
def test_bkmouse_bkkeypad(self): | ||
self.op.MoveTo(200,200); | ||
self.op.Sleep(200); | ||
self.op.LeftClick(); | ||
self.op.Sleep(1000); | ||
r=self.op.SendString(self.send_hwnd,"Hello World!"); | ||
print("SendString ret:",r); | ||
self.op.Sleep(2000); | ||
return 0; | ||
|
||
def test_bkimage(self): | ||
self.op.GetColor(30,30); | ||
self.op.Capture(0,0,100,100,"bkimgae.bmp"); | ||
return 0; | ||
|
||
def test_ocr(self): | ||
#ocr-设置字库 | ||
r=self.op.SetDict(0,"test.dict"); | ||
print("SetDict:",r); | ||
s=self.op.OcrAuto(0,0,100,100,1.0); | ||
print("ocr:",s); | ||
s=self.op.OcrEx(0,0,100,100,"000000-020202",1.0); | ||
print("OcrEx:",s); | ||
return 0; | ||
|
||
|
||
def test_all(): | ||
demo=Demo(); | ||
demo.test_base(); | ||
demo.test_window_api(); | ||
if demo.test_bkmode() == 0: | ||
return 0; | ||
demo.test_bkmouse_bkkeypad(); | ||
demo.test_bkimage(); | ||
demo.test_ocr(); | ||
|
||
return 0; | ||
|
||
#run all test | ||
print("test begin"); | ||
test_all(); | ||
print("test end"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.