diff --git a/BaiHu/MV.py b/BaiHu/MV.py index 24478e49..c57ab5c0 100644 --- a/BaiHu/MV.py +++ b/BaiHu/MV.py @@ -23,10 +23,13 @@ def open_jian_ying(): # 关闭剪映 subprocess.Popen(['taskkill', '/F', '/IM', 'JianyingPro.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + time.sleep(1) # 清理剪映的草稿区 remove_dir_contents(JianYingCaoGao) # 打开剪眏 subprocess.Popen([jianYingExePath]) + time.sleep(3) + # 检查是不是已经正确打开了 while True: appwindows = get_app_list() @@ -42,16 +45,14 @@ def open_jian_ying(): time.sleep(1) # 激活剪映为当前操作窗口 - time.sleep(2) hwnd = x[0] + time.sleep(3) # 显示为当前窗口 win32gui.SetForegroundWindow(hwnd) # 移动窗口到指定的显示器左上角上去 win32gui.SetWindowPos(hwnd, win32con.HWND_TOP, wm.x, wm.y, 0, 0, win32con.SWP_NOSIZE) # 最大化 win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED) - - exit(0) # 破解剪映 crack_jian_ying() return hwnd @@ -64,7 +65,7 @@ def crack_jian_ying(): subprocess.Popen(['taskkill', '/F', '/IM', jian_ying_exe_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # 等待关闭完成 - time.sleep(1) + time.sleep(3) subprocess.Popen([jian_ying_exe_path]) # 打开破解软件 time.sleep(4) @@ -77,9 +78,9 @@ def crack_jian_ying(): is_running = True if is_running: - # wm.x win32gui.SetForegroundWindow(hwnd) - + # 移动窗口到指定的显示器左上角上去 + win32gui.SetWindowPos(hwnd, win32con.HWND_TOP, wm.x, wm.y, 0, 0, win32con.SWP_NOSIZE) pyautogui.press('enter') time.sleep(1) pyautogui.press('enter') @@ -90,14 +91,13 @@ def crack_jian_ying(): # 导入图片 def import_img(hwnd, img_path): # 开始创作 - x = 554 + x = wm.x + 554 y = 90 # 将鼠标移动到坐标处 pyautogui.moveTo(x, y) # 单击左键 pyautogui.click() - time.sleep(1) # # 此时有两个剪映专业版, 我们找第二个 @@ -112,12 +112,13 @@ def import_img(hwnd, img_path): time.sleep(1) break hwnd = x[0] + time.sleep(1) # 最大化 win32gui.ShowWindow(hwnd, win32con.SW_SHOWMAXIMIZED) time.sleep(1) - # 导入按钮 - x = 398 + # # 导入按钮 + x = wm.x + 398 y = 321 # 将鼠标移动到坐标处 pyautogui.moveTo(x, y) @@ -126,12 +127,12 @@ def import_img(hwnd, img_path): time.sleep(1) # 输入图片路径 pyautogui.typewrite(img_path) - # 回车 + # # 回车 pyautogui.press('enter') time.sleep(1) - # 【还在是选择所有图片!!!】 图片选择区域的空白部分 - x = 581 + # # 【还在是选择所有图片!!!】 图片选择区域的空白部分 + x = wm.x + 581 y = 385 pyautogui.moveTo(x, y) # 单击左键,获取焦点 @@ -143,29 +144,22 @@ def import_img(hwnd, img_path): pyautogui.press('enter') time.sleep(1) - # 关闭掉播放器 - # pyautogui.moveTo(183, 673) - # time.sleep(1) - # pyautogui.moveTo(248, 673) - # pyautogui.click() - # time.sleep(1) - - pyautogui.moveTo(173, 231) # 移动到导入区的空白位置 - pyautogui.dragTo(233, 814, 0.5, button='left') # 进行拖动 - pyautogui.dragTo(188, 810, 0.5, button='left') # 进行拖动 + pyautogui.moveTo(wm.x + 173, wm.y + 231) # 移动到导入区的空白位置 + pyautogui.dragTo(wm.x + 233, wm.y + 814, 0.5, button='left') # 进行拖动 + pyautogui.dragTo(wm.x + 188, wm.y + 810, 0.5, button='left') # 进行拖动 def cut_mp3(img_count): # 切割歌曲,将标尺在开头定位住 - pyautogui.moveTo(169, 610) + pyautogui.moveTo(wm.x + 169, 610) # 拖动标尺到达最后一个图片的边缘 - pyautogui.dragTo(169 + img_count * 41, 605, 0.5, button='left') + pyautogui.dragTo(wm.x + 169 + img_count * 41, 605, 0.5, button='left') # 移动鼠标到声音轨 - pyautogui.moveTo(169 + img_count * 41, 888) + pyautogui.moveTo(wm.x + 169 + img_count * 41, 888) # 点击鼠标使声音轨获取焦点 pyautogui.click() # 移动鼠标到向右切割按钮处 - pyautogui.moveTo(245, 584) + pyautogui.moveTo(wm.x + 245, 584) pyautogui.click() time.sleep(1) @@ -231,18 +225,20 @@ def run_once(hwnd, img_path, img_count): video_name = str(uuid.uuid4()) # 导入图片到时间轴 import_img(hwnd, img_path) + # 切割歌曲 cut_mp3(img_count) # 每个图片添加动画换场效果 - dhx = 1292 + dhx = wm.x + 1404 dhy = 57 d = 0 imgList = [] - xgx = 170 # 效果的第一个图片左侧边缘位置坐标 + xgx = wm.x + 170 # 效果的第一个图片左侧边缘位置坐标 + for i in range(0, img_count): # 点击封面轨道中的每张图片 - x = 190 + d # (190,813)是指第一张的位置 + x = wm.x + 190 + d # (190,813)是指第一张的位置 y = 813 imgList.append({x, y}) pyautogui.moveTo(x, y) @@ -255,7 +251,8 @@ def run_once(hwnd, img_path, img_count): pyautogui.click() time.sleep(1) # 选择了过场动画1~6 - zb = [(1334, 174), (1413, 174), (1492, 174), (1569, 174), (1254, 244), (1332, 244)] + zb = [(wm.x + 1334, 174), (wm.x + 1413, 174), (wm.x + 1492, 174), (wm.x + 1569, 174), (wm.x + 1254, 244), + (wm.x + 1332, 244)] # 产生一个0~5的随机值 r = random.randint(0, 5) pyautogui.moveTo(zb[r][0], zb[r][1]) @@ -264,33 +261,34 @@ def run_once(hwnd, img_path, img_count): time.sleep(1) # 拖拽特效 - pyautogui.moveTo(265, 58) # 顶部特效按钮 + pyautogui.moveTo(wm.x + 265, 58) # 顶部特效按钮 pyautogui.click() - pyautogui.moveTo(67, 150) # 左侧人物特效按钮 + pyautogui.moveTo(wm.x + 67, 150) # 左侧人物特效按钮 pyautogui.click() time.sleep(0.5) + # 首次多等一会 - if i == 0: - pyautogui.moveTo(265, 58) # 顶部特效按钮 - pyautogui.click() - pyautogui.moveTo(67, 150) # 左侧人物特效按钮 - pyautogui.click() - # 首次多等一会 - time.sleep(3) - - zb = [(158, 221), (258, 221), (358, 221), - (157, 337), (260, 337), - (360, 337), (465, 335), - (266, 457)] - # 产生一个0~7的随机值 - r = random.randint(0, 7) - pyautogui.moveTo(zb[r][0], zb[r][1]) - pyautogui.click() - # 鼠标拖拽到轨道上 - pyautogui.dragTo(xgx, 763, 0.5, button='left') - xgx = xgx + 38 # 38是偏移量,即每个特效有效长度38 + # if i == 0: + # pyautogui.moveTo(wm.x + 265, 58) # 顶部特效按钮 + # pyautogui.click() + # pyautogui.moveTo(wm.x + 67, 150) # 左侧人物特效按钮 + # pyautogui.click() + # # 首次多等一会 + # time.sleep(3) + # + # zb = [(wm.x + 158, 221), (wm.x + 258, 221), (wm.x + 358, 221), + # (wm.x + 157, 337), (wm.x + 260, 337), + # (wm.x + 360, 337), (wm.x + 465, 335), + # (wm.x + 266, wm.x + 457)] + # # 产生一个0~7的随机值 + # r = random.randint(0, 7) + # pyautogui.moveTo(zb[r][0], zb[r][1]) + # pyautogui.click() + # # 鼠标拖拽到轨道上 + # pyautogui.dragTo(wm.x + xgx, 763, 0.5, button='left') + # xgx = xgx + 38 # 38是偏移量,即每个特效有效长度38 # # 导出 - export(video_name) + # export(video_name) return video_name @@ -359,7 +357,18 @@ def run_switch(hwnd, source_img, cartoon_img): return video_name +# https://blog.csdn.net/nongcunqq/article/details/114022284 +def keybd_event(VK_CODE): # VK_CODE为键盘编码 + win32api.keybd_event(VK_CODE, 0, 0, 0) + win32api.keybd_event(VK_CODE, 0, win32con.KEYEVENTF_KEYUP, 0) + time.sleep(1) + + if __name__ == '__main__': + # 打开CapsLock,防止中文输入法影响程序运行 + if win32api.GetKeyState(win32con.VK_CAPITAL) == 0: + keybd_event(20) + # 配置文件 config = ConfigUtil.getConfig() # 剪映运行的显示器编号 @@ -372,12 +381,6 @@ if __name__ == '__main__': # 坐标测试的屏幕分辨率:1680*1050 wm = monitors[working_id - 1] - # print(wm.width, wm.height, wm.x, wm.y) - - # 显示器的分辨率和开始的位置 - # for i, monitor in enumerate(monitors): - # print("显示器", i + 1, "分辨率:", monitor.width, "x", monitor.height) - # print("显示器", i + 1, "位置:", monitor.x, ",", monitor.y) # 获取当前脚本文件的绝对路径 script_path = os.path.abspath(__file__) @@ -404,15 +407,15 @@ if __name__ == '__main__': # 操作类型,1:生成MV,2:生成图片切换 type_id = 1 - # - # # 生成MV - # if type_id == 1: - # # 用户上传了多少张图片 - # imgCount = count_files(imgPath) - 1 # 因为有一个是MP3 - # # 拷贝MP3文件到imgPath目录 - # shutil.copy(mp3, imgPath) - # videoName = run_once(hwnd, imgPath, imgCount) + '.mp4' - # print(os.path.join(JiangYingOutPath, videoName)) + + # 生成MV + if type_id == 1: + # 用户上传了多少张图片 + imgCount = count_files(imgPath) - 1 # 因为有一个是MP3 + # 拷贝MP3文件到imgPath目录 + shutil.copy(mp3, imgPath) + videoName = run_once(hwnd, imgPath, imgCount) + '.mp4' + print(os.path.join(JiangYingOutPath, videoName)) # # # 生成图片切换 # if type_id == 2: diff --git a/BaiHu/鼠标坐标/CsAutoGui.dll b/BaiHu/鼠标坐标/CsAutoGui.dll new file mode 100644 index 00000000..a15e7dfe Binary files /dev/null and b/BaiHu/鼠标坐标/CsAutoGui.dll differ diff --git a/BaiHu/鼠标坐标/坐标显示.exe b/BaiHu/鼠标坐标/坐标显示.exe new file mode 100644 index 00000000..658ca101 Binary files /dev/null and b/BaiHu/鼠标坐标/坐标显示.exe differ