Exemple #1
1
 def send_command(self, cmd):
     self.save_screenshot()
     pyautogui.hotkey('ctrl', 'space')
     pyautogui.typewrite(cmd)
     self.save_screenshot()
     pyautogui.press('enter')
     pyautogui.press('escape')
Exemple #2
0
    def quoteOSHPark(self):
        """Function for navigating OSHPark's website."""

        url, user, pw = self.readConfig('oshpark', 'rigid')
        # Open new tab and go to URL
        self.newTab()
        self.driver.get(url)
        # Enter login information
        self.driver.find_element_by_css_selector('#user_email').send_keys(user)
        self.driver.find_element_by_css_selector('#user_password').send_keys(pw)
        # Click login button
        self.driver.find_element_by_css_selector('.buttons > input:nth-child(1)').click()

        self.driver.find_element_by_css_selector('#ember291').click()
        self.driver.find_element_by_css_selector('#file_selector > input:nth-child(2)').click()

        e = EWMH()
        windows = e.getClientList()
        for window in windows:
            if e.getWmName(window) == 'File Upload':
                time.sleep(0.5)
                e.setActiveWindow(window)
                e.display.flush()

        time.sleep(0.5)
        pyautogui.hotkey('ctrl', 'a')
        pyautogui.press('backspace')
        # '''get file location from config file'''
        # pyautogui.typewrite(fileLocation)
        pyautogui.press('return')
Exemple #3
0
def output_doulist(input_list):
    # 1. find button and change focus in browser
    button_pos = pyautogui.locateOnScreen('output/add_button.png')
    if not button_pos: 
        # no valid button        
        print '没有找到有效的"添加内容"按钮, 请检查后再次导出.'
        return
    elif len(list(pyautogui.locateAllOnScreen('output/add_button.png'))) > 1:
        # more than one valid button
        print '屏幕中有多个有效的"添加内容"按钮, 请检查后再次导出.'
        return
    else:
        # valid input: only one button available
        # remaining issue: the picture is not alwas found in screen...that's strange.
        pyautogui.click(button_pos)
    for i in input_list:
        # 2. press button 
        time.sleep(4)
        pyautogui.click(button_pos)
        # 3. write link
        time.sleep(2)
        pyautogui.typewrite(i)
        pyautogui.press('enter')
        # 4. add to Doulist
        time.sleep(2)
        pyautogui.press('tab')
        pyautogui.press('tab')
        pyautogui.press('tab')
        pyautogui.press('enter')
    print 'iDoulist: 书籍列表已被添加到屏幕上的豆列中.'
def chopping():
    imaging.chopping_check()
    while config.check:
        imaging.chopping_check()
        print('Chopping...')
        pyautogui.press('d')
        time.sleep(.45)
def buscar_campo_serial(serial_number):
    msg = ''
    pyautogui.PAUSE = 0.5
    pyautogui.FAILSAFE = False
    pyperclip.copy('')
    
    dondeEstaElCampoSerial = pyautogui.locateOnScreen('operator-id-field.png')
    if dondeEstaElCampoSerial is None:
        msg = 'El campo de SERIAL NUMBER no fue encontrado'
        return (False, msg)
        
    else:
        campoSerialPos = list(dondeEstaElCampoSerial)
        #print campoSerialPos
         
    centrocampoSerial = pyautogui.center(campoSerialPos)     
    #print centrocampoSerial
    pyautogui.moveTo(centrocampoSerial)
    pyautogui.click(None,None,2)
    #pyautogui.typewrite('C3WB4E768226230')
    pyautogui.typewrite(serial_number)
    pyautogui.press('enter')
    #pyautogui.press('enter')
    #pyautogui.press('enter')
    
    return (True, msg)
def dumper():
    pya.click(100, 500)
    pya.hotkey('alt', 'd')
    pya.press('enter')
    pya.hotkey('alt', 'd')
    mrn = pyperclip.copy('empty')
    pya.hotkey('ctrl', 'c')
    mrn = pyperclip.paste()
    print(mrn)
    today_path = write_as_billed(mrn)
    make_web_secretary(today_path)
    with shelve.open('d:\\JOHN TILLET\\episode_data\\dumper_data.db') as s:
        try:
            episode = s[mrn]
        except KeyError:
            pya.alert('No data available')
            return
    episode_discharge(
            episode['in_theatre'], episode['out_theatre'], 
            episode['anaesthetist'], episode['endoscopist'])
    episode_procedures(
            episode['upper'], episode['colon'],
            episode['banding'], episode['asa'])
    if (episode['upper'] in {'30490-00'}
            or 'HALO' in episode['message']
            or '32089-00' in episode['message']
            or episode['colon'] in {'32093-00', '32094-00'}
            or episode['banding'] in {'32153-00'}): 
            episode_claim()
    else:
        pya.hotkey('alt', 'c')
    episode_theatre(episode['endoscopist'], episode['nurse'],
                    episode['clips'], episode['varix_lot'])
    def startNewGame(self, genome=None):

          # Refresh state
        logger.info('in start game 200')
        logger.info(genome)
        self.readGameState()
        logger.info(self.gamestate)

        
        if genome:
            self.genome = genome
        # If game is already over, press space
        if self.gamestate == 'OVER' or not self.onGameStart:
            self.event.set()

          # Set start callback
            self.onGameStart = True
            logger.info('Trying to start')
          # Press space to begin game (repetidelly)
            pyautogui.press(' ')
            #ThreadJob(lambda x:pyautogui.press(' '),self.event, 0.3 ).start()

          # Refresh state
            self.readGameState()

        else:
          # Wait die, and call recursive action
            self.setGameEnd = 2
def getViewsWithPytesseract():
	global latestViewCount, totalViews, nothingFoundCounter, totalRuns
	while totalRuns < 10000:
		try:
			print("Runs: %s" % totalRuns)
			totalRuns += 1
			# shiftDown()
			pyautogui.press('down')
			time.sleep(0.5)
			im = screenShot()
			s = pytesseract.image_to_string(im, config='-psm 6')
			print s
			if "views" in s != -1:
				for line in s.split("\n"):
					if "views" in line:
						evaluateViews(line)
			elif "vlews" in s != -1:
				for line in s.split("\n"):
					if "vlews" in line:
						evaluateViews(line)
			elif "VIEWS" in s != -1:
				for line in s.split("\n"):
					if "vlews" in line:
						evaluateViews(line)
			else:
				if nothingFoundCounter == 15:
					saveViews(totalViews, latestViewCount)
				else:
					nothingFoundCounter += 1
					print("Nothing found %s times" % nothingFoundCounter)
					#getViewsWithPytesseract()
		except Exception, e:
			print ("Something went terribly wrong: %s" % str(e))
Exemple #9
0
def key(s):
	if 'enter' in s:
		pyautogui.press('enter')
	elif 'back' in s:
		pyautogui.press('back')
	else:
		pyautogui.typewrite(s)
def tick(direction='right', count=0):
	global oldIm
	global newIm
	# no sleep but there's a long step size... is it hanging on the screenshot???
	# screenGrab(count)

	# oldPath, newPath = None, None
	if count is 0:
		newIm = screenGrab(count)
	else:
		oldIm = newIm
		newIm = screenGrab(count)

		# shouldn't be getcwding every time
		# oldPath = os.getcwd() + '/caps/' + str(count - 1) + '.png'
		# oldPath = s
		# newPath = os.getcwd() + '/caps/' + str(count) + '.png'
	# direction = bestMove(oldPath, newPath)
	oldDirection = direction
	direction = bestMove(oldIm, newIm)

	if oldDirection not in ['space','sit']:
		pyautogui.keyUp(oldDirection)
	if direction not in ['space','sit']:

		pyautogui.keyDown(direction)
		# time.sleep(0.05)
	elif direction == "space":
		pyautogui.press('space')
	count += 1
	tick(direction, count)
Exemple #11
0
def sign_in(email, password):
    pyautogui.typewrite(email, interval=TYPE_INTERVAL)
    pyautogui.press('enter')
    time.sleep(3)
    pyautogui.typewrite(password, interval=TYPE_INTERVAL)
    pyautogui.press('enter')
    time.sleep(3)
def parse_info(name):
    driver.find_element_by_xpath('//*[@title="Search or start new chat"]').click()
    pag.typewrite(name)
    pag.press('enter')
    time.sleep(1)
    page = driver.page_source
    soup = BeautifulSoup(page, "html.parser")
    
    x = soup.find_all("span")
    numbers = []
    for i in range(0,len(list(x))):
        if str(x[i]).find(str(name)) == -1:
            continue
        else:
            numbers.append(i)
        
    del i
    
    

    date = str(datetime.now())
    name = re.search('>(.*)<', str(x[numbers[len(numbers)-1]])).group(1)
    info = re.search('>(.*)<', str(x[numbers[len(numbers)-1]+1])).group(1)
    del x
    return date,name,info
Exemple #13
0
def dir_command(dir):
    global y_pressed, dir_to_hjkl
    print(y_pressed)
    if y_pressed:
        invoke("xdotool key ctrl+alt+{}".format(dir_to_hjkl[dir]))
    else:
        pyautogui.press(dir.lower())
Exemple #14
0
 def start_scan(self):
     # print(self.cursor, self.color)
     print('starting scan in 2')
     time.sleep(2)
     prev_position = [0, 0]
     while True:
         pyautogui.press('3')
         # time.sleep(1)
         color = self.color
         image = img.grab()
         for x in range(250, 1500, 2):             # change to fishing area
             for y in range(200, 650, 2):
                 color_now = image.getpixel((x, y))
                 if np.allclose(list(color_now), list(color), atol=10):
                     print('found color in position', x, y)
                     '''self.update_s2(color_now)
                     self.color_now = color_now
                     time.sleep(1)
                     win32api.SetCursorPos((x, y))
                     print('match!')
                     self.after(2000)'''
                     if abs(x - prev_position[0] >= 10) and abs(y - prev_position[2] >= 10):
                         prev_position[0] = x
                         prev_position[1] = y
                         win32api.SetCursorPos((x, y))
                         return self.wait_thread()
         print('scan Finished with no match...')
Exemple #15
0
	def run(self):
		while 1:
			try:
				data = record_keyboard_data()
				pyautogui.typewrite(data)
				pyautogui.press('enter')
			except Exception as e:
				print "Something went wrong in keyboardThread: ", e
Exemple #16
0
def loadSymbolInChart(msComponents, symbol):
    pyautogui.moveTo(msComponents['symbolEntry']['x'], msComponents['symbolEntry']['y'], 0.25)
    safeClick(msComponents['symbolEntry']['x'], msComponents['symbolEntry']['y'])
    pyautogui.hotkey(platform.primary_key_modifier, 'a')
    pyautogui.press('delete')
    pyautogui.typewrite(symbol)
    pyautogui.typewrite(['enter'])
    wait(DELAY_CHART_LOAD)
def shiftDown():
	print "\nGoing down...\n"
	# counter = 0
	# while counter < 6:
	# 	#time.sleep(0.5)
	# 	pyautogui.press('down')
	# 	counter += 1
	pyautogui.press('down')
Exemple #18
0
	def perform_action(self, clazz):
		if clazz == 'flip':
			pyautogui.hotkey('command', 'space')
		elif clazz == 'top_down':
			pyautogui.press('space')
		elif clazz == 'right_left':
			pyautogui.press('right')
		print "dummy"
Exemple #19
0
def navigateGameWindow():
    """Get the initial focus on the game window and mute the game, getting
    ready to play."""
    # Get focus on the game by clicking the center of the game region
    pyautogui.click(GAME_CENTER[0], GAME_CENTER[1], duration=1)

    # Mute game (it helps too because it disables some in-game effects :-p)
    pyautogui.press('m')
 def bet(self, n):
     v = self.LOCATIONS['textBar']
     gui.moveTo(np.random.randint(v[0][0] + self.x, v[1][0] + self.x),
                np.random.randint(v[0][1] + self.y, v[1][1] + self.y), 
                duration = .5)
     gui.click()
     gui.typewrite(str(n), interval=0.25)
     gui.press('enter')
 def quickbooks(self):
     '''
     Starts QuickBooks. Logs in.
     '''
     startfile('"C:\Program Files (x86)\Intuit\QuickBooks Enterprise Solutions 16.0\QBW32Enterprise.exe"')
     sleep(30)
     typewrite(self.password)
     press('enter')
     sleep(5)
Exemple #22
0
def imageviewer_rightKey():
	pyautogui.press('winleft')
	name = get_actived_win_name()
	sleep(2)
	if name == 'dde-launcher':
		launcherobj = root.application(appName='dde-launcher', description='/usr/bin/dde-launcher')
		launcherobj.child('Image Viewer').click(3)
	else:
		raise Exception("dde-launcher did not opened!")
Exemple #23
0
def key():  # press keyboard
    import pyautogui
    if auth(request.args.get('password')) is False: return 'authfail'
    try:
        button = str(request.args.get('key'))
    except:
        return 'badparam'
    pyautogui.press(button)
    return str(request.args.get('key')) + ' button pressed'
Exemple #24
0
def three0_Searches():
    virtual_Keyboard(random_Letters())
    time.sleep(randint(1,3))
    pyautogui.press("enter")
    time.sleep(randint(1,5))
    click(397, 105)
    for i in range(7):
        pyautogui.press("backspace")
        time.sleep(.3)
Exemple #25
0
def check_result(USN):
    browser = webdriver.Firefox()
    browser.get("http://results.vtu.ac.in/")

    searchElem = browser.find_element_by_css_selector("body > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > b:nth-child(2) > form:nth-child(10) > p:nth-child(1) > input:nth-child(1)")
    searchElem.is_selected
    searchElem.send_keys(USN)
    
    pyautogui.press('enter')
Exemple #26
0
def launcherSearchDeepin():
	pyautogui.press('winleft')
	name = get_actived_win_name()
	sleep(2)
	if name == 'dde-launcher':
		launcherobj = root.application(appName='dde-launcher', description='/usr/bin/dde-launcher')
		launcherobj.child('search-edit').text = 'deepin'
	else:
		raise Exception("dde-launcher did not opened!")
Exemple #27
0
    def collect_relics(self):

        self.gs.window.click(self.gs.window.settings_coord)
        self.gs.window.click((self.gs.window.box[0] + 420, self.gs.window.box[1] + 150))
        time.sleep(.2)
        gui.press('esc')
        time.sleep(.1)
        self.gs.window.click((self.gs.window.box[0] + 1375, self.gs.window.box[1] + 61))

        self.load()
def genericSpammer(quantity, msg):
    try:
        pyautogui.FAILSAFE = True

        for i in range(quantity):
            pyautogui.typewrite(msg, interval=0.001)
            pyautogui.press('enter')

    except pyautogui.FailSafeException as e:
        raise e
Exemple #29
0
def click_through(i):
    ad_spotter(i)
    #for i in range(0,3):
    #    pyautogui.click()
    time.sleep(2)
    #pyautogui.click()
    #close_tab()
    pyautogui.keyDown('command')
    pyautogui.press('w')
    pyautogui.keyUp('command')
Exemple #30
0
 def clear_text(self):
     self.wait_for_app_to_be_clickable()
     pyautogui.keyDown('shift')
     pyautogui.press('end')
     pyautogui.keyUp('shift')
     pyautogui.press('backspace')
def do_type(text):
    if text == '':
        pyautogui.press('backspace')
    else:
        pyautogui.typewrite(text)
Exemple #32
0
        cy = int(mom['m01'] / mom['m00'])

    # Drawing everything in the image
    cv2.drawContours(img, [cnt], -1, (122, 122, 0), 2)
    cv2.circle(img, (cx, cy), 7, (0, 0, 255), 2)
    cv2.putText(img, "Centre", (cx, cy), cv2.FONT_HERSHEY_SIMPLEX, 1,
                (0, 0, 0), 2)
    cv2.line(img, (0, height // 2 - 70), (width, height // 2 - 70),
             (255, 255, 255), 5)
    cv2.line(img, (0, height // 2 + 70), (width, height // 2 + 70),
             (255, 255, 255), 5)

    # pressing the key
    if cy < height // 2 - 70:
        if last != "up":
            pyautogui.press("up")
        last = "up"
    elif cy > height // 2 + 70:
        if last != "down" and not downPressed:
            pyautogui.keyDown("down")
            downPressed = True
        last = "down"
    else:
        if downPressed:
            pyautogui.keyUp("down")
            downPressed = False
        last = "centre"

    cv2.imshow("Frame", img)
    cv2.imshow("Thresh", thresh)
    k = cv2.waitKey(10) & 0xFF
Exemple #33
0
import pyautogui as pyg
import time

pyg.PAUSE = 1.5
pizzaURL = "bit.ly/113thHousingSurvey"

pyg.click(468, 842)
for i in range(10):
	pyg.hotkey('ctrl', 't')
	pyg.typewrite(pizzaURL + '\n')
	pyg.click(483, 590)
	pyg.press('pagedown')
	pyg.click(483, 161)
	pyg.click(485, 586)
	pyg.press('pagedown')
	pyg.click(516, 727)
	pyg.hotkey('ctrl', 'w')

 def select(self, *args):
     pyautogui.press('shift')
     return "break"
Exemple #35
0
    print('Speak now: ')
    audio = r3.record(source, duration=3)
    print(r3.recognize_google(audio))

if 'video' in r3.recognize_google(audio):
    r2 = sr.Recognizer()
    url = 'https://www.youtube.com/results?search_query='
    with sr.Microphone() as source:
        print('Search for a video: ')
        audio = r2.record(source, duration=4)
        try:
            get = r2.recognize_google(audio, language='ro-RO')
            print(get)
            playonyt(get)
            time.sleep(5)
            pg.press('space')

        except sr.UnkownValueError:
            print('error')
        except sr.RequestError as e:
            print('failed'.format(e))

if 'Wikipedia' in r3.recognize_google(audio):
    r2 = sr.Recognizer()
    url = 'https://en.wikipedia.org/wiki/'
    with sr.Microphone() as source:
        print('Search for a wikipedia page: ')
        audio = r2.record(source, duration=3)
        try:
            get = r2.recognize_google(audio)
            print(get)
Exemple #36
0
def vaaka():
    # FAL ase pystykuva koordinaatit ensimmainen
    x1 = 1254
    x2 = 1399
    y1 = 74
    y2 = 455
    # lippaan kuvan etsinnan koordinaatit
    x3 = 730
    x4 = 952
    y3 = 713
    y4 = 923
    # toisen lippaan etsimisen koordit
    xx3 = 1299
    xx4 = 1566
    yy3 = 725
    yy4 = 926

    # ekan lippaan dragauskoordinaatit
    x5 = 1545
    y5 = 650
    # scrolli
    scrol = 0
    # %5 resetin jlk draggayskoordinaatit lippaasta aseeseen
    # uusi aseen koordinaatti lippaan draggaykseen
    ylip = 0
    # vaaka arvot falikuvan etsimiselle
    ax = 1264
    ay = 80
    ax2 = 1641
    ay2 = 205

    pyautogui.click(x=1660, y=552)
    for i in range(1, 35):
        pyautogui.scroll(1)
    pyautogui.moveTo(x=1899, y=406)
    pyautogui.dragTo(1887, 692, 2, button='left')

    for i in range(0, 26):
        print("kierros", i)
        print("ax=", ax, "ax2= ", ax2, "ay=", ay, "ay2= ", ay2)
        if i % 2 == 0 and i != 0:
            # x akseli resetti
            ax = 1264
            ax2 = 1641
            ay += 126
            ay2 += 126

        if i == 12:
            pyautogui.click(x=1660, y=552)
            for i in range(1, 14):
                pyautogui.scroll(-1)

            ax = 1264
            ax2 = 1641
            ay = 179
            ay2 = 305

        falkuva = imagesearcharea("falkuva1.png",
                                  x1,
                                  y1,
                                  x2,
                                  y2,
                                  precision=0.7,
                                  im=None)

        falkuva1 = imagesearcharea("falkuva.png",
                                   ax,
                                   ay,
                                   ax2,
                                   ay2,
                                   precision=0.7,
                                   im=None)
        falextreme = imagesearcharea("falextremeV.png",
                                     ax,
                                     ay,
                                     ax2,
                                     ay2,
                                     precision=0.7,
                                     im=None)
        falEL = imagesearcharea("lyhytfalV.png",
                                ax,
                                ay,
                                ax2,
                                ay2,
                                precision=0.7,
                                im=None)
        # kivaa = ImageGrab.grab(bbox=(ax, ay, ax2, ay2))
        #kivaa.show()

        # PYSTYASENTOETSINTA

        # VAAKATASOSEARcHI
        if falkuva1 != [-1, -1] or falextreme != [-1, -1] or falEL != [-1, -1]:

            pyautogui.click(ax + falkuva1[0] + 20,
                            ay + falkuva1[1] + 20,
                            button='right')
            time.sleep(0.2)
            #etsii klikatun inspectí ikkunan
            ins = (imagesearch("inspect.png", precision=0.5))
            print("inspectikuva: ", ins)
            time.sleep(0.2)
            #klikkaa inspectiä
            pyautogui.click(ins[0] + 2, ins[1] + 5)
            time.sleep(0.3)
            #etsii lipasta inspectistä
            lipas = imagesearcharea("lipas.png", x3, y3, x4, y4)

            print(lipas)

            #jos lipasta ei löydy, siirrytaan seuraavaan aseeseen
            if lipas[0] == -1:
                ax += 250
                ax2 += 253

                pyautogui.press('esc')
                #JOS TARVII DRAGATA LIPAS POIS
            if lipas[0] != -1:
                #     #jos ase on extreme, annetaan eri koordinaatit, jotta draggays onnistuu
                #     if falextreme == [-1, -1]:
                #
                #         pyautogui.moveTo(990, 70)
                #         pyautogui.dragTo(1722, 78, 2)
                #     else:
                #         pyautogui.moveTo(985, 8)
                #         pyautogui.dragTo(1722, 78, 2)

                lipas = imagesearcharea("lipas.png", x3, y3, x4, y4)
                # lippaan päälle hiiri
                pyautogui.moveTo(x3 + lipas[0] + 3, y3 + lipas[1] + 3, 0.5)
                #VANHA LIPPAAN ETSIMISBOKSI JOS DRAGGAA INSPECTI RUUDUN OIKEAAN REUNAAN
                #pyautogui.moveTo(xx3 + lipas[0] + 3, yy3 + lipas[1] + 3, 0.5)
                pyautogui.keyDown('ctrl')
                pyautogui.click()
                pyautogui.keyUp('ctrl')
                # vetaa lippaan reppuun
                #--vanha
                # pyautogui.dragTo(1128, 631, 1.5)
                #--vanha
                # pyautogui.click(1128, 631, button='right')
                #--uusi ctrl
                pyautogui.press('esc')
                pyautogui.click(879, 507, button='right')
                # klikkaa unload ammo'
                time.sleep(0.2)

                #--vanha drag
                # pyautogui.click(1128 + 20, 631 - 82)
                #--uus ctrl
                time.sleep(0.3)
                pyautogui.click(889, 416)
                #  time.sleep(1.5)

                #--vanha drag
                # pyautogui.moveTo(1128, 631, 0.4)
                #--uus ctrl
                pyautogui.moveTo(879, 507, 0.4)
                pyautogui.dragTo(ax + 40, ay + 60 + ylip, 1.5)
                ax += 250
                ax2 += 253
                x5 + 51

        else:
            ax += 250
            ax2 += 253
Exemple #37
0
from idlelib.multicall import r

import pyautogui
import time

time.sleep(5)
f = open("cuarteto-de-nos.txt", "r")
t = time.time()
s = 3.0

for word in f:
    pyautogui.typewrite(word)
    pyautogui.press("enter")
    time.sleep(s - ((time.time() - t) % s))
Exemple #38
0
 def enter_dungeon(self): 
     pyautogui.press(Keybinds.INTERACT)
time.sleep(3)


counter = 1

#1480 1345 499 193

img2 = cv2.cvtColor(np.array(ImageGrab.grab()), cv2.COLOR_BGR2RGB)
# x,y,w,h = cv2.selectROI("teno", img2,False,False) #x,y,w,h
x,y,w,h = 1480 ,1345, 499, 193

print(x,y,w,h)

time.sleep(2)
pyautogui.press('space')



bbox = (x,y,x+w,y+h) # left top right bottom
# bbox = (203, 684, 294, 775)
shape = (bbox[3]-bbox[1], bbox[2]-bbox[0], 3)
bg = 255
# ref_img2 = np.full(shape, bg)
ref_img2 = np.full(shape, bg)
# ref_img2 = ref_img2[:300,:500]
i = 1

while True:
    img2 = cv2.cvtColor(np.array(ImageGrab.grab(bbox)), cv2.COLOR_BGR2RGB)
    # driver.save_screenshot('temp.png')
count = 5
for i in range(count):
    print(str(count - i) + "." * (count - i))
    time.sleep(1)
print("\nExecute\n")

pya.click(
    pya.locateCenterOnScreen('captures\\0-email.png',
                             grayscale=True,
                             confidence=.5))
pya.move(1000, 0)
time.sleep(.5)

# Enter user credentials
pya.typewrite("*****@*****.**")
pya.press("tab")
time.sleep(.25)
pya.typewrite("thisisatemppassword")
pya.press("tab")
time.sleep(.25)
pya.press("enter")

# Start filling personal details
pya.move(1000, 0)
time.sleep(1)
pya.press("tab")
pya.typewrite("Bryan")
time.sleep(.25)
pya.press("tab")
pya.typewrite("Cruz")
time.sleep(.25)
Exemple #41
0
def post_comment():
    var = generate_message()
    pyautogui.write(var, interval=0.5)
    pyautogui.press('enter')
    time.sleep(2)
Exemple #42
0
def open_mspaint():
    pyautogui.hotkey('win', 'r')
    pyautogui.typewrite('mspaint')
    pyautogui.press('enter')
Exemple #43
0
def slashN() -> str:
    p.press("enter")
    return "1"
Exemple #44
0
def falmyynti():
    #FAL ase pystykuva koordinaatit ensimmainen
    x1 = 1254
    x2 = 1399
    y1 = 74
    y2 = 455
    #lippaan kuvan etsinnan koordinaatit
    x3 = 730
    x4 = 952
    y3 = 713
    y4 = 923
    #toisen lippaan etsimisen koordit
    xx3 = 1299
    xx4 = 1566
    yy3 = 725
    yy4 = 926

    #ekan lippaan dragauskoordinaatit
    x5 = 1545
    y5 = 650
    #scrolli
    scrol = 3
    #%5 resetin jlk draggayskoordinaatit lippaasta aseeseen
    #uusi aseen koordinaatti lippaan draggaykseen
    ylip = 0
    #vaaka arvot falikuvan etsimiselle
    ax = 1264
    ay = 80
    ax2 = 1641
    ay2 = 205

    pyautogui.click(x=1660, y=552)
    for i in range(1, 35):
        pyautogui.scroll(1)
    pyautogui.moveTo(x=1899, y=406)
    pyautogui.dragTo(1887, 692, 2, button='left')

    for i in range(0, 20):
        print(i, "kierrokset vilisee silimissä")
        if i == 5:
            pyautogui.click(x=1660, y=552)
            for i in range(1, scrol + 4):
                pyautogui.scroll(-1)
            # x akseli resetti
            x1 = 1254
            x2 = 1399
            scrol += 6
            #ylip += 375
        if i == 10:
            pyautogui.moveTo(x=1660, y=552)
            for i in range(1, 10):
                pyautogui.scroll(-1)
            x1 = 1264
            x2 = 1389
            y1 = 179
            y2 = 557
        if i == 15:
            x1 = 1264
            x2 = 1389
            y1 = 556
            y2 = 934

        falkuva = imagesearcharea("falkuva1.png",
                                  x1,
                                  y1,
                                  x2,
                                  y2,
                                  precision=0.7,
                                  im=None)
        falkuvaextP = imagesearcharea("falextremepysty.png",
                                      x1,
                                      y1,
                                      x2,
                                      y2,
                                      precision=0.7,
                                      im=None)
        falkuvaextLP = imagesearcharea("lyhytfalP.png",
                                       x1,
                                       y1,
                                       x2,
                                       y2,
                                       precision=0.7,
                                       im=None)
        print(falkuva, falkuvaextLP, falkuvaextP)

        #PYSTYASENTOETSINTA
        if falkuva != [-1, -1] or falkuvaextP != [-1, -1] or falkuvaextLP != [
                -1, -1
        ]:
            print("normifal:", falkuva, " extreme:", falkuvaextP)
            pyautogui.click(x1 + falkuva[0] + 20,
                            y1 + falkuva[1] + 20,
                            button='right')
            time.sleep(0.2)
            ins = (imagesearch("inspect.png", precision=0.5))
            print("inspectikuva: ", ins)
            time.sleep(0.2)

            pyautogui.click(ins[0] + 2, ins[1] + 5)
            time.sleep(0.3)
            lipas = imagesearcharea("lipas.png", x3, y3, x4, y4)

            print(lipas)

            if lipas[0] == -1:
                x1 += 127
                x2 += 127

                pyautogui.press('esc')
            if lipas[0] != -1:

                #lipas
                #lipas = imagesearcharea("lipas.png", x3, y3, x4, y4)
                # lippaan päälle hiiri
                pyautogui.moveTo(x3 + lipas[0] + 3, y3 + lipas[1] + 3, 0.5)
                pyautogui.keyDown('ctrl')
                pyautogui.click()
                pyautogui.keyUp('ctrl')
                pyautogui.press('esc')
                pyautogui.click(879, 507, button='right')
                # klikkaa unload ammo
                time.sleep(0.3)
                pyautogui.click(889, 416)
                pyautogui.moveTo(879, 507, 0.4)

                pyautogui.dragTo(x1 + 40, y1 + 170 + ylip, 1.5)
                x1 += 127
                x2 += 127
                x5 + 51

        else:
            x1 += 127
            x2 += 127

    vaaka()
    ammukset()
Exemple #45
0
        elif "restart the system" in query:
            os.system("shutdown /r /t 5")

        elif "sleep the system" in query:
            os.system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0")



###########################################################################################################################################
###########################################################################################################################################



        elif 'switch the window' in query:
            pyautogui.keyDown("alt")
            pyautogui.press("tab")
            time.sleep(1)
            pyautogui.keyUp("alt")
                   

        elif "tell me news" in query:
            speak("please wait sir, feteching the latest news")
            news()


        elif "email to avinash" in query:
               
            speak("sir what should i say")
            query = takecommand().lower()
            if "send a file" in query:
                email = '*****@*****.**' # Your email
Exemple #46
0
def loop():
    global newX, newY, oldX, oldY, listenClick, scrollMode, scrollBaseY, dragging, timeSinceFive, bgModel, bgCaptured, initialCalibrate, at, recording, timeSinceThree, numFours, isRecording
    _, frame = webcam.read()
    if not backgroundVersion:
        # flip image
        frame = cv2.flip(frame, 1)
        frame = cv2.resize(frame, (screenWidth, screenHeight))
        img = cv2.GaussianBlur(frame, (blurValue, blurValue), 0)
        imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
        # show frame
        # cv2.imshow('Blur', imgHSV)
        mask = cv2.inRange(imgHSV, lowerBound, upperBound)
        maskOpen = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernelOpen)
        maskClose = cv2.morphologyEx(maskOpen, cv2.MORPH_CLOSE, kernelOpen)
        # show frame
        cv2.imshow('maskClose', maskClose)
        # show frame
        cv2.imshow('mask', mask)
    else:  # TODO Working here
        frame = cv2.bilateralFilter(frame, 5, 50, 100)  # use smoothing filter
        frame = cv2.flip(frame, 1)
        # TODO may mess up calculations
        frame = cv2.resize(frame, (screenWidth, screenHeight))
        if rightHanded:
            cv2.rectangle(frame, (int(boxX * frame.shape[1]), 0),
                          (frame.shape[1], int(boxY * frame.shape[0])),
                          (255, 0, 0), 2)
        else:
            cv2.rectangle(
                frame, (0, 0),
                (int(boxX * frame.shape[1]), int(boxY * frame.shape[0])),
                (255, 0, 0), 2)
        cv2.imshow('original', frame)
        cv2.waitKey(1)
        # print(bgCaptured)
        if bgCaptured:
            img = removeBG(frame)
            if rightHanded:
                img = img[0:int(boxY * screenHeight),
                          int(boxX * screenWidth):screenWidth]  # clip the ROI
            else:
                img = img[0:int(boxY * screenHeight), 0:screenWidth -
                          int(boxX * screenWidth)]  # clip the ROI
            cv2.imshow('mask', img)
            # Binarize
            gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
            blur = cv2.GaussianBlur(gray, (blurValue, blurValue), 0)
            cv2.imshow('blur', blur)
            ret, thresh = cv2.threshold(blur, threshold, 255,
                                        cv2.THRESH_BINARY)
            cv2.imshow('ori', thresh)
            # maskOpen = thresh[0:0+int(screenHeight*boxY), int(screenWidth*boxX):int(screenWidth*boxX)+screenWidth]
            maskOpen = thresh
            maskOpen = cv2.resize(maskOpen,
                                  (screenWidth, screenHeight))  # TODO Here
            cv2.imshow('IMPORTANT', maskOpen)
        # TODO End of BG version
    if not backgroundVersion or (backgroundVersion and bgCaptured):
        _, conts, _ = cv2.findContours(
            cv2.resize(maskOpen, (screenWidth, screenHeight)),
            cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
        maxx, maxy, maxh, maxw = [0, 0, 0, 0]
        ci = 0
        for i in range(len(conts)):
            x, y, w, h = cv2.boundingRect(conts[i])
            if h * w > maxh * maxw:
                maxx = x
                maxy = y
                maxw = w
                maxh = h
                ci = i
        # If worthy size
        if maxw * maxh > sizeThreshold:
            detect = True
            # Finger processing
            maxCont = conts[ci]
            hull = cv2.convexHull(maxCont)
            drawing = np.zeros(img.shape, np.uint8)
            cv2.drawContours(drawing, [maxCont], 0, (0, 255, 0), 2)
            cv2.drawContours(drawing, [hull], 0, (0, 0, 255), 3)
            # cv2.imshow("test", drawing)
            isFinishCal, cnt = calculateFingers(maxCont, drawing)
            numFing = cnt + 1
            if numFing == 1:
                numFing = calculateOneZero(maxCont, frame)
            pos = calculateHighestPoint(maxCont)
            # Check for one finger
            if inputQueue.qsize() == maxQueueSize:
                if inputQueue.get() == 4:
                    numFours -= 1
            inputQueue.put(numFing)
            if numFing == 4:
                numFours += 1
            if numFours > maxQueueSize - 2 and not isRecording:
                at.start()
                isRecording = True
                playsound.playsound(
                    'C:\\Users\\huytr\\PycharmProjects\\IronHand\\beep-02.wav',
                    True)
            if numFing == 0 and isRecording:
                transcript = at.stop()
                isRecording = False
                playsound.playsound(
                    'C:\\Users\\huytr\\PycharmProjects\\IronHand\\s2.wav',
                    True)
                if transcript is not None:
                    doCommand(transcript)
            print(numFing, pos, numFours)
            # Debug
            # print(pos)
            cv2.circle(frame, pos, 5, (0, 0, 255), -1)
            cv2.imshow('Point', frame)
            # Recalibrate
            # # print(cv2.contourArea(maxCont)/screenWidth/screenHeight)
            # if cv2.contourArea(maxCont)/screenWidth/screenHeight > .5 and backgroundVersion and initialCalibrate != 0:
            #     bgCaptured = False
            # initialCalibrate = 1
        else:
            detect = False
        if detect and numFing == 1:
            scaleX = gui.size()[0] / (xBoundHigh - xBoundLow)
            scaleY = gui.size()[1] / (yBoundHigh - yBoundLow)
            oldX = newX
            oldY = newY
            newX = (pos[0] - xBoundLow) * scaleX
            newY = (pos[1] - yBoundLow) * scaleY
            listenClick = True
            scrollMode = False
        elif detect and numFing == 2:
            # if not in scroll mode, store the base y and set scroll mode to true
            if not scrollMode:
                scrollMode = True
                scrollBaseY = pos[1]
            else:
                clicks = int((scrollBaseY - pos[1]))
                gui.scroll(clicks)
        elif detect and numFing >= 5:
            scrollMode = False
            listenClick = False
            timeSinceFive = time.time()
        elif detect and numFing == 0:
            scrollMode = False
            listenClick = False
            # if recording and time.time()-timeSinceThree > 0.5:
            #     recording = False
            #     transcript = at.stop()
            #     if transcript is not None:
            #         gui.typewrite(transcript)
            if time.time() - timeSinceFive < 0.5:
                gui.keyDown('ctrl')
                gui.press('w')
                gui.keyUp('ctrl')
        # elif detect and numFing == 4:
        #     scrollMode = False
        #     listenClick = False
        #     timeSinceThree = time.time()
        #     if not recording:
        #         recording = True
        #         at.start()
        else:
            scrollMode = False
            listenClick = False
        pyautogui.typewrite(['down', 'down', '\t'])
    elif person['source'] == 'crystal ball':
        pyautogui.typewrite(['down', 'down', 'down', '\t'])
    elif person['source'] == 'money':
        pyautogui.typewrite(['down', 'down', 'down', 'down', '\t'])

# Fill out the RoboCop field.
    if person['robocop'] == 1:
        pyautogui.typewrite([' ', '\t'])
    elif person['robocop'] == 2:
        pyautogui.typewrite(['right', '\t'])
    elif person['robocop'] == 3:
        pyautogui.typewrite(['right', 'right', '\t'])
    elif person['robocop'] == 4:
        pyautogui.typewrite(['right', 'right', 'right', '\t'])
    elif person['robocop'] == 5:
        pyautogui.typewrite(['right', 'right', 'right', 'right', '\t'])

# Fill out the Additional Comments field.
    pyautogui.typewrite(person['comments'] + '\t')

# Click Submit.
    pyautogui.press('enter')

# Wait until form page has loaded.
    print('Clicked Submit.')
    time.sleep(5)

# Click the Submit another response link.
pyautogui.click(submitAnotherLink[0], submitAnotherLink[1])
    deltaframe = cv2.absdiff(gray1, gray2)
    cv2.imshow('delta', deltaframe)
    threshold = cv2.threshold(deltaframe, 25, 255, cv2.THRESH_BINARY)[1]
    threshold = cv2.dilate(threshold, None)
    cv2.imshow('threshold', threshold)
    countour, heirarchy = cv2.findContours(threshold, cv2.RETR_EXTERNAL,
                                           cv2.CHAIN_APPROX_SIMPLE)
    for i in countour:
        if cv2.contourArea(i) < 50:
            movement_detected = True
            if movement_detected is True:
                pyautogui.keyDown('ctrl')
                pyautogui.keyDown('win')
                pyautogui.keyDown('right')
                pyautogui.keyUp('ctrl')
                pyautogui.keyUp('win')
                pyautogui.keyUp('right')
                pyautogui.press('stop')
                print("Movement Detected")
                cap.release()
                cv2.destroyAllWindows()

        (x, y, w, h) = cv2.boundingRect(i)
        cv2.rectangle(frame2, (x, y), (x + w, y + h), (255, 0, 0), 2)

    cv2.imshow('window', frame2)

    if cv2.waitKey(20) == ord('q'):
        break
Exemple #49
0
def main():
    try:
        init(autoreset=True)

        print(Fore.GREEN + 'Print count start : %s' % paper_count)

        secs_between_keys = 0.01
        # regex = "Untitled - Notepad"
        # regex = "Microsoft Excel - Book1"
        regex = "Session A - [24 x 80]"

        win = WindowMgr()
        wh = win.find_window(regex)
        if wh == None:
            print('%s is not opened' % regex)
            sys.exit()

        (x, y, w, h) = win.set_onTop(wh)
        # Start at First page of CTCS program
        pyautogui.press('f12')
        pyautogui.press('f12')
        pyautogui.press('f12')
        pyautogui.press('f12')

        pyautogui.typewrite('1', interval=secs_between_keys)  #Work with CTCS
        pyautogui.press('enter')

        pyautogui.typewrite('4', interval=secs_between_keys)  #GATE
        pyautogui.press('enter')

        pyautogui.typewrite('2', interval=secs_between_keys)  #GATE out
        pyautogui.press('enter')

        # Focus on Call card item
        pyautogui.press('enter')
        import re
        callcard_rex = re.compile("^[0-9]{5}$")

        # Say Ready to process.
        from playsound import playsound
        playsound('sounds/welcome.wav')

        while True:
            callcard_number = pyautogui.prompt(
                text='Please scan Call card number :',
                title='Scan call card Number',
                default='')
            if callcard_number == 'quit' or callcard_number == None or callcard_number == 'q' or callcard_number == 'Q':
                print('See you ,Bye Bye..')
                break
            else:
                if not callcard_rex.match(callcard_number):
                    pyautogui.alert(text='Call Card number must be 5 digits',
                                    title="Invalid call card number",
                                    button='OK')
                    continue

                # Delete Ticket File
                # wh = w.find_window(regex)
                (x, y, w, h) = win.set_onTop(wh)
                win.Maximize(wh)

                # Fill Call Card
                pyautogui.press('enter')
                pyautogui.typewrite(callcard_number,
                                    interval=secs_between_keys)
                pyautogui.press('enter')
                pyautogui.press('enter')

                # Print EIR ,Capture picture and Upload to Server
                print_eir()
                # Finished

                print('Finished for call card: %s' % callcard_number)
    except:
        f = open("log.txt", "w")
        f.write(traceback.format_exc())
        print(traceback.format_exc())
x = 1
while True:
    x = x + 1
    w, h = template.shape[::-1]
    #filename1 = 'Dreehanit.png'

    base_screen = ImageGrab.grab(bbox=(1150, 0, 1900, 250))
    #cv2.imwrite(filename1, base_screen)

    base_screen.save('Dreehanit.png')

    img_rgb = cv2.imread('Dreehanit.png')
    img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
    res = cv2.matchTemplate(img_gray, template, cv2.TM_CCOEFF_NORMED)
    loc = np.where(res >= 0.7)
    print(len(loc))
    for i in loc:
        print(i)

    try:
        if loc[0] != None and loc[1] != None:
            print('F**k Yeaahhh Babe!!!!')
            pyautogui.press('3', presses=5, interval=0.0)
            #time.sleep(0.1)
            #pyautogui.press("3")
        else:
            pass
    except:
        pass

    print('--------------------------------------------------')
from mss import mss
import tensorflow as tf
import cv2
import time
import numpy as np
import pyautogui

model = tf.keras.models.load_model("minecraft.h5")

while True:
    with mss() as sct:
        screenshot = sct.shot()
    image = cv2.imread(screenshot)
    image = cv2.resize(image, (70, 70))
    image = np.array(image)
    image = np.reshape(image, (1, 70, 70, 3)) / 255.0
    predictions = model.predict(image)
    predictions = np.argmax(predictions)
    if predictions == 0:
        pyautogui.press('a')
        print('a')
    elif predictions == 1:
        pyautogui.press('d')
        print('d')
    else:
        pyautogui.press('w')
        print('w')
def main():

    speak("say    'Hi     Jarvis'     to     Activate     -JARVIS-   ")
    while True:
        print("say 'Hi jarvis' to Activate -JARVIS-")
        say = takeCommand().lower()
        if ("hi jarvis" == say):
            wishME()
            while True:

                query = takeCommand().lower(
                )  #Converting user query into lower case
                # Logic for executing tasks based on query
                if 'wikipedia' in query:  #if wikipedia found in the query then this block will be executed
                    speak('Searching Wikipedia...')
                    query = query.replace("wikipedia", "")
                    results = wikipedia.summary(query, sentences=2)
                    speak("According to Wikipedia")
                    print(results)
                    speak(results)

                # My Computer Handle
                elif 'go back' in query:
                    pyautogui.press('backspace')

                elif 'open my computer' in query:
                    path = 'C:\\Windows\\explorer.exe'
                    os.startfile(path)

                elif 'maximize tab' in query:
                    pyautogui.hotkey('win', 'up')

                elif 'go to windows' in query:
                    pyautogui.moveTo(304, 400, duration=0.1)
                    pyautogui.doubleClick()

                elif 'go to games' in query:
                    pyautogui.moveTo(831, 400, duration=0.1)
                    pyautogui.doubleClick()

                elif 'go to music' in query:
                    pyautogui.moveTo(1050, 400, duration=0.1)
                    pyautogui.doubleClick()

                elif 'go to movies' in query:
                    pyautogui.moveTo(296, 450, duration=0.1)
                    pyautogui.doubleClick()

                elif 'go to main' in query:
                    pyautogui.moveTo(552, 457, duration=0.1)
                    pyautogui.doubleClick()

                elif 'go to downloads' in query:
                    pyautogui.moveTo(1013, 267, duration=0.1)
                    pyautogui.doubleClick()

                elif 'items in start' in query:
                    pyautogui.moveTo(54, 755, duration=0.2)
                    pyautogui.click()
                    speak("what do you want to search")
                    say = takeCommand()
                    pyautogui.typewrite(say, interval=0.1)
                    pyautogui.press('enter')

                elif 'system shutdown' in query:
                    pyautogui.hotkey('ctrl', 'esc')
                    pyautogui.moveTo(27, 718, duration=0.1)
                    pyautogui.click()
                    pyautogui.moveTo(59, 629, duration=0.1)
                    pyautogui.click()

                elif 'system restart' in query:
                    pyautogui.hotkey('ctrl', 'esc')
                    pyautogui.moveTo(27, 718, duration=0.1)
                    pyautogui.click()
                    pyautogui.moveTo(57, 657, duration=0.1)
                    pyautogui.click()

                elif 'go to desktop' in query:
                    pyautogui.hotkey('win', 'd')
                # computer handle end

                # File Handling
                elif 'search karo' in query:
                    pyautogui.press('f3')
                    speak('search what sir!')
                    say = takeCommand()
                    pyautogui.write(say, interval=0.1)
                    pyautogui.press('down')
                    pyautogui.press('enter')

                elif 'close' in query:
                    pyautogui.hotkey('ctrl', 'w')

                elif 'create new folder' in query:
                    pyautogui.hotkey('ctrl', 'shift', 'n')
                    say = takeCommand()
                    if 'rename' in say:
                        speak("sir please say name for folder")
                        say = takeCommand()
                        pyautogui.write(say, interval=0.1)
                        pyautogui.press('enter')
                    else:
                        pyautogui.press('enter')

                elif 'maximize' in query:
                    pyautogui.hotkey('win', 'up')

                elif 'minimize' in query:
                    pyautogui.hotkey('win', 'up')

                elif 'copy file' in query:
                    pyautogui.hotkey('ctrl', 'c')

                elif 'paste file' in query:
                    pyautogui.hotkey('ctrl', 'v')

                elif 'cut file' in query:
                    pyautogui.hotkey('ctrl', 'x')

                elif 'open new' in query:
                    pyautogui.hotkey('ctrl', 'n')

                elif 'hold ctrl' in query:
                    pyautogui.keyDown('ctrl')

                elif 'hold shift' in query:
                    pyautogui.keyDown('shift')

                elif 'release ctrl' in query:
                    pyautogui.keyUp('ctrl')

                elif 'release shift' in query:
                    pyautogui.keyUp('shift')

                elif 'select all' in query:
                    pyautogui.hotkey('ctrl', 'a')
                # file handling end

                # Notepad handle
                elif 'open notepad' in query:
                    pyautogui.moveTo(54, 755, duration=0.2)
                    pyautogui.click()
                    pyautogui.write("notepad", interval=0.2)
                    pyautogui.press('enter')

                elif 'save this file' in query:
                    pyautogui.hotkey('ctrl', 's')
                    say = takeCommand()
                    pyautogui.write(say, interval=0.2)
                    pyautogui.press('enter')
                    pyautogui.hotkey('alt', 'f4')

                # Notes end

                # Start handle
                elif 'open start' in query:
                    pyautogui.hotkey('ctrl', 'esc')

                elif 'scroll up' in query:
                    pyautogui.vscroll(343)

                elif 'scroll down' in query:
                    pyautogui.vscroll(-343)

                #start end

                # Wifi Handle
                elif 'connect ' in query:
                    pyautogui.moveTo(1220, 756, duration=0.1)
                    pyautogui.click()
                    time.sleep(2)
                    pyautogui.moveTo(1058, 681, duration=0.1)
                    pyautogui.click()
                    time.sleep(2)
                    pyautogui.moveTo(1220, 756, duration=0.1)
                    pyautogui.click()

                elif 'disconnect ' in query:
                    pyautogui.moveTo(1220, 756, duration=0.1)
                    pyautogui.click()
                    time.sleep(2)
                    pyautogui.moveTo(1058, 681, duration=0.1)
                    pyautogui.click()
                    time.sleep(2)
                    pyautogui.moveTo(1220, 756, duration=0.1)
                    pyautogui.click()
                #wifi end

                elif 'who am i' in query:
                    print(speak)
                    speak(
                        'Your name is Masoom Zaid. You are a python programmer.'
                    )

                elif 'kya kar sakte ho' in query:
                    speak(
                        "Sir I can not        break        the           moon          and            stars             because         won't        be       that       logical        thing "
                    )
                    speak(
                        "But !  Sir    i      Do     allthings      what      do       you        want!"
                    )

                elif ("jarvis" == query):
                    speak("yes sir")

                #km player automation
                elif 'forward' in query:
                    pyautogui.press('right')

                elif 'more forward' in query:
                    pyautogui.press('right', presses=3)

                elif 'backward' in query:
                    pyautogui.press('left')

                elif 'more backward' in query:
                    pyautogui.press('left', presses=3)

                elif 'pause' in query:
                    pyautogui.press('space')

                elif 'play' in query:
                    pyautogui.press('space')

                elif 'full screen' in query:
                    pyautogui.hotkey('ctrl', 'enter')

                elif 'window screen' in query:
                    pyautogui.hotkey('ctrl', 'enter')

                elif 'jyada karo' in query:
                    pyautogui.press('up', presses=5)

                elif 'kam karo' in query:
                    pyautogui.press('down', presses=5)
                # KM Player End

                elif ("search on google" == query):
                    speak(
                        "sir can u tell me what do you want to search on Google"
                    )

                    said = takeCommand()
                    text = said
                    speak("Searching google....")
                    chromedriver = "C:\\Users\\Shadab\\Desktop\\jarvis\\chromedriver.exe"
                    driver = webdriver.Chrome(chromedriver)
                    driver.get("https://www.google.co.in/")
                    driver.find_element_by_name("q").send_keys(text)

                    driver.find_element_by_xpath(
                        "//*[@id='tsf']/div[2]/div[1]/div[3]/center/input[1]"
                    ).click()

                elif ("search on youtube" == query):

                    speak(
                        "sir can u tell me what do you want to search on Youtube"
                    )
                    said = takeCommand()
                    text = said
                    speak("Searching youtube....")
                    driver.get("https://www.youtube.com/")
                    driver.find_element_by_name("search_query").send_keys(text)

                    driver.find_element_by_xpath(
                        "//*[@id='search-icon-legacy']/yt-icon").click()

                elif ("search on gaana" == query):

                    speak(
                        "sir can u tell me what do you want to search on gaana"
                    )
                    said = takeCommand()
                    text = said
                    speak("Searching gaana....")
                    chromedriver = "C:\\Users\\Shadab\\Desktop\\jarvis\\chromedriver.exe"
                    driver = webdriver.Chrome(chromedriver)
                    driver.get("https://gaana.com/")
                    driver.find_element_by_id("sb").send_keys(text)

                    driver.find_element_by_xpath(
                        "//*[@id='mainarea']/div[1]/div[2]/div[1]/div[1]/a"
                    ).click()

                elif 'how are you' in query:
                    speak("i am fine sir thank you for asking!")
                    speak("How can i help you sir")

                elif ("open google" == query):
                    speak("opening google...")
                    webbrowser.open('google.com')

                elif ("google khol do" == query):
                    speak("opening google...")
                    webbrowser.open('google.com')

                elif 'open converter' in query:
                    speak("opening Y 3 Mate...")
                    webbrowser.open(
                        "https://www.y2mate.com/en5/download-youtube")

                elif ("open youtube" == query):
                    speak("opening youtube...")
                    webbrowser.open('youtube.com')

                elif 'open gaana' in query:
                    speak("opening gaana...")
                    webbrowser.open("gaana.com")

                elif 'open facebook' in query:
                    speak("opening facebook....")
                    webbrowser.open("facebook.com")

                elif 'open codewithharry' in query:
                    speak("opening code with harry....")
                    webbrowser.open("codewithharry.com")

                elif 'edureka channel' in query:
                    speak("openeing edureka....")
                    webbrowser.open(
                        "https://www.youtube.com/channel/UCkw4JCwteGrDHIsyIIKo4tQ"
                    )

                elif 'open programming channel' in query:
                    speak("opening sir")
                    webbrowser.open(
                        "https://www.youtube.com/channel/UCeVMnSShP_Iviwkknt83cww"
                    )

                elif 'open stackoverflow' in query:
                    speak("opening stack over flow")
                    webbrowser.open("stackoverflow.com")

                elif 'open torrent' in query:
                    speak("opening torrent...")
                    torrent_path = "C:\\Users\\Shadab\\AppData\\Roaming\\uTorrent\\uTorrent.exe"
                    os.startfile(torrent_path)

                elif 'open photoshop' in query:
                    speak("opening photoshop...")
                    photoshop_path = "C:\\Program Files (x86)\Adobe\\Adobe Photoshop CC 2014 (32 Bit)\\Photoshop.exe"
                    os.startfile(photoshop_path)

                elif 'open vs code' in query:
                    speak("opening v s code...")
                    vs_path = "C:\\Users\\Shadab\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"
                    os.startfile(vs_path)

                elif 'open pycharm' in query:
                    speak("opening pycharm...")
                    pycharm_path = "C:\\Program Files\\JetBrains\\PyCharm Community Edition 2020.1.2\\bin\\pycharm64.exe"
                    os.startfile(pycharm_path)

                elif 'open music player' in query:
                    speak("opening  audio  player...")
                    km_path = "C:\\KMPlayer\\KMPlayer.exe"
                    os.startfile(km_path)

                elif 'open project folder' in query:
                    speak("opening projects...")
                    path_fol = "H:\\python projects"
                    os.startfile(path_fol)

                elif 'open full course' in query:
                    speak("opening courses...")
                    path_Lio = "H:\\Learn in one video"
                    os.startfile(path_Lio)

                elif 'programming tutorials' in query:
                    speak("opening tutorials...")
                    path_program = "H:\\Programming Videos"
                    os.startfile(path_program)

                elif 'open music folder' in query:
                    speak("opening sir...")
                    path_music = "F:\\New Songs"
                    os.startfile(path_music)

                elif 'play yalgaar song' in query:
                    speak("playing yalgaar ")
                    path_music = "F:\\musics\\15.mp3"
                    os.startfile(path_music)

                elif 'open sublime ' in query:
                    speak("opening sublime.")
                    sublime_path = "C:\\Program Files\\Sublime Text 3\\sublime_text.exe"
                    os.startfile(sublime_path)

                elif 'open voice' in query:
                    speak("opening sir!")
                    voice_path = "C:\\Users\\Public\\Desktop\\Vocal Remover Pro.exe"
                    os.startfile(voice_path)

                elif 'the time' in query:
                    strTime = datetime.datetime.now().strftime("%H:%M:%S")
                    speak(f"Sir, the time is {strTime}")

                elif 'play songs' in query:
                    os.startfile(random.choice(songs))

                elif 'change song' in query:
                    os.startfile(random.choice(songs))

                elif 'quit' in query:
                    speak("ok sir! have a nice day")
                    exit()
Exemple #53
0
import pyautogui as p
import pyperclip
msg = pyperclip.paste().split()
for i in range(len(msg) - 1, -1, -1):
    p.press(msg[i])

def do_press(key):
    print("Pressing '" + key + "' " + str(multiplier_keys) + " time" + ('s' if multiplier_keys != 1 else ''))
    for x in range(multiplier_keys):
        pyautogui.press(key)
    cx = int(M["m10"] / M["m00"])
    cy = int(M["m01"] / M["m00"])
    center = (cx, cy)
    cv2.circle(fram, center, 7, (255, 0, 0), -1)
    cv2.imshow("frame", fram)
    if prevcenter[0] > 0 and prevcenter[1] > 0:
        cutoff = dst(center[0], center[0], prevcenter[0], prevcenter[1])
        #print(cutoff)
        if cutoff > 1000:
            if abs(center[0] - prevcenter[0]) > abs(center[1] - prevcenter[1]):
                print(((center[0] - prevcenter[0]) / (time.time() - init)))
                if 175 < abs(
                    (center[0] - prevcenter[0]) / (time.time() - init)) < 300:
                    #print(((center[0]-prevcenter[0])/(time.time()-init)))
                    if center[0] - prevcenter[0] > 0:
                        pyg.press(['right'])
                    else:
                        pyg.press(['left'])
            else:
                print(((center[1] - prevcenter[1]) / (time.time() - init)))
                if 175 < abs(
                    (center[1] - prevcenter[1]) / (time.time() - init)) < 300:

                    if center[0] - prevcenter[0] > 0:
                        pyg.press(['down'])
                    else:
                        pyg.press(['up'])
    init = time.time()
    prevcenter = center
    #print(final)
    #ser.write(final)
import pyautogui
import time

#Make sure that your chrome browser is pin to the taskbar

pyautogui.moveTo(1777, 13, duration=1)
pyautogui.click()
pyautogui.moveTo(222, 1054, duration=1)
pyautogui.click()
pyautogui.moveTo(466, 63, duration=1)
pyautogui.click()
pyautogui.write("Google doodle hurdles", interval=0.1)
pyautogui.press('enter')
time.sleep(3)
pyautogui.moveTo(438, 397, duration=1)
pyautogui.click()
time.sleep(5)
pyautogui.moveTo(950, 385, duration=1)
time.sleep(5)
pyautogui.click()

for i in range(300):
    pyautogui.press('right')
    pyautogui.press('left')
Exemple #57
0
def find_next_comment():
    badcode = True
    while badcode:
        pyautogui.press('down')
        if pyautogui.locateCenterOnScreen('comment.png', confidence=0.6):
            badcode = False
Exemple #58
0
def cleanse():
    press('y')
Exemple #59
0
def fire_ship():
    if not pag.pixelMatchesColor(*settings.AUTO_PILOT, (76, 232, 170),
                                 tolerance=30):
        move_ship2()

    pag.press('`', presses=1, interval=0.25)
    pag.press('r', presses=1, interval=0.25)

    nearest_enemy_loc = select_enemy()
    # print(nearest_enemy_loc)

    if not nearest_enemy_loc:
        pag.sleep(10)
        return

    move_crosshair(nearest_enemy_loc)
    global FIRE_ROUNDS
    pag.sleep(2)

    # fire if gun is ready
    if pag.pixelMatchesColor(*settings.GUN_READY, (30, 200, 120),
                             tolerance=30):
        pag.click(clicks=2, interval=0.25)

    pag.press('r', presses=1, interval=0.25)
    if not FIRE_ROUNDS % 10:
        # print(f'#{FIRE_ROUNDS} use consuption')
        pag.press('t', presses=1, interval=0.25)
        pag.press('y', presses=1, interval=0.25)
        pag.press('u', presses=1, interval=0.25)

    pag.sleep(1)
    FIRE_ROUNDS += 1
Exemple #60
-1
def test_animatorStepIncrement(cartavisInstance, cleanSlate):
    """
    Test that the Animator can be set to different step increment values.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Open animator settings
    _openAnimatorSettings()

    # Find the step increment spin box and change the step increment to 2
    stepIncrement = ImageUtil.locateCenterOnScreen('test_images/stepIncrement.png')
    pyautogui.click(x=stepIncrement[0]+40, y=stepIncrement[1])
    pyautogui.press('delete')
    pyautogui.typewrite('2')
    pyautougi.press('return')

    # Go to the next channel value 
    a[0].setChannel(0)
    _getNextValue()
    assert a[0].getChannelIndex() == 2

    # Close animator settings 
    _openAnimatorSettings()