コード例 #1
0
ファイル: keyboard.py プロジェクト: kukeblue/Manipulator
    def write(text):
        logger.launch_logger('键盘输入:' + text)
        pyautogui.write(text)


# ['\t', '\n', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(',
# ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7',
# '8', '9', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_', '`',
# 'a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
# 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
# 'accept', 'add', 'alt', 'altleft', 'altright', 'apps', 'backspace',
# 'browserback', 'browserfavorites', 'browserforward', 'browserhome',
# 'browserrefresh', 'browsersearch', 'browserstop', 'capslock', 'clear',
# 'convert', 'ctrl', 'ctrlleft', 'ctrlright', 'decimal', 'del', 'delete',
# 'divide', 'down', 'end', 'enter', 'esc', 'escape', 'execute', 'f1', 'f10',
# 'f11', 'f12', 'f13', 'f14', 'f15', 'f16', 'f17', 'f18', 'f19', 'f2', 'f20',
# 'f21', 'f22', 'f23', 'f24', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
# 'final', 'fn', 'hanguel', 'hangul', 'hanja', 'help', 'home', 'insert', 'junja',
# 'kana', 'kanji', 'launchapp1', 'launchapp2', 'launchmail',
# 'launchmediaselect', 'left', 'modechange', 'multiply', 'nexttrack',
# 'nonconvert', 'num0', 'num1', 'num2', 'num3', 'num4', 'num5', 'num6',
# 'num7', 'num8', 'num9', 'numlock', 'pagedown', 'pageup', 'pause', 'pgdn',
# 'pgup', 'playpause', 'prevtrack', 'print', 'printscreen', 'prntscrn',
# 'prtsc', 'prtscr', 'return', 'right', 'scrolllock', 'select', 'separator',
# 'shift', 'shiftleft', 'shiftright', 'sleep', 'space', 'stop', 'subtract', 'tab',
# 'up', 'volumedown', 'volumemute', 'volumeup', 'win', 'winleft', 'winright', 'yen',
# 'command', 'option', 'optionleft', 'optionright']
コード例 #2
0
 def find_text(path):
     image = get_file_content(path)
     res = ocr_client.basicGeneral(image)
     print(res)
     if len(res['words_result']) == 0:
         logger.launch_logger('baidu ocr 未识别到文字')
         return None
     else:
         logger.launch_logger('识别文字成功:' + str(res))
     return res
コード例 #3
0
ファイル: screen.py プロジェクト: kukeblue/Manipulator
 def find_area_text(self, region):
     if region is None:
         region = self.region
     else:
         region[0] = region[0] + self.screen_rect[0]
         region[1] = region[1] + self.screen_rect[1]
     logger.launch_logger('开始区域找子:' + str(region))
     im = pyautogui.screenshot('find_area_text.png', region=tuple(region))
     logger.launch_logger('find_area_text.png 保存成功')
     BApi.find_text('find_area_text.png')
コード例 #4
0
ファイル: screen.py プロジェクト: kukeblue/Manipulator
 def __init__(self, window_class, window_title):
     # hwnd = win32gui.FindWindow('WeChatMainWndForPC', '微信')
     hwnd = win32gui.FindWindow(window_class, window_title)
     left, top, right, bottom = win32gui.GetWindowRect(hwnd)
     self.hwnd = hwnd
     self.screen_rect = [left, top, right, bottom]
     self.region = (left, top, right - left, bottom - top)
     logger.launch_logger('绑定窗口成功' + str(self.screen_rect))
     self.relative_move_to(100, 100)
     Mouse.right_click()
コード例 #5
0
ファイル: screen.py プロジェクト: kukeblue/Manipulator
    def move_find_image(self, image_path, confidence=0.9):
        logger.launch_logger('查找图片:' + image_path)
        image_location = pyautogui.locateOnScreen(image_path,
                                                  confidence=confidence,
                                                  region=self.region)

        if image_location is not None:
            logger.launch_logger('图片' + image_path + '查找成功')
            self.move(image_location.left, image_location.top)
        else:
            raise Exception('图片' + image_path + '查找失败')
コード例 #6
0
def ca_520_151():
    infrastructure.Keyboard.hot_key('alt', 'e')
    time.sleep(1)
    infrastructure.screen.move_find_image('../../images/7/ca.png')
    infrastructure.Mouse.right_click(num=2)
    time.sleep(1)
    infrastructure.screen.move_find_image('../../images/7/ca_520_151.png')
    infrastructure.Mouse.left_click()
    time.sleep(1)
    infrastructure.Keyboard.hot_key('alt', 'e')
    infrastructure.Keyboard.press('f9')
    infrastructure.screen.move_find_image('../../images/ca/ca_520_159.png')
    infrastructure.Mouse.left_click()
    time.sleep(2)
    infrastructure.Keyboard.press('f9')
    infrastructure.screen.move_find_image('../../images/ca/ca_biao_33_20.png')
    infrastructure.Mouse.left_click()
    time.sleep(5)
    infrastructure.Mouse.right_click(num=3)
    infrastructure.Keyboard.press('f9')
    infrastructure.screen.move_find_image('../../images/ca/ca_biao_npc1.png', confidence=0.7)
    infrastructure.Mouse.left_click(num=1)
    time.sleep(1)
    infrastructure.screen.move_find_image('../../images/ca/ca_biao_tree.png', confidence=0.7)
    infrastructure.Mouse.left_click(num=1)
    time.sleep(2)
    infrastructure.Keyboard.press('f9')
    infrastructure.screen.move_find_image('../../images/ca/ca_biao_npc1.png', confidence=0.7)
    infrastructure.Mouse.left_click(num=1)
    time.sleep(1)
    box = infrastructure.screen.find_image('../../images/ca/ca_biao_message1.png')
    if box is None:
        logger.launch_logger('镖局启动人工验证')
        pyautogui.alert(text='人工验证完成', title='进入人工验证', button='OK')
        infrastructure.screen.move_find_image('../../images/ca/ca_biao_message2.png')
        infrastructure.Mouse.left_click(num=1)
    else:
        infrastructure.screen.move(box.left, box.top)
        infrastructure.Mouse.left_click(num=1)
        time.sleep(1)
        infrastructure.screen.move_find_image('../../images/ca/ca_biao_message2.png')
        infrastructure.Mouse.left_click(num=1)


# ca_520_151()
コード例 #7
0
ファイル: screen.py プロジェクト: kukeblue/Manipulator
    def find_image(self, image_path, confidence=0.9):
        logger.launch_logger('查找图片:' + image_path)
        image_location = pyautogui.locateOnScreen(image_path,
                                                  confidence=confidence,
                                                  region=self.region)

        if image_location is not None:
            logger.launch_logger('图片' + image_path + '查找成功')
            return image_location
        else:
            logger.launch_logger('图片' + image_path + '查找失败')
            return None
コード例 #8
0
ファイル: screen.py プロジェクト: kukeblue/Manipulator
 def relative_move_to(self, x, y):
     logger.launch_logger('移动到窗口内:' + str(x) + ',' + str(y))
     pyautogui.moveTo(self.screen_rect[0] + x, self.screen_rect[1] + y)
コード例 #9
0
ファイル: keyboard.py プロジェクト: kukeblue/Manipulator
 def press(key):
     logger.launch_logger('键盘按键:' + key)
     pyautogui.press(key)
コード例 #10
0
ファイル: keyboard.py プロジェクト: kukeblue/Manipulator
 def hot_key(key1, key2):
     logger.launch_logger('键盘组合按键:' + key1 + key2)
     pyautogui.hotkey(key1, key2)
コード例 #11
0
ファイル: mouse.py プロジェクト: kukeblue/Manipulator
 def left_click(num=1):
     logger.launch_logger('左击鼠标' + str(num) + '次')
     pyautogui.click(clicks=num)
コード例 #12
0
ファイル: mouse.py プロジェクト: kukeblue/Manipulator
 def move_to(x, y):
     logger.launch_logger('鼠标移动到' + str(x) + ',' + str(y))
     pyautogui.moveTo(x, y)
コード例 #13
0
ファイル: mouse.py プロジェクト: kukeblue/Manipulator
 def right_click(num=1):
     logger.launch_logger('右击鼠标' + str(num) + '次')
     pyautogui.click(clicks=num, button='right')