代码拉取完成,页面将自动刷新
同步操作将从 yinkaisheng/PythonUIAutomation4Windows 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!python3
# -*- coding: utf-8 -*-
import time
import automation
def main():
firefoxWindow = automation.WindowControl(searchDepth = 1, ClassName = 'MozillaWindowClass')
if not firefoxWindow.Exists(0):
automation.Logger.WriteLine('please run Firefox first', automation.ConsoleColor.Yellow)
return
firefoxWindow.ShowWindow(automation.ShowWindow.Maximize)
firefoxWindow.SetActive()
time.sleep(1)
tab = automation.TabControl(searchFromControl= firefoxWindow)
newTabButton = automation.ButtonControl(searchFromControl= tab, searchDepth= 1)
newTabButton.Click()
edit = automation.EditControl(searchFromControl= firefoxWindow)
# edit.Click()
edit.SendKeys('http://global.bing.com/?rb=0&setmkt=en-us&setlang=en-us{Enter}')
time.sleep(2)
searchEdit = automation.FindControl(firefoxWindow,
lambda c:(isinstance(c, automation.EditControl) or isinstance(c, automation.ComboBoxControl)) and c.Name == 'Enter your search term'
)
# searchEdit.Click()
searchEdit.SendKeys('PythonUIAutomation4Windows site:www.oschina.net{Enter}',0.05)
link = automation.HyperlinkControl(searchFromControl= firefoxWindow, SubName = 'PythonUIAutomation4Windows首页')
if not link.Exists():
return
automation.Win32API.PressKey(automation.Keys.VK_CONTROL)
link.Click() #press control to open the page in a new tab
automation.Win32API.ReleaseKey(automation.Keys.VK_CONTROL)
newTab = automation.TabItemControl(searchFromControl= tab, SubName = 'PythonUIAutomation4Windows首页')
newTab.Click()
link = automation.HyperlinkControl(searchFromControl= firefoxWindow, Name = 'yinkaisheng/PythonUIAutomation4Windows')
sx, sy = automation.Win32API.GetScreenSize()
left, top, right, bottom = link.BoundingRectangle
while bottom <= 0 or top > sy:
automation.Logger.WriteLine('press PageDown')
automation.SendKeys('{PageDown}')
time.sleep(1)
left, top, right, bottom = link.BoundingRectangle
automation.Win32API.PressKey(automation.Keys.VK_CONTROL)
link.Click()
automation.Win32API.ReleaseKey(automation.Keys.VK_CONTROL)
newTab = automation.TabItemControl(searchFromControl= tab, SubName = 'yinkaisheng/PythonUIAutomation4Windows')
newTab.Click()
starLink = automation.HyperlinkControl(searchFromControl= firefoxWindow, SubName = 'Star')
if starLink.Exists(5):
automation.GetConsoleWindow().SetActive()
automation.Logger.WriteLine('Star PythonUIAutomation4Windows after 2 seconds', automation.ConsoleColor.Yellow)
time.sleep(2)
firefoxWindow.SetActive()
time.sleep(1)
starLink.Click()
time.sleep(2)
if __name__ == '__main__':
main()
automation.GetConsoleWindow().SetActive()
input('press Enter to exit')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。