Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3599533
  • 博文数量: 365
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2522
  • 用 户 组: 普通用户
  • 注册时间: 2019-10-28 13:40
文章分类

全部博文(365)

文章存档

2023年(8)

2022年(130)

2021年(155)

2020年(50)

2019年(22)

我的朋友

分类: Python/Ruby

2022-06-30 17:11:47

# -*- coding: utf-8-*-

import uiautomation as auto

import time

import subprocess

# subprocess.Popen('C:\Program Files\Google\Chrome\Application\chrome.exe')

time.sleep(2)

start_time = time.time()

print('开始时间:{}'.format(start_time))

auto.SetGlobalSearchTimeout(3)

content = auto.DocumentControl(Name="内容管理-CSDN创作中心", Classname="Chrome_RenderWidgetHostHWND")

# 点击同步至社区

tongbu = 跟单网gendan5.comcontent.EditControl(Name="同步至社区")

if tongbu.Exists():

    tongbu.Click()

last_group = content.GetLastChildControl()

non_name_list = last_group.ListControl()

specific_list = non_name_list.GetChildren()

a = []

for i in specific_list:

    a.append(i.GetChildren()[0].Name)

print(a)

print('社区数:', len(a))

yes = content.TextControl(Name='确认')

tongbu.Click()

s = 0

for i in a:

    # 先点一次同步,跳出框

    if tongbu.Exists():

        tongbu.Click()

    specific_community = content.TextControl(Name='{}'.format(i))

    # print(specific_community.Name)

    if s == 0:

        if not specific_community.Exists():

            s += 2

        else:

            specific_community.Click()

            if not yes.Exists():

                s += 2

    if s > 0:

        content.GetLastChildControl().GetFirstChildControl().MoveCursorToMyCenter()

        auto.WheelDown(wheelTimes=s, waitTime=0.01)

        # 如果社区没显示出来,则滚动

        if not specific_community.Exists():

            # 鼠标放置中心

            content.GetLastChildControl().GetFirstChildControl().MoveCursorToMyCenter()

            # print("滚动")

            auto.WheelDown(waitTime=0.01)

            s += 2

            time.sleep(0.5)

            specific_community.Click(5, 5)

        # 有社区,但是只显示一点

        else:

            specific_community.Click(5, 5)

            if not yes.Exists():

content.GetLastChildControl().GetFirstChildControl().MoveCursorToMyCenter()

                auto.WheelDown(waitTime=0.01)

                s += 2

                time.sleep(0.5)

                specific_community.Click(5, 5)

                yes = content.TextControl(Name='确认')

                if yes.Exists():

                    yes.Click()

                    print(a.index(i) + 1, i, ' 已同步')

            else:

                yes = content.TextControl(Name='确认')

                if yes.Exists():

                    yes.Click()

                    print(a.index(i) + 1, i, ' 已同步')

    specific_community.Click(5, 5)

    yes = content.TextControl(Name='确认')

    if yes.Exists():

        yes.Click()

        print(specific_community.Name)

        print(a.index(i)+1, i, ' 已同步')

end_time = time.time()

sum_time = end_time - start_time

print("""运行时间:{}s""".format(sum_time))

阅读(687) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~