使用 OfflineMapMaker 下载离线地图、不输入授权码只能下载最多缩放到13级别的数据、网上搜了下整了个 破解版 OfflineMapMaker 下载地图、无奈破解版的每运行几分钟就会提示授权码有问题、程序停止。花个钱买正版的也要小100$、划不来、只是为了学习一下而已、刚好第一次使用Python 学习一下如何使用也正好。
示图
使用pyautogui模拟人为操作
每运行几分钟就停止程序
一、pyautogui是什么?自动化的就不多说了,网上多的是,随便找一个感谢这位作者 的文章看看就行了,也是第一次使用python去写东西,就当是学习拉,总之会编程的还是可以看懂python、言归正传,下面开始造。
二、使用步骤 1.引入库2.运行软件 OfflineMapMaker 软件import subprocess #
import os
import schedule #本想使用定时去执行的
import pyautogui
import time
import datetime
import threading
def run_OfflineMapMaker_exe():
exe = "G:/softInstall/omm/omm.exe"
if os.path.exists(exe):
subprocess.Popen(exe)
# os.system(exe)
# f = os.popen(exe)
# data = f.readline()
# f.close()
# print(data)
time.sleep(1)
3.运行软件 OfflineMapMaker 软件
def voidRunFrom():
#pyautogui.press('enter', 3) # 敲2次回车,去掉2个提示
time.sleep(2)
#睡眠1秒后、开始操作
print('睡眠1秒后、开始操作')
#wind键操作、显示桌面
# pyautogui.keyDown('Win') #摁住Win键
# pyautogui.press('d') #按一下D键
# pyautogui.keyUp('win') #松开Win键
pyautogui.hotkey('Win', 'd')
time.sleep(2)
# # 进入桌面获取到OfflineMapMaker软件位置
# offline_pos = pyautogui.locateOnScreen(
# 'OfflineMapMaker.png')
# goto_pos = pyautogui.center(offline_pos)
# #鼠标移动到软件上
# #pyautogui.moveTo(goto_pos, duration=0.5)
# pyautogui.moveTo(goto_pos)
run_OfflineMapMaker_exe()
#双击打开
#pyautogui.doubleClick()
print('软件、双击打开完成!')
# pyautogui.alert(text='软件打开',title='提示',button='ok')
#鼠标移动到屏幕中间
size = pyautogui.size()
print(size.width)
pyautogui.moveTo(size.width/2, size.height/2)
#移动到地图选择器上 搜索 Google Hybrid Maps for China
pyautogui.moveRel(-350, -365, 0.5)
pyautogui.click()
# pyautogui.click(100, 105,button=left,duration=0.4)
pyautogui.press('shift') # 切换输入法
pyautogui.write('Google')
pyautogui.press('space')
pyautogui.write('Hybrid')
pyautogui.press('space')
pyautogui.write('Maps')
pyautogui.press('space')
pyautogui.write('for')
pyautogui.press('space')
pyautogui.write('China')
## 摁下Tab切换到,输入经纬度
pyautogui.press('tab', 3)
pyautogui.write('110.94035614941404') # 输入左边的经度
pyautogui.press('tab')
pyautogui.write('111.3386105439453') # 输入右边的经度
pyautogui.press('tab')
pyautogui.write('26.53871478999292') # 输入上边的纬度
pyautogui.press('tab')
pyautogui.write('26.13749744099157') # 输入下边的纬度
## 缩放程度设置
pyautogui.press('tab', 4)
pyautogui.press('up', 4) # 最小调至13
pyautogui.press('tab')
pyautogui.press('up', 9) # 最大调至21
## 输入保存位置
pyautogui.press('tab')
pyautogui.write('G:\Maps\testmaps')
## 跳到 Start 按钮
pyautogui.press('tab', 6)
## 点击开始 回车开始
pyautogui.press('enter') # pyautogui.click()
4.软件结束检测
def exe_End_Detect():
print(datetime.datetime.now())
offline_pos = pyautogui.locateOnScreen(
'OfflineMapMakerTaskStoppedEndText.png')
if offline_pos != None: # 如果不为空就敲击3下回车、结束软件
print('有数据、将会结束MapMaker软件')
goto_pos = pyautogui.center(offline_pos) # 移动到上面、只确保桌面有一个
pyautogui.moveTo(goto_pos)
pyautogui.press('enter', 3) # 敲击3下回车、结束软件
time.sleep(10) # 睡眠10秒
pyautogui.press('enter', 2) # 再次确认一下
voidRunFrom() # 再次运行
print('没有数据')
timer = threading.Timer(5, exe_End_Detect) # 5秒检测一次
timer.start()
5. 开始运行
# 定时器 (方案2)
if __name__ == '__main__':
print('开始执行MapMaker软件')
voidRunFrom() # 第一次、执行、后面由定时间检查之后再执行
t1 = threading.Timer(10, function=exe_End_Detect)
t1.start()
6.定时服务(这个方案是太浪费时间了!)
#每11分钟执行一次 (方案1)
# schedule.every(11).minutes.do(voidRunFrom)
# if __name__ == '__main__':
# #flog = True # 标识 是否数据已经全下载完成
# #isRun = False # 表示 OfflineMapMaker 软件是否在运行
# print('main函数进入、开始执行方法')
# voidRunFrom()
# print('执行定时任务')
# while True:
# schedule.run_pending()
# #voidRunFrom()
# print('运行方法结束')
总结
学习到 定时任务、定时器、等
此操作保证桌面只有一个程序运行,否则就检测不出,或乱输入了!!!
OfflineMapMaker 我使用了代理,不然是不能下载那个地图的!
如需 破解版 OfflineMapMaker 网上自己搜吧



