我想使用ALT + TAB键将一个窗口切换到另一个窗口 你能告诉我任何建议吗
我使用了以下代码,但没有使用
driver.get("https://www.netflix.com")
driver = webdriver.Edge(r"C:\Python27\Lib\site-packages\selenium\webdriver\edge\MicrosoftWebDriver.exe")
driver.implicitly_wait(1)
driver.maximize_window()
time.sleep(20)
keyAction = ActionChains(driver)
keyAction.key_down(Keys.ALT).key_down(Keys.TAB).key_up(Keys.ALT).key_up(Keys.TAB).perform()
time.sleep(10)
keyAction1 = ActionChains(driver)
keyAction1.key_down(Keys.ALT).key_down(Keys.TAB).key_up(Keys.ALT).key_up(Keys.TAB).perform()
答案 0 :(得分:0)
以下代码适用于我
我使用以下代码将Windows浏览器切换到普通浏览器,反之亦然
user32 = ctypes.windll.user32
user32.keybd_event(0x12, 0, 0, 0) #Alt
user32.keybd_event(0x09, 0, 0, 0) #Tab
user32.keybd_event(0x09, 0, 2, 0) #~Tab
user32.keybd_event(0x12, 0, 2, 0) #~Alt
time.sleep(10)
user32.keybd_event(0x12, 0, 0, 0) #Alt
user32.keybd_event(0x09, 0, 0, 0) #Tab
user32.keybd_event(0x09, 0, 2, 0) #~Tab
user32.keybd_event(0x12, 0, 2, 0) #~Alt