Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def resetMouse():
pyautogui.moveTo(*origin)
mousepos = P(*pyautogui.position())
self.assertEqual(mousepos, origin)
# moving the mouse over time (1/5 second)
desired -= P(42, 42)
pyautogui.moveTo(desired.x, desired.y, duration=0.2)
mousepos = P(*pyautogui.position())
self.assertEqual(mousepos, desired)
# Passing a list instead of separate x and y.
desired += P(42, 42)
pyautogui.moveTo(list(desired))
mousepos = P(*pyautogui.position())
self.assertEqual(mousepos, desired)
# Passing a tuple instead of separate x and y.
desired += P(42, 42)
pyautogui.moveTo(tuple(desired))
mousepos = P(*pyautogui.position())
self.assertEqual(mousepos, desired)
# Passing a sequence-like object instead of separate x and y.
desired -= P(42, 42)
pyautogui.moveTo(desired)
mousepos = P(*pyautogui.position())
self.assertEqual(mousepos, desired)
import pyautogui
from selenium import webdriver
import time
import os
'''chrome_driver_path = os.path.abspath('..') + "\\Drivers\\chromedriver.exe"
driver=webdriver.Chrome(chrome_driver_path)
driver.maximize_window()
driver.get("http://demo.guru99.com/test/upload/")
driver.implicitly_wait(5)
time.sleep(5)
pyautogui.hotkey('ctrl', 'a')'''
screenWidth, screenHeight = pyautogui.size()
currentMouseX, currentMouseY = pyautogui.position()
print("screenWidth - {0},screenHeight - {1}".format(screenWidth, screenHeight))
print("currentMouseX - {0},currentMouseY - {1}".format(currentMouseX, currentMouseY))
pyautogui.keyDown('win')
pyautogui.keyDown('m')
pyautogui.keyUp('m')
pyautogui.keyUp('win')
'''pyautogui.moveTo(100, 150)
pyautogui.click()
print(bcolors.OKBLUE + "Testing PyAutoGui keyboard" + bcolors.ENDC)
try:
pyautogui.typewrite("")
print(pyautogui.typewrite(""))
except (IOError, OSError) as e:
print(bcolors.FAIL + "ERROR" + bcolors.ENDC)
print(e)
except:
print("Unexpected error:", sys.exc_info()[0])
raise
print(bcolors.OKBLUE + "Testing PyAutoGui mouse" + bcolors.ENDC)
try:
pyautogui.position()
print(pyautogui.position())
except (IOError, OSError) as e:
print(bcolors.FAIL + "ERROR" + bcolors.ENDC)
print(e)
except:
print("Unexpected error:", sys.exc_info()[0])
raise
else:
print("Version: " + pyautogui.__version__)
print("")
print(
bcolors.BOLD + bcolors.OKGREEN + "PyAutoGui working correctly." + bcolors.ENDC
)
print("")
print(
"_____________________________________________________________________________________"
self.detector.tick( dataDicts )
# Early return for quicker detection
if( self.detector.detect_silence() ):
return self.detector.tickActions
mouseMoving = False
if( self.detector.detect("click") ):
click()
elif( self.detector.detect("moving" ) ):
mouseMoving = True
if( self.mode != "precision" ):
if( self.mode == "regular" ):
press("f4")
self.mode = "precision"
self.centerXPos, self.centerYPos = pyautogui.position()
elif( self.detector.detect("rightclick") ):
click(button='right')
elif( self.detector.detect("scroll_up") ):
scroll( 150 )
elif( self.detector.detect("scroll_down") ):
scroll( -150 )
elif( self.detector.detect( "exit" ) ):
self.modeSwitcher.turnOnModeSwitch()
elif( self.detector.detect( "special" ) ):
quadrant = detect_mouse_quadrant( 3, 3 )
if( quadrant == 1 ):
hotkey('alt', 'left')
elif( quadrant == 2 ):
hotkey('ctrl', 't')
elif( quadrant == 3 ):
hotkey('ctrl', 'w')
def run(self):
while self.running:
self.click()
sleep(self.time_step)
if (self.x, self.y) != position():
self.running=False
def detect_screen_edge( threshold ):
width, height = pyautogui.size()
x, y = position()
edges = []
if( y <= threshold ):
edges.append( "up" )
elif( y >= height - threshold ):
edges.append( "down" )
if( x <= threshold ):
edges.append( "left" )
elif( x >= width - threshold ):
edges.append( "right" )
return edges