Пример #1
0
def open_qqbox():
    """ 打开QQ群对话框界面
    :return:
    """
    # 1、任务栏窗口
    task_mainWindow = auto.PaneControl(searchDepth=1, Name='任务栏')
    print(task_mainWindow)
    # 2、通过任务栏窗口获取用户提示通知区域
    warn_part = task_mainWindow.ToolBarControl(Name="用户提示通知区域")
    print(warn_part)
    # 3、获取并点击QQ按钮
    qq_button = warn_part.ButtonControl(foundIndex=2, searchDepth=1)
    # QQ名称 = '''QQ: 祝佰航(990095293)\r\n声音: 关闭\r\n消息提醒框: 关闭\r\n会话消息: 任务栏头像闪动'''
    # qq_button = warn_part.ButtonControl(Name=QQ名称, searchDepth=1)
    print(qq_button)
    qq_button.Click(waitTime=1.5)
    sleep(0.5)
    # 获取并激活QQ界面
    main_window = auto.WindowControl(searchDepth=1, Name='QQ')
    main_window.SetActive()
    print(main_window)
    sleep(0.5)
    # 获取搜索框
    search_Edit = main_window.EditControl(searchDepth=6, Name="搜索:联系人、群聊、企业")
    sleep(0.5)
    # 搜索群名称
    search_Edit.SetFocus()
    search_Edit.SendKeys('中泰证券二部技术讨论')
    search_Edit.SendKeys('{Enter}')
    sleep(0.5)
    # 最大化打开的对话框
    dialog_box = auto.WindowControl(Name='中泰证券二部技术讨论', searchDepth=1)
    print(dialog_box)
    dialog_box.Maximize()
def BatchRename():
    foxitWindow = automation.WindowControl(searchDepth=1,
                                           ClassName='classFoxitReader')
    foxitWindow.ShowWindow(automation.ShowWindow.ShowMaximized)
    foxitWindow.SetActive()
    automation.Logger.Log(foxitWindow.Name[:-len(' - Foxit Reader')] + '\n')
    time.sleep(1)
    automation.SendKeys('{Ctrl}0')
    time.sleep(0.5)
    editToolBar = automation.ToolBarControl(searchFromControl=foxitWindow,
                                            AutomationId='59583',
                                            Name='Caption Bar')
    if editToolBar.Exists(0, 0):
        editToolBar.Click(0.96, 0.5)
        time.sleep(0.5)
        automation.SendKeys('{Alt}y')
        time.sleep(0.5)
    editToolBar = automation.ToolBarControl(searchFromControl=foxitWindow,
                                            AutomationId='60683',
                                            Name='Caption Bar')
    if editToolBar.Exists(0, 0):
        editToolBar.Click(0.96, 0.5)
        time.sleep(0.5)
        automation.SendKeys('{Alt}y')
        time.sleep(0.5)
    paneWindow = automation.WindowControl(searchFromControl=foxitWindow,
                                          AutomationId='65280')
    bookmarkPane = automation.PaneControl(searchFromControl=paneWindow,
                                          searchDepth=1,
                                          foundIndex=1)
    l, t, r, b = bookmarkPane.BoundingRectangle
    #bookmarkButton = automation.ButtonControl(searchFromControl= bookmarkPane, Name = '书签') # can't find, but automation -a can find it, why
    if bookmarkPane.Name == '书签':
        if r - l < 40:
            bookmarkButton = automation.ControlFromPoint(l + 10, t + 40)
            if bookmarkButton.Name == '书签':
                bookmarkButton.Click(simulateMove=False)
    else:
        bookmarkButton = automation.ControlFromPoint(l + 10, t + 40)
        if bookmarkButton.Name == '书签':
            bookmarkButton.Click(simulateMove=False)
    tree = automation.TreeControl(searchFromControl=foxitWindow,
                                  ClassName='SysTreeView32')
    childItems = tree.GetChildren()
    bookMarks = []
    depth = 1
    for treeItem in childItems:
        if treeItem.ControlType == automation.ControlType.TreeItemControl:
            RenameTreeItem(tree, treeItem, bookMarks, depth)
    fout = open('rename_pdf_bookmark.txt', 'wt', encoding='utf-8')
    depth = 1
    for bookMark in bookMarks:
        DumpBookMark(fout, bookMark, depth)
    fout.close()
    if Renamed:
        automation.Logger.Log('rename pdf: ' + foxitWindow.Name)
        automation.SendKeys('{Ctrl}s')
        time.sleep(0.5)
        while '*' in foxitWindow.Name:
            time.sleep(0.5)
Пример #3
0
def check_Other_AvayaIX():
    while uiautomation.WindowControl(
            Name="Other Avaya IX Workplace instances are detected").Exists(3):
        uiautomation.WindowControl(
            Name="Other Avaya IX Workplace instances are detected").SendKeys(
                '{Alt}'
                '{N}')
Пример #4
0
def test():
    subprocess.Popen(path)
    automation.WindowControl(class_name='Qt5QWindowIcon',
                             Name='userLoginViewClass').Refind(20, 1)
    window = automation.WindowControl(searchDepth=1,
                                      ClassName='Qt5QWindowIcon',
                                      Name=u'userLoginViewClass')
    # 用户名
    edit1 = automation.EditControl(searchFromControl=window,
                                   Name=u'lineEdit_userName')
    edit1.DoubleClick()
    PressKey(0x0E)
    key_input('guojian')
    # 密码
    edit2 = automation.EditControl(searchFromControl=window,
                                   Name=u'lineEdit_password')
    edit2.DoubleClick()
    key_input('8888888888888')
    # 验证码
    edit3 = automation.EditControl(searchFromControl=window,
                                   Name=u'lineEdit_identifyCode')
    edit3.DoubleClick()
    key_input('izxf')
    # 确定
    button = automation.ButtonControl(searchFromControl=window,
                                      Name=u'pushButton_sure')
    button.Click()
def click_setting():
    OneX_Window = uiautomation.WindowControl(Name = "Avaya one-X® Communicator")
    OneX_Window.SetFocus()
    time.sleep(1)
    btn_Menu = OneX_Window.ButtonControl(AutomationId="ButtonMenu")
    time.sleep(1)
    btn_Menu.Click()
    choose_logout = OneX_Window.MenuItemControl(Name="Log Out")
    # logout phone if it is login before
    if choose_logout.Exists(2):
        choose_logout.Click()
        time.sleep(1)
        OneX_Window = uiautomation.WindowControl(Name="Avaya one-X® Communicator")
        OneX_Window.SetFocus()
        btn_Menu = OneX_Window.ButtonControl(AutomationId="ButtonMenu")
        time.sleep(1)
        btn_Menu.Click()
    # click setting
    choose_setting = OneX_Window.MenuItemControl(Name = "Settings")
    choose_setting.Click()

    audio_error = uiautomation.WindowControl(Name="WindowMessageBox")

    # Wait and click OK on Audio Error message if it is displayed.
    while uiautomation.WindowControl(Name="WindowMessageBox").Exists(5):
        uiautomation.WindowControl(Name="WindowMessageBox").ButtonControl(Name="OK").Click()
Пример #6
0
def main():
    auto.ShowDesktop()
    subprocess.Popen('notepad')
    time.sleep(1)
    note = auto.WindowControl(searchDepth=1, ClassName='Notepad')
    note.SetActive()
    note.SetTopmost()
    transformNote = note.GetTransformPattern()
    transformNote.Move(400, 0)
    transformNote.Resize(400, 300)
    edit = note.EditControl()
    edit.SendKeys('{Ctrl}{End}{Enter 2}I\'m a topmost window!!!\nI cover other windows.')
    subprocess.Popen('mmc.exe devmgmt.msc')
    mmcWindow = auto.WindowControl(searchDepth=1, ClassName='MMCMainFrame')
    mmcWindow.SetActive()
    transformMmc = mmcWindow.GetTransformPattern()
    transformMmc.Move(100, 100)
    transformMmc.Resize(400, 300)
    time.sleep(1)
    auto.DragDrop(160, 110, 900, 110, 0.2)
    auto.DragDrop(900, 110, 160, 110, 0.2)
    mmcWindow.SendKeys('{Alt}f', waitTime=1)
    mmcWindow.SendKeys('X', charMode=False)  # or mmcWindow.SendKey(auto.Keys.VK_X)
    edit.SendKeys('{Ctrl}{End}{Enter 2}You close me.')
    vp = edit.GetValuePattern()
    if vp:
        print('current text:', vp.Value)
    auto.GetConsoleWindow().SetActive()
Пример #7
0
def close_mail_app():
    AddWindow = uiautomation.WindowControl(Name="Add an account")
    AddWindow.SetFocus()
    AddWindow.SendKeys('{Alt}' '{F4}')
    time.sleep(5)
    MailWindow = uiautomation.WindowControl(Name="Mail")
    MailWindow.SetFocus()
    MailWindow.SendKeys('{Alt}' '{F4}')
    time.sleep(1)
Пример #8
0
def go_to(menuItem, submenuItem):
    zipWindow = uiautomation.WindowControl(Name="7-Zip")

    uiautomation.WaitForExist(zipWindow, 5)
    zipWindow.MenuItemControl(RegexName=f"{menuItem}.*").Click()

    # Because Application changes after clicking file
    zipWindow = uiautomation.WindowControl(Name="7-Zip")
    uiautomation.WaitForExist(zipWindow, 5)
    zipWindow.MenuItemControl(RegexName=f"{submenuItem}.*").Click()
Пример #9
0
def close_7zip():
    zipWindow = uiautomation.WindowControl(Name="7-Zip")

    uiautomation.WaitForExist(zipWindow, 5)
    zipWindow.MenuItemControl(Name="File").Click()

    # Because Application changes after clicking file
    zipWindow = uiautomation.WindowControl(Name="7-Zip")
    uiautomation.WaitForExist(zipWindow, 5)
    zipWindow.MenuItemControl(RegexName="Exit.*").Click()
Пример #10
0
def record(url):
    '''录制'''
    console = uiautomation.GetConsoleWindow()
    window = uiautomation.WindowControl(searchDepth=1,
                                        ClassName='WeChatMainWndForPC',
                                        SubName=u'微信')
    window.ShowWindow(uiautomation.ShowWindow.Maximize)
    window.SetActive()
    # 点击“文件传输助手”(要求置顶)
    uiautomation.Win32API.MouseClick(170, 75)

    window.SendKeys(4 * (url + ' ') + '{Enter}')
    uiautomation.Win32API.MouseClick(1130, 480)

    page = uiautomation.WindowControl(searchDepth=1,
                                      ClassName='IEWebViewWnd',
                                      SubName=u'微信')
    page.ShowWindow(uiautomation.ShowWindow.Maximize)
    page.SetActive()

    # 滚动到选项
    v = page.PaneControl(ClassName='Internet Explorer_Server')
    clicks = []
    while True:
        console.SetActive()
        # input(u'1.请把webview滚动到合适的未知,然后按回车: ')
        raw_input(u'1. scroll webview to proper percent, and press enter: ')
        percent = v.CurrentVerticalScrollPercent()
        print(percent)
        v.SetScrollPercent(0, percent)
        console.SetActive()
        # input(u'2.请把鼠标放在webview中需要点击的位置,然后按回车: ')
        c = raw_input(u'2. put cursor to proper position, and press enter: ')
        (x, y) = uiautomation.Win32API.GetCursorPos()
        print((x, y))
        clicks.append((percent, x, y))
        # c = input(u'3.还需要继续操作,请输入c并按回车:')
        b = raw_input(
            u'3. if want to break, input b and press enter, or press enter for exit: '
        )
        if b == 'b':
            break
    page.Close()
    print(clicks)
    # TODO wait
    votes = input('4. how many votes you want to do? ')
    action = {  # 被认为是局部变量不会保存到全局变量中
        'url': url,
        'clicks': clicks,
        # TODO wait
        'votes': votes
    }
    print('action: ')
    print(action)
Пример #11
0
 def stop_whiteboard(self):
     white_board_window = auto.WindowControl(
         searchDepth=1, ClassName="ev_app::views::WhiteBoardDlg")
     white_board_window.GroupControl(
         searchDepth=1,
         ClassName="ev_app::views::WhiteBoardTopWidget").TextControl(
             searchDepth=4, Name="停止分享").Click()
     exit_white_board_button = auto.WindowControl(searchDepth=1, ClassName="ev_app::views::WhiteBoardDlg").WindowControl(searchDepth=1, ClassName="ev_app::views::AlertDlg")\
         .ButtonControl(searchDepth=3, Name="是")
     if exit_white_board_button.Exists():
         exit_white_board_button.Click()
Пример #12
0
 def __init__(self):
     self.hjtMeetingWindow = auto.WindowControl(
         searchDepth=1, AutomationId="CLayoutBackgroundDlg")
     self.meetingWindowControl = self.hjtMeetingWindow.GroupControl(
         searchDepth=1, AutomationId="CLayoutBackgroundDlg.m_pWgtTitleBar")
     self.meetingLabel = self.hjtMeetingWindow.GroupControl(
         searchDepth=1,
         AutomationId="CLayoutBackgroundDlg.m_pWgtTitleBar").TextControl(
             searchDepth=1, ClassName="QLabel")
     self.meetingControlToolBar = auto.WindowControl(searchDepth=1, ClassName="ev_app::views::CLayoutBackgroundDlg") \
         .WindowControl(searchDepth=1, ClassName="ev_app::views::CLayoutCoverDlg").WindowControl(searchDepth=1, ClassName="ev_app::views::CLayoutToolbarDlg")
Пример #13
0
def bench(count=30):
    log('bench begin...')
    window = uiautomation.WindowControl(searchDepth = 1, ClassName = 'Notepad', SubName = '无标题 - 记事本')
    window.SetActive(waitTime=0)
    window.Maximize(waitTime=0)
    while count > 0:
        window = uiautomation.WindowControl(searchDepth = 1, ClassName = 'Notepad', SubName = '无标题 - 记事本')
        window.SetActive(waitTime=0)
        window.SendKeys('123123123123123{ENTER}', 0,0)
        window.SendKeys('{ALT}{ESC}', 0,0)
        count -= 1
    log('bench end...')
def click_login():
    Win_one = uiautomation.WindowControl(ClassName = "Window")
    Win_one.SetFocus()
    btn_login = Win_one.ButtonControl(Name = "Log In")
    btn_login.Click()

    # # verify login
    Win_login = uiautomation.WindowControl(Name = "Avaya one-X® Communicator")
    if not Win_login.Exists():
        raise valueError ("Cannot login One_x")

    while uiautomation.WindowControl(Name="WindowMessageBox").Exists(3):
        uiautomation.WindowControl(Name="WindowMessageBox").ButtonControl(Name="OK").Click()
Пример #15
0
def install_furmark(tool_full_path):
    # install Furmark
    print('installing furmark')
    subprocess.Popen(tool_full_path)
    time.sleep(2)
    furMark = auto.WindowControl(searchDepth=1, ClassName='TWizardForm')
    furMark.SetTopmost(True, waitTime=1)
    furMark.RadioButtonControl(searchDepth=6,
                               Name='I accept the agreement').Click()
    furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
    furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
    try:
        furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
        furMark.CheckBoxControl(searchDepth=7,
                                Name='Create a &desktop shortcut').Click()
        furMark.CheckBoxControl(searchDepth=7,
                                Name='Create a &Quick Launch icon').Click()
        furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
        furMark.ButtonControl(searchDepth=2, Name='Install').Click()
        time.sleep(8)
        furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
        furMark.CheckBoxControl(searchDepth=5, Name='Launch FurMark').Click()
        furMark.CheckBoxControl(searchDepth=5,
                                Name='Launch FurMark release notes').Click()
        furMark.ButtonControl(searchDepth=2, Name='Finish').Click()
    except LookupError as e:
        # print('遇到错误:', e)
        folderExistWindow = auto.WindowControl(searchDepth=1,
                                               Name='Folder Exists')
        folderExistWindow.SetTopmost(True)
        time.sleep(2)
        try:
            folderExistWindow.ButtonControl(searchDepth=2, Name='是(Y)').Click()
        except LookupError as e:
            # print('遇到错误:', e)
            folderExistWindow.ButtonControl(searchDepth=2, Name='Yes').Click()
        furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
        furMark.CheckBoxControl(searchDepth=7,
                                Name='Create a &desktop shortcut').Click()
        furMark.CheckBoxControl(searchDepth=7,
                                Name='Create a &Quick Launch icon').Click()
        furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
        furMark.ButtonControl(searchDepth=2, Name='Install').Click()
        time.sleep(8)
        furMark.ButtonControl(searchDepth=2, Name='Next >').Click()
        furMark.CheckBoxControl(searchDepth=5, Name='Launch FurMark').Click()
        furMark.CheckBoxControl(searchDepth=5,
                                Name='Launch FurMark release notes').Click()
        furMark.ButtonControl(searchDepth=2, Name='Finish').Click()
    print('furmark installed')
Пример #16
0
def install_aida(tool_full_path):
    print('installing aida64')
    subprocess.Popen(tool_full_path)
    time.sleep(2)
    aidaLanguage = auto.WindowControl(searchDepth=1,
                                      ClassName='TSelectLanguageForm')
    aidaLanguage.SetTopmost(True)
    aidaLanguage.ComboBoxControl(searchDepth=2).Click()
    aidaLanguage.ListItemControl(searchDepth=4, Name='English').Click()
    time.sleep(2)
    try:
        aidaLanguage.ButtonControl(searchDepth=2, Name='OK').Click()
        aida = auto.WindowControl(searchDepth=1, Name='Setup - AIDA64 Extreme')
        aida.SetTopmost(True)
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.RadioButtonControl(searchDepth=6,
                                Name='I accept the agreement').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Install').Click()
        time.sleep(8)
        aida.CheckBoxControl(searchDepth=5,
                             Name='Launch AIDA64 Extreme').Click()
        aida.CheckBoxControl(searchDepth=5,
                             Name='View AIDA64 Extreme Documentation').Click()
        aida.ButtonControl(searchDepth=2, Name='Finish').Click()
    except LookupError as e:
        #print('遇到错误:', e)
        aidaLanguage.ButtonControl(searchDepth=2, Name='确定').Click()
        aida = auto.WindowControl(searchDepth=1, Name='Setup - AIDA64 Extreme')
        aida.SetTopmost(True)
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.RadioButtonControl(searchDepth=6,
                                Name='I accept the agreement').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Next >').Click()
        aida.ButtonControl(searchDepth=2, Name='Install').Click()
        time.sleep(8)
        aida.CheckBoxControl(searchDepth=5,
                             Name='Launch AIDA64 Extreme').Click()
        aida.CheckBoxControl(searchDepth=5,
                             Name='View AIDA64 Extreme Documentation').Click()
        aida.ButtonControl(searchDepth=2, Name='Finish').Click()
    print('aida64 installed')
def login_extension(phone, password):
    AvayaComm_Window = uiautomation.WindowControl(Name="Avaya Communicator")
    AvayaComm_Window.SetFocus()
    #Login_Button = AvayaComm_Window.ButtonControl(AutomationID="loginButton")
    Login_Button = AvayaComm_Window.TextControl(Name="Not logged in")
    Login_Button.Click()
    time.sleep(1)

    # edit phone
    btn_logout = uiautomation.ButtonControl(Name="Logout")
    Edit_phone1 = btn_logout.GetNextSiblingControl()
    Edit_phone = Edit_phone1.GetFirstChildControl()
    Edit_phone.SendKeys('{Ctrl}' '{A}')
    Edit_phone.SendKeys('{DEL}')
    Edit_phone.SendKeys(phone)
    time.sleep(1)
    Edit_phone.SendKeys('{Tab}')
    # edit password
    Edit_password1 = Edit_phone1.GetNextSiblingControl()
    Edit_password = Edit_password1.GetFirstChildControl()
    Edit_password.SendKeys('{Ctrl}' '{A}')
    Edit_password.SendKeys('{DEL}')
    Edit_password.SendKeys(password)
    Edit_password.SendKeys('{Enter}')
    logged_station_name = AvayaComm_Window.TextControl(
        Name="Incorrect extension or password.")
    if logged_station_name.Exists(1):
        raise Exception("Login Station Unsuccessfully")
def settings_server(server_IP, domain_server):
    Settings_Window = uiautomation.WindowControl(ClassName="Window")
    Settings_Window.SetFocus()

    server_List = Settings_Window.ListItemControl(Name="Server")
    server_List.Click()

    server_address = Settings_Window.TextControl(Name="Server address")
    Edit_ServerIP = server_address.GetNextSiblingControl()
    Edit_ServerIP.SendKeys('{Ctrl}' '{A}')
    Edit_ServerIP.SendKeys('{DEL}')
    Edit_ServerIP.SendKeys(server_IP)

    # server port 5060
    text_control = Settings_Window.TextControl(Name="Server port")
    Edit_Port = text_control.GetNextSiblingControl()
    Edit_Port.SendKeys('{Ctrl}' '{A}')
    Edit_Port.SendKeys('{DEL}')
    Edit_Port.SendKeys("5060")
    time.sleep(1)

    # Transport Type: TCP
    TCP = Settings_Window.RadioButtonControl(Name="TCP")
    TCP.Click()

    # # domain
    domain = Settings_Window.TextControl(Name="Domain")
    Edit_Domain = domain.GetNextSiblingControl()
    Edit_Domain.SendKeys('{Ctrl}' '{A}')
    Edit_Domain.SendKeys('{DEL}')
    Edit_Domain.SendKeys(domain_server)

    time.sleep(1)
    btn_OK = uiautomation.ButtonControl(Name="OK")
    btn_OK.Click()
Пример #19
0
def testNotepadCN():
    consoleWindow = automation.GetConsoleWindow()
    consoleWindow.SetActive()
    automation.Logger.ColorfulWriteLine(
        '\nI will open <Color=Green>Notepad</Color> and <Color=Yellow>automate</Color> it. Please wait for a while.'
    )
    time.sleep(2)
    automation.ShowDesktop()
    #打开notepad
    subprocess.Popen('notepad')
    #查找notepad, 如果name有中文,python2中要使用Unicode
    window = automation.WindowControl(searchDepth=1,
                                      ClassName='Notepad',
                                      SubName='无标题 - 记事本')
    #可以判断window是否存在,如果不判断,找不到window的话会抛出异常
    #if window.Exists(maxSearchSeconds = 3):
    screenWidth, screenHeight = automation.Win32API.GetScreenSize()
    window.MoveWindow(screenWidth // 4, screenHeight // 4, screenWidth // 2,
                      screenHeight // 2)
    window.SetActive()
    #查找edit
    edit = automation.EditControl(
        searchFromControl=window)  #or edit = window.EditControl()
    edit.Click(waitTime=0)
    #python2中要使用Unicode, 模拟按键
    edit.SetValue('hi你好')
    edit.SendKeys('{Ctrl}{End}{Enter}下面开始演示{! 4}{ENTER}', 0.2, 0)
    edit.SendKeys(text)
    edit.SendKeys('{Enter 3}0123456789{Enter}', waitTime=0)
    edit.SendKeys('ABCDEFGHIJKLMNOPQRSTUVWXYZ{ENTER}', waitTime=0)
    edit.SendKeys('abcdefghijklmnopqrstuvwxyz{ENTER}', waitTime=0)
    edit.SendKeys('`~!@#$%^&*()-_=+{ENTER}', waitTime=0)
    edit.SendKeys('[]{{}{}}\\|;:\'\",<.>/?{ENTER}', waitTime=0)
    edit.SendKeys(
        '™®①②③④⑤⑥⑦⑧⑨⑩§№☆★○●◎◇◆□℃‰€■△▲※→←↑↓〓¤°#&@\^_―♂♀{ENTER}{CTRL}a')
    window.CaptureToImage('Notepad.png')
    edit.SendKeys('Image Notepad.png was captured, you will see it later.',
                  0.05)
    #查找菜单
    window.MenuItemControl(Name='格式(O)').Click()
    window.MenuItemControl(Name='字体(F)...').Click()
    windowFont = window.WindowControl(Name='字体')
    windowFont.ComboBoxControl(AutomationId='1140').Select('中文 GB2312')
    windowFont.ButtonControl(Name='确定').Click()
    window.Close()

    # buttonNotSave = ButtonControl(searchFromControl = window, SubName = '不保存')
    # buttonNotSave.Click()
    # or send alt+n to not save and quit
    # automation.SendKeys('{Alt}n')
    # 使用另一种查找方法
    buttonNotSave = automation.FindControl(
        window, lambda control, depth: control.ControlType == automation.
        ControlType.ButtonControl and '不保存' in control.Name)
    buttonNotSave.Click()
    subprocess.Popen('Notepad.png', shell=True)
    time.sleep(2)
    consoleWindow.SetActive()
    automation.Logger.WriteLine('script exits', automation.ConsoleColor.Cyan)
    time.sleep(2)
Пример #20
0
def refreshDict():
    console = uiautomation.GetConsoleWindow()
    # new handle
    global nextHandleKey
    log('nextHandleKey = ' + str(nextHandleKey))
    begHandle = 0
    while True:
        window = uiautomation.WindowControl(searchDepth=1,  ClassName='WeChatMainWndForPC', SubName=u'微信')
        window.ShowWindow(uiautomation.ShowWindow.Maximize)
        #window.SetActive()
        curHandle = window.Handle
        if begHandle == 0 :
            begHandle = curHandle
        elif begHandle == curHandle :
            break
        if curHandle not in handleDict.values():
            handleDict[nextHandleKey] = curHandle
            log('add: ' + str(nextHandleKey) + ' ' + str(curHandle))
            nextHandleKey += 1
        window.SendKeys('{ALT}{ESC}')
    console.SetActive()
    # invalid handle
    keyList = handleDict.copy().keys()
    for index in keyList:
        curHandle = handleDict[index]
        window = uiautomation.ControlFromHandle(curHandle)
        if window == None:
            handleDict.pop(index)
            log('pop: ' + str(index) + ' ' + str(curHandle))
    log('dice is refreshed: len=' + str(len(handleDict)) + ' nextHandleKey='+str(nextHandleKey))
Пример #21
0
def trainOld():
    '''养号'''
    log('>>>> train() begin...')
    console = uiautomation.GetConsoleWindow()

    while True:
        window = uiautomation.WindowControl(searchDepth=1,  ClassName='WeChatMainWndForPC', SubName=u'微信')
        window.ShowWindow(uiautomation.ShowWindow.Maximize)
        window.SetActive()
        log('train begin window: {0}'.format(window.Handle))

        # # 点击搜索
        # uiautomation.Win32API.MouseClick(126, 24)
        # # 输入“文件传输助手”
        # window.SendKeys(u'文件传输助手')
        # # 点击联系人
        # uiautomation.Win32API.MouseClick(147, 88)

        # 直接点击第一个联系人
        uiautomation.Win32API.MouseClick(136, 73)
        # 输入url
        window.SendKeys(time.strftime('%Y-%m-%d %H:%M:%S')+' 你好你好!!!{Enter}')

        # 窗口放到最后
        window.SendKeys('{ALT}{ESC}')
        log('train end window: {0}'.format(window.Handle))
        time.sleep(1800)
    console.SetActive()
    log('>>>> train() end...')
Пример #22
0
def save_content(LAST_MESS_TEMP):
    """ 复制聊天记录到指定文件中
    :return:
    """
    dialog_box = auto.WindowControl(Name='中泰证券二部技术讨论', searchDepth=1)
    dialog_box.SetActive()
    dialog_box.Maximize()
    message_win = dialog_box.ListControl(Name='消息', searchDepth=13)
    message_win.Click()
    auto.Click(800, 800)
    message_win.SendKeys('{Ctrl}A')
    message_win.SendKeys('{Ctrl}C')
    df = pd.read_clipboard(sep=r"\s+", encoding='utf-8', error_bad_lines=False)
    df.to_csv('message_tmp.txt', index=False, sep=' ', encoding='utf_8_sig')
    # 查找未写入文件的内容
    k = 0
    with open('message_tmp.txt', 'r', encoding='utf_8_sig') as fp:
        readlines = fp.readlines()
        for i, line in enumerate(readlines):
            if line == LAST_MESS_TEMP:
                k = i
                break
        LAST_MESS_TEMP = readlines[-1].strip()

    # 将未写入文件的内容写入文件
    with open('message.txt', 'a+', encoding='utf_8_sig') as fp:
        readlines = fp.readlines()
        for i in range(k, len(readlines)):
            fp.write(readlines[i])
    return LAST_MESS_TEMP
Пример #23
0
 def SetTopMostByName(self, name):
     try:
         sleep(2)
         el = automation.WindowControl(searchDepth=1, Name=name)
         el.SetTopmost(True)
     except Exception as e:
         print("窗口置顶异常" + '||原因:' + str(e))
Пример #24
0
    def prepare(self):
        time.sleep(3)
        automation.SendKey(automation.Keys.VK_F12)
        time.sleep(3)
        win = automation.WindowControl(searchDepth=1,
                                       ClassName='ApplicationFrameWindow')
        control = win.WindowControl(searchDepth=1,
                                    ClassName='Windows.UI.Core.CoreWindow',
                                    searchWaitTime=100)
        # print(control)
        control = control.CustomControl(searchDepth=1,
                                        AutomationId='m_f12Docked')
        control = control.GroupControl(searchDepth=1)
        f12 = control.PaneControl(searchDepth=1)
        f12 = f12.PaneControl(searchDepth=1)
        f12 = f12.PaneControl(searchDepth=1, AutomationId='9')
        f12 = f12.PaneControl(searchDepth=1, Name='Network')
        toolbar = f12.ToolBarControl(searchDepth=1)
        self.button = toolbar.ButtonControl(searchDepth=1, Name='清除会话')
        self.button.Invoke()
        # button.Click()
        # contentFilter = toolbar.ButtonControl(searchDepth=1, Name = '内容类型筛选器')
        automation.SendKey(automation.Keys.VK_TAB)
        automation.SendKey(automation.Keys.VK_SPACE)
        automation.SendKey(automation.Keys.VK_DOWN)
        automation.SendKey(automation.Keys.VK_DOWN)
        automation.SendKey(automation.Keys.VK_DOWN)
        automation.SendKey(automation.Keys.VK_DOWN)
        automation.SendKey(automation.Keys.VK_DOWN)
        automation.SendKey(automation.Keys.VK_DOWN)
        automation.SendKey(automation.Keys.VK_SPACE)
        automation.SendKey(automation.Keys.VK_ESCAPE)

        self.groupControl = f12.GroupControl(
            searchDepth=1, Name='名称, 协议, 方法, 结果, 内容类型, 已接收, 时间, 发起程序, 开始时间,')
Пример #25
0
 def start_hjt():
     """重启应用"""
     sleep(5)
     if not auto.WindowControl(
             searchDepth=1, ClassName='ev_app::views::CHomeDlg').Exists():
         subprocess.Popen(
             "C:\\Program Files (x86)\\HexMeetHJT\\HexMeetHJT.exe")
Пример #26
0
def zoomSearch():
    zoom = auto.WindowControl(searchDepth=1, ClassName='ZPPTMainFrmWndClassEx')
    if not zoom.Exists(3, 1):
        print('Can not find Zoom window')
        exit(0)
    # print(zoom)
    selectByChildTree(zoom)
Пример #27
0
    def close_hjt():
        """关闭程序"""
        try:
            hexMeetHJTWindow = auto.WindowControl(
                searchDepth=1, ClassName='ev_app::views::CHomeDlg')
            if hexMeetHJTWindow.WindowControl(
                    searchDepth=1,
                    ClassName="ev_app::views::AlertDlg").ButtonControl(
                        searchDepth=3, Name="确定").Exists(1):
                hexMeetHJTWindow.WindowControl(
                    searchDepth=1,
                    ClassName="ev_app::views::AlertDlg").ButtonControl(
                        searchDepth=3, Name="确定").Click()
            sleep(3)
            hexMeetHJTWindow.GroupControl(
                searchDepth=1,
                AutomationId="CHomeDlg.m_pWgtTitleBar").ButtonControl(
                    searchDepth=1,
                    AutomationId="CHomeDlg.m_pWgtTitleBar.m_pBtnClose").Click(
                    )
            sleep(3)
            hexMeetHJTWindow.WindowControl(
                searchDepth=1, AutomationId="CHomeDlg.AlertDlg").ButtonControl(
                    searchDepth=3, Name="确定").Click()
            sleep(3)

            cmd = 'taskkill /F /IM HexMeetHJT.exe'
            os.system(cmd)
        # if hexMeetHJTWindow.Exists():
        except:
            cmd = 'taskkill /F /IM HexMeetHJT.exe'
            os.system(cmd)
def CalcOnWindows10():
    char2Id = {
        '0': 'num0Button',
        '1': 'num1Button',
        '2': 'num2Button',
        '3': 'num3Button',
        '4': 'num4Button',
        '5': 'num5Button',
        '6': 'num6Button',
        '7': 'num7Button',
        '8': 'num8Button',
        '9': 'num9Button',
        '.': 'decimalSeparatorButton',
        '+': 'plusButton',
        '-': 'minusButton',
        '*': 'multiplyButton',
        '/': 'divideButton',
        '=': 'equalButton',
        '(': 'openParanthesisButton',
        ')': 'closeParanthesisButton',
    }
    calcWindow = automation.WindowControl(searchDepth=1,
                                          ClassName='ApplicationFrameWindow',
                                          Name='Calculator')
    if not calcWindow.Exists(0, 0):
        subprocess.Popen('calc')
    calcWindow.SetActive()
    calcWindow.ButtonControl(AutomationId='NavButton').Click()
    calcWindow.ListItemControl(Name='Scientific Calculator').Click()
    calcWindow.ButtonControl(AutomationId='clearButton').Click()
    char2Button = {}
    for key in char2Id:
        char2Button[key] = calcWindow.ButtonControl(AutomationId=char2Id[key])
    Calc(calcWindow, char2Button, '1234 * (4 + 5 + 6) - 78 / 90')
    Calc(calcWindow, char2Button, '2*3.14159*10')
Пример #29
0
def CalcOnXP():
    chars = '0123456789.+-*/=()'
    calcWindow = auto.WindowControl(searchDepth=1, ClassName='SciCalc')
    if not calcWindow.Exists(0, 0):
        subprocess.Popen('calc')
    calcWindow.SetActive()
    calcWindow.SendKeys('{Alt}vs', 0.5)
    clearBtn = calcWindow.ButtonControl(Name='CE')  #
    clearBtn.Click()
    if 0:
        #Desc it not a valid search property, but it can be used for debug printing
        char2Button = {
            key: calcWindow.ButtonControl(Name=key, Desc='Button ' + key)
            for key in chars
        }
    else:
        #Run faster because it only walk calc window once
        char2Button = {}
        for c, d in auto.WalkControl(calcWindow, maxDepth=1):
            if c.Name in chars:
                char2Button[c.Name] = c
    Calc(calcWindow, char2Button, '1234 * (4 + 5 + 6) - 78 / 90.8')
    Calc(calcWindow, char2Button, '3*3+4*4')
    Calc(calcWindow, char2Button, '2*3.14159*10')
    calcWindow.Disappears(1)
    calcWindow.GetWindowPattern().Close()
    calcWindow.Exists(1)
Пример #30
0
def desktop_root():
    root = automation.WindowControl(ClassName='MozillaWindowClass')
    for i in root.GetChildren():
        for j in i.GetChildren():
            for k in j.GetChildren():
                for l in k.GetChildren():
                    print(l)