Quotes

Thursday, April 26, 2018

Auto Logon Python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

usernameStr = 'userid@gmail'
passwordStr = 'pwd'

browser = webdriver.Chrome()
browser.get(('https://accounts.google.com/signin/v2/identifier?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin'))
# fill in username and hit the next button
username = browser.find_element_by_id('Sign in')
username.send_keys(usernameStr)
nextButton = browser.find_element_by_id('next')
nextButton.click()

# wait for transition then continue to fill items
password = WebDriverWait(browser, 1).until(
    EC.presence_of_element_located((By.ID, 'Passwd')))
password.send_keys(passwordStr)

signInButton = browser.find_element_by_id('signin')
signInButton.click()


Mouse

import pyautogui import win32api import sys pyautogui.FAILSAFE = False for i in range(80000000000000000000): if win32api.GetAsyncKeyState(ord('K')): sys.exit() pyautogui.moveTo(1, 1, duration=1.25) pyautogui.click(10, 5) pyautogui.moveTo(100, 100, duration=1.25)

No comments:

Post a Comment