1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
| class DM: def __init__(self): self.dm = None self.register()
def register(self, reg_code='yonghu84f875b03fb0d5c536a56a631156628a', ver_info='yk4551187'): try: dirPath = os.path.dirname(__file__) reg_dm = ctypes.windll.LoadLibrary(dirPath + r'\dmdll\DmReg.dll') reg_dm.SetDllPathW(dirPath + r'\dmdll\dm.dll', 0) dm = CreateObject(r'dm.dmsoft') ret = dm.Reg(reg_code, ver_info) if ret == 1: print('[SUCCESS]大漠注册码有效') self.dm = dm return dm elif ret == -2: print('[ERROR]进程没有以管理员方式运行') exit(0) elif ret == -1: print('[ERROR]无法连接网络') exit(0) elif ret == 0: print('[ERROR]失败,未知错误') exit(0) elif ret == 2: print('[ERROR]余额不足') exit(0) elif ret == 3: print('[ERROR]绑定了本机器,但是账户余额不足50元') exit(0) elif ret == 4: print('[ERROR]注册码错误') exit(0) elif ret == 5: print('[ERROR]你的机器或者IP在黑名单列表中或者不在白名单列表中') exit(0) elif ret == 777: print( '[ERROR]同一个机器码注册次数超过了服务器限制,被暂时封禁. 请登录后台,插件今日详细消费记录里,相应的机器码是否有次数异常,并立刻优化解决.如果还有问题,可以联系我来解决.') exit(0) else: print('[ERROR]', ret) exit(0) except Exception as e: print(e) exit(1)
def Version(self): print(self.dm.Ver())
def newDM(self): return CreateObject(r'dm.dmsoft')
class DMutil: def __init__(self, dm): self.dm = dm def 找图(self, x1, y1, x2, y2, picName, dataColor="505050", sim=0.9, dir=0): pic_ret = self.dm.FindPicE(x1, y1, x2, y2, picName, dataColor, sim, dir) if pic_ret != '-1|-1|-1': items = pic_ret.split("|") print("找到图片信息--->", items) return [int(items[1]), int(items[2])] else: print("定位不到图片", pic_ret, picName) return [None, None] def 找图成功点击(self, x1, y1, x2, y2, picName, dataColor="505050", sim=0.9, dir=0): res = self.findPic(x1, y1, x2, y2, picName, dataColor, sim, dir) if res[0] and res[1]: self.dm.移动鼠标(res[0], res[1]) self.dm.LeftClick() print("点击成功---->", res) return 1 return 0 def 找图直到成功点击(self, x1, y1, x2, y2, picName, 偏移x=0, 偏移y=0, 延迟=0, dataColor="505050", sim=0.9, dir=0): while True: res = self.findPic(x1, y1, x2, y2, picName, dataColor, sim, dir) if res[0] and res[1]: res[0] = res[0] + int(偏移x) res[1] = res[1] + int(偏移y) self.移动鼠标(res[0], res[1]) self.dm.LeftClick() print("点击成功---->", res, picName) time.sleep(延迟) return 1 else: print("没找到---", res, picName) def 多图直到成功点击(self, 数组, 偏移x=0, 偏移y=0, 延迟=0, dataColor="505050", sim=0.9, dir=0): while True: for item in 数组: x1, y1, x2, y2, picName = item res = self.findPic(x1, y1, x2, y2, picName, dataColor, sim, dir) if res[0] and res[1]: res[0] = res[0] + int(偏移x) res[1] = res[1] + int(偏移y) self.移动鼠标(res[0], res[1]) self.dm.LeftClick() print("点击成功---->", res, picName) time.sleep(延迟) return 1 else: print("没找到---", res, picName) def 找图偏移点击(self, x1, y1, x2, y2, picName, 偏移x, 偏移y, 延迟=0, dataColor="505050", sim=0.9, dir=0): res = self.findPic(x1, y1, x2, y2, picName, dataColor, sim, dir) if res[0] and res[1]: self.移动鼠标(res[0] + int(偏移x), res[1] + int(偏移y)) print(res[0] + int(偏移x), res[1] + int(偏移y)) self.dm.LeftClick() print("点击成功---->", res) time.sleep(延迟) return 1 else: return 0 def 多图偏移点击Ex(self, 数组, 偏移x, 偏移y, 延迟=0, dataColor="505050", sim=0.9, dir=0): for item in 数组: x1, y1, x2, y2, picName = item res = self.findPic(x1, y1, x2, y2, picName, dataColor, sim, dir) if res[0] and res[1]: self.移动鼠标(res[0] + int(偏移x), res[1] + int(偏移y)) print(res[0] + int(偏移x), res[1] + int(偏移y)) self.dm.LeftClick() print("点击成功---->", res) time.sleep(延迟) return 1 return 0
def 移动鼠标(self, x, y, 随机=True): if 随机 == True: self.dm.MoveTo(x, y) else: self.dm.MoveTo(x + random.randint(1, 5), y + random.randint(1, 5)) def 点击(self, x, y): self.移动鼠标(x, y) self.dm.LeftClick()
def 按住(self, x, y, yc_time): self.移动鼠标(x, y) self.dm.LeftDown() time.sleep(yc_time) self.dm.LeftUp()
def 滑动(self, x1, y1, x2, y2): self.移动鼠标(x1, y1) self.dm.LeftDown() time.sleep(0.5) self.移动鼠标(x2, y2) time.sleep(0.5) self.dm.LeftUp() time.sleep(0.5)
def 截图(self, x1, y1, x2, y2, file): self.dm.Capture(x1, y1, x2, y2, file)
|