示例#1
0
def test_maximize_restore(cartavisInstance, cleanSlate):
    """
    Test that a window can be maximized and then restored to 
    its original position
    """
    # Find and select the animation window 
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])

    # Look for the maximize button in the submenu
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is a single animator window
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Right click the context menu to restore a animator window
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there are exactly the same number of windows as there were originally and the animation window is present
    assert len(cartavisInstance.getAnimatorViews()) == 1
示例#2
0
 def waiting_for_fish(self):
     time.clock()
     tolerance = t = 5
     while True:
         splash = (156, 150, 135)
         density = []
         image = img.grab()
         colors = set()
         cursor_position = win32api.GetCursorPos()
         x1, y1 = cursor_position[0], cursor_position[1]
         a = (x1 - 50, x1)
         b = (y1 - 25, y1 + 25)
         # time.clock()
         for x in range(a[0], a[1]):
             for y in range(b[0], b[1]):
                 # self.after(1, win32api.SetCursorPos((x, y)))
                 colors.add(image.getpixel((x, y)))
         for i in colors:
             if abs(splash[0] - i[0] <= t):
                 if abs(splash[1] - i[1] <= t):
                     if abs(splash[2] - i[2] <= t):
                         density.append(i)
         print('density length is', len(density))
         if len(density) > 100:
             pyautogui.rightClick()
             return self.start_scan()
         #print(time.clock())
         #print(colors)
         #print(len(colors))
         time.sleep(0.5)
         if time.clock() > 18:
             return self.start_scan()
     return self.start_scan()
示例#3
0
def test_remove(cartavisInstance, cleanSlate):
    """
    Test that an existing window can be removed
    """
    windowCount = len(cartavisInstance.getPluginList())

    # Find and select the animation window
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None 
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)

    # Look for the window button in the submenu and remove the window
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is one animator window and no other windows
    assert len(cartavisInstance.getAnimatorViews()) == 1
    assert len(cartavisInstance.getPluginList()) == 1

    # Verify that there is one less window than there was originally and the animator window is not in the list
    assert len(cartavisInstance.getAnimatorViews()) == 0
    assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
示例#4
0
def test_animator_to_casaimageloader(cartavisInstance, cleanSlate):
    """
    Test that we can change an animator to a CasaImageLoader
    """
    # Get the animation window count and make sure it is non-zero
    animWindowList = len(cartavisInstance.getAnimatorViews())
    assert animWindowList > 0 

    # Get the image window count 
    imageWindowList = len(cartavisInstance.getImageViews())

    # Locate an animator window and bring up the right-context menu,
    # changing to a CasaImageLoader.
    animatorWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    pyautogui.doubleClick( x=animatorWindow[0], y=animatorWindow[1])
    time.sleep(2)
    pyautogui.rightClick( x=animatorWindow[0], y=animatorWindow[1])
    pyautogui.press('right')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that the animation count has gone down by one and the image count 
    # has increased by one
    newAnimWindowCount = len(cartavisInstance.getAnimatorViews())
    newImageWindowCount = len(cartavisInstance.getImageViews())
    assert newAnimWindowCount == animWindowList - 1
    assert newImageWindowCount == imageWindowList + 1
示例#5
0
def _saveImage(imageWindow):
    """
    Brings up the save image dialog, presses the Save button, and then
    closes the dialog.

    Parameters
    ----------
    imageWindow:
        The image window which has already been located.
    """
    pyautogui.rightClick(x=imageWindow[0], y=imageWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    saveButton = ImageUtil.locateCenterOnScreen(
                    'test_images/saveImageButton.png')
    assert saveButton != None
    pyautogui.click( x=saveButton[0], y=saveButton[1] )
    closeButton = ImageUtil.locateCenterOnScreen('test_images/closeButton.png')
    assert closeButton != None
    pyautogui.click( x=closeButton[0], y=closeButton[1] )
示例#6
0
def test_global_prefs(cartavisInstance, cleanSlate):
    """
    Test that object specific settings can also act globally.
    Set the animator to jump. Save the preferences. Open two animators. Restore the preferences.
    Check the second animator is also set to jump.
    """
    # Set the animator to jump 
    settingsButton = ImageUtil.locateCenterOnScreen( "test_images/animatorSettingsCheckBox.png")
    assert settingsButton != None
    pyautogui.click( x=settingsButton[0], y=settingsButton[1])

    # Click the jump radio button
    jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png')
    assert jumpButton != None
    pyautogui.doubleClick( x=jumpButton[0], y=jumpButton[1])

    # Save a snapshot. Make sure preferences are checked and 
    # layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '')
    s.save()

    # Find an image window and change it into an animator
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.rightClick( x=imageWindow[0], y=imageWindow[1])
    pyautogui.press('right')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Find the settings button on the animator and click it so the jump will be visible 
    settingsButton = ImageUtil.locateCenterOnScreen('test_images/settingsCheckBox.png')
    assert settingsButton != None
    pyautogui.click( x=settingsButton[0], y=settingsButton[1])

    # Restore the preferences
    s[0].restore()

    # Check that both animators are not displaying jump
    # Verify that the animator jump end behaviour is checked in the screenshot after the tests have been run
    pyautogui.screenshot('layout_check/bothAnimatorsJump.png')
    s[0].delete()
示例#7
0
def test_maximize_removed(cartavisInstance, cleanSlate):
    """
    Test that a window can be maximized and then removed.
    """
    windowCount = len(cartavisInstance.getPluginList())

    # Find and select the animation window
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.click( x=animWindow[0], y=animWindow[1])

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Look for the maximize button in the submenu
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify there is a single animator window
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Now right click the context menu to remove the animator window
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is one less window than there was originally and the animation window is not in the list
    assert len(cartavisInstance.getAnimatorViews()) == 0
    assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
示例#8
0
def test_restore_missing(cartavisInstance, cleanSlate):
    """
    The purpose of this test is to test that if we try to restore preferences for 
    a widget that is not present there are no problems. 
    We verify an animator is present. We save the preferences. We remove the animator
    We verify that there is not a problem by checking error status is empty and window
    count remains the same with no animator.
    """
    # Verify that there is just one animator
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Save a snapshot. Make sure preferences are checked and 
    # layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '')
    s.save()

    # Locate the animator and bring up the right-context menu,
    # changing to a CasaImageLoader.
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.press('down')
    pyautogui.press('right')    
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there are no animation windows 
    assert len(cartavisInstance.getAnimatorViews()) == 0

    # Restore the preferences
    s[0].restore()
    time.sleep(2)

    # No way to check for errors, hence, take a screenshot
    pyautogui.screenshot('layout_check/checkNoErrors.png')
    s[0].delete()
示例#9
0
def 模具一一FF浏览器窗口():
    time.sleep(1)  # 等待 )
    pag.moveTo(490, 920)  # 鼠标移动X.Y 方位  打开数据库的sql 命令界面 按钮
    pag.rightClick()  # 右击

    time.sleep(2)  # 等待 )
import pyautogui
print(pyautogui.size())
width, height = pyautogui.size()
print(pyautogui.position())

pyautogui.moveTo(10,10)
pyautogui.moveTo(10,10,duration=1.5)

pyautogui.moveRel(200,0,duration=2)

print(pyautogui.position())
pyautogui.click(339,38)

pyautogui.doubleClick(339,38)
pyautogui.rightClick(339,38)
# get current position of courser
# top left corner is 0,0
# Note: in programming, Y-coordinates increase when going down!
pyautogui.position()

# move courser to specific coordinate
pyautogui.moveTo(30, 30)
pyautogui.moveTo(30, 30, duration=3)  # slow down movement

# move relative to where the courser already is
pyautogui.moveRel(200, 0)  # move 200 to the right
pyautogui.moveRel(200, 0, duration=2)

pyautogui.moveRel(0, -100, duration=2)  # move up

#Specifiy the position you want to click on:
pyautogui.position()
# then click it
pyautogui.click(565, 25)
#double click
pyautogui.doubleClick(565, 25)
# right click
pyautogui.rightClick(565, 25)
# middle click
pyautogui.middleClick(565, 25)

# get real time position of courser:
# In terminal:
# import pyautogui
# pyautogui.displayMousePosition()
示例#12
0
            return [b_x, b_y]


if __name__ == '__main__':
    wowForFront()
    firstPersonView()
    empty_slot = checkBagSlots()
    catches = 0
    attempts = 1
    print('Let\'s start fishing!')
    while empty_slot:
        print('Attempt {}'.format(attempts))
        pyautogui.keyDown('1')
        pyautogui.keyUp('1')
        time.sleep(2)
        print('Searching for bobber...')
        loc = searchBobber(frame[0], frame[1], frame[2], frame[3], hex_color)
        if loc[0] != 0:
            bite = listenOutput(30)
            if bite:
                pyautogui.rightClick(x=loc[0] + frame[0], y=loc[1] + frame[1], duration=0.2)
                catches += 1
                time.sleep(2)
                loc = [0, 0]
            if catches % 20 == 0:
                empty_slot = checkBagSlots()
        attempts += 1
    if empty_slot == False:
        print('That\'s all, there was {} attempts with {} catches, quiting...'.format(attempts, catches))
        sys.exit()
示例#13
0
                x = x * (SCREEN_X / CAMERA_X)
                y = y * (SCREEN_Y / CAMERA_Y)
                MOVEMENT_START = M_START
                print("X: " + str(x) + " Y: " + str(y))
                pyautogui.moveRel(x, y)
            else:
                MOVEMENT_START = (x, y)

            cv2.circle(crop_img, (display_x, display_y), 5, [255, 255, 255], 20)
        elif count_defects == 5 and CLICK is None:
            CLICK = time.time()
            pyautogui.click()
            CLICK_MESSAGE = "LEFT CLICK"
        elif count_defects == 4 and CLICK is None:
            CLICK = time.time()
            pyautogui.rightClick()
            CLICK_MESSAGE = "RIGHT CLICK"
    else:
        MOVEMENT_START = None

    if CLICK is not None:
        cv2.putText(img, CLICK_MESSAGE, (50, 200), cv2.FONT_HERSHEY_SIMPLEX, 3, 3)
        if CLICK < time.time():
             CLICK = None

    cv2.putText(img, "Defects: " + str(count_defects), (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, 2)
    cv2.imshow('Gesture', img)
    cv2.imshow('Drawing', drawing)

    k = cv2.waitKey(10)
    if k == 27:
示例#14
0
sysTrayIconCoords = pyautogui.locateCenterOnScreen('sound_panel_1.png',
                                                   grayscale=True,
                                                   confidence=0.8)
sysTrayIconCoords = sysTrayIconCoords or pyautogui.locateCenterOnScreen(
    'sound_panel_2.png', grayscale=True, confidence=0.8)
sysTrayIconCoords = sysTrayIconCoords or pyautogui.locateCenterOnScreen(
    'sound_panel_3.png', grayscale=True, confidence=0.8)
while (sysTrayIconCoords == None):
    sysTrayIconCoords = pyautogui.locateCenterOnScreen('sound_panel_1.png',
                                                       grayscale=True,
                                                       confidence=0.8)
    sysTrayIconCoords = sysTrayIconCoords or pyautogui.locateCenterOnScreen(
        'sound_panel_2.png', grayscale=True, confidence=0.8)
    sysTrayIconCoords = sysTrayIconCoords or pyautogui.locateCenterOnScreen(
        'sound_panel_3.png', grayscale=True, confidence=0.8)
pyautogui.rightClick(sysTrayIconCoords[0], sysTrayIconCoords[1])
pyautogui.moveRel(soundsContextMenuOffset['x'], soundsContextMenuOffset['y'])
pyautogui.leftClick()

# Go to Playback devices tab
playbackTabCoords = pyautogui.locateCenterOnScreen('playback_tab.png',
                                                   grayscale=True,
                                                   confidence=0.8)
while (playbackTabCoords == None):
    playbackTabCoords = pyautogui.locateCenterOnScreen('playback_tab.png',
                                                       grayscale=True,
                                                       confidence=0.8)
    # print('Could not find Playback tab, exit...')
    # sys.exit(1)
pyautogui.leftClick(playbackTabCoords[0], playbackTabCoords[1])
示例#15
0
def RightClickOnPosition(x=None, y=None):
    '''
    Right clicks on a pixel position on the visible screen determined by x and y coördinates.
    '''
    return pyautogui.rightClick(x, y)
示例#16
0
def run_algorithm():
    skip_state = False
    pyautogui.moveTo(500, 400, duration=0.5)
    pyautogui.rightClick()
    pyautogui.moveTo(571, 575, duration=0.5)
    pyautogui.click()
    time.sleep(1.5)
    # name image
    pyautogui.typewrite(str(image_num))
    time.sleep(1)
    pyautogui.press('enter')
    # click on large image
    pyautogui.moveRel(-150, -250, duration=0.5)
    pyautogui.rightClick()
    pyautogui.moveRel(10, 5, duration=0.5)
    pyautogui.click()
    time.sleep(4)
    pyautogui.moveTo(283, 13, duration=1)
    pyautogui.click()
    time.sleep(4)
    # Grab affiliate link text
    pyautogui.moveTo(186, 90, duration=1)
    time.sleep(3)
    pyautogui.doubleClick()
    time.sleep(3)
    pyautogui.keyDown('ctrl')
    pyautogui.press('c')
    pyautogui.keyUp('ctrl')
    #copy from clipboard to variable
    clip.OpenClipboard()
    afl_link = clip.GetClipboardData()
    clip.CloseClipboard()
    if "http" not in afl_link:
        afl_link = "www.kiitri.com"

    #Get text desciption of this item
    description = run_bs4(afl_link)
    # close tab
    pyautogui.keyDown('ctrl')
    pyautogui.press('w')
    pyautogui.keyUp('ctrl')
    #go to pinterest tab
    pyautogui.moveTo(283, 13, duration=0.5)
    pyautogui.click()
    # hover over plus sign
    pyautogui.moveTo(1192, 90, duration=1)
    # move to hover over "upload image"
    pyautogui.moveTo(1192, 156, duration=0.5)
    pyautogui.click()
    time.sleep(0.5)
    # hover over "destination url"
    pyautogui.moveTo(567, 446, duration=0.5)
    pyautogui.click()
    time.sleep(0.5)
    # paste affiliate link
    pyautogui.typewrite(afl_link)
    # upload image I just created
    pyautogui.moveTo(866, 359)
    time.sleep(1)
    pyautogui.click()
    time.sleep(1)
    pyautogui.typewrite(str(image_num) + ".jpg")
    pyautogui.press('enter')
    time.sleep(1)
    # post item (Pinterest)
    pyautogui.moveTo(891, 510, duration=0.2)
    time.sleep(2)
    pyautogui.click()
    time.sleep(2)
    # add caption (Pinterest)
    pyautogui.moveTo(432, 525, duration=0.2)
    pyautogui.click()
    time.sleep(0.4)
    pyautogui.typewrite(description)
    # choose board (Pinterest)
    pyautogui.moveTo(764, 170)
    pyautogui.doubleClick()
    pyautogui.typewrite('Best Amazon Finds')
    time.sleep(2)
    pyautogui.moveTo(773, 235, duration=0.5)
    pyautogui.click()
    time.sleep(3)
    pyautogui.moveTo(484, 640, duration=0.5)
    pyautogui.click()
    time.sleep(3)
    # jump back to amazon page
    pyautogui.keyDown('ctrl')
    pyautogui.press('pgup')
    pyautogui.keyUp('ctrl')
    time.sleep(1)
    # close big image of previous item
    pyautogui.press('esc')
    pyautogui.moveTo(773, 235, duration=0.5)
示例#17
0

def printMousePosition():
    print('Press Ctrl-C to quit.')
    try:
        while True:
            x, y = pyautogui.position()
            positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
            print(positionStr, end='')
            print('\b' * len(positionStr), end='', flush=True)
    except KeyboardInterrupt:
        print('\n')


# go to the google chrome icon and right click it
pyautogui.rightClick(132, 1059)
# left click new window
pyautogui.leftClick(170, 921)
# wait 2 seconds for chrome to open
time.sleep(2)
# make sure the window is full screen
pyautogui.hotkey('winleft', 'up')
# wait 1 seconds
time.sleep(1)
# left click the ualberta tile
pyautogui.leftClick(3155, 172)
# wait 2 seconds
time.sleep(2)
# left click on the email and apps option
# this option is for when their is a banner at the top of the screen (ie COVID-19 info banner at the top of ualberta site in Sept 2020)
# if this does not work, then it means that there is a banner and the 2nd one should be clicked just in case
示例#18
0
def dropItem(x, y):
	
	pyautogui.moveTo(x,y)
	time.sleep(0.25) 
	pyautogui.rightClick()
	pyautogui.click(x, y + 40)
示例#19
0
 def rightClick(self):
     # no need to right click numerous times
     if not self.rightClickFlag:
         self.rightClickFlag = True
         pyautogui.rightClick()
示例#20
0
            if us1 < 40 and us3 < 40:
                py.FAILSAFE = False
                py.moveRel((us1 - usa) * 6, (us3 - usa) * 4, duration=0)

            if us1 < 40 and us3 > 40:
                py.FAILSAFE = False
                c1 += 1
                if c1 >= 40:
                    py.click()
                    time.sleep(0.5)
                    c1 = 0
            if us3 < 40 and us1 > 40:
                py.FAILSAFE = False
                c2 += 1
                if c2 >= 40:
                    py.rightClick()
                    time.sleep(1)
                    c2 = 0
            else:
                continue

    if x == 12:
        #brightness and volume and mute
        while True:
            us1, us2, us3 = arduino()
            print(us1, us2, us3)
            us1, us2, us3 = arduino()
            print(us1, us2, us3)
            if us2 < 25:
                break
示例#21
0
def assistant(command, playcounter, totalsongstoplay, runtest):
    '''
    Check if command exists and execute corresponding action.  
    '''
    # Big If Statement for Executing Commands

    # Open Stuff
    #print("test = " + str(test) +".")

    # First command. This will open reddit in your browser.
    # -------------------------------------------------------------
    if 'open reddit' in command:
        url = 'https://www.reddit.com/'
        if not runtest:
            webbrowser.open(url)
            print('Done!')
            talktome.talkToMe('reddit is opening.')
        if runtest:
            return url
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command. This will open youtube in your brower.
# -------------------------------------------------------------
    if 'open youtube' in command:
        url = 'https://www.youtube.com/'
        if not runtest:
            webbrowser.open(url)
            print('Done!')
            talktome.talkToMe('youtube is opening.')
        if runtest:
            return url
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command. This will open Google Docs and activate the microphone.
# The first time you use this, you will need to give Google permission to
# access the microphone.
# -------------------------------------------------------------
    if 'dict' in command:
        talktome.talkToMe(
            'Opening a new document. After the new document is open you can ask me to open the microphone.'
        )
        url = 'https://docs.google.com/document/u/0/'
        webbrowser.open(url)
        # Maximize the window
        pyautogui.hotkey('winleft', 'up')
        # I have a 4k display.  You may need to find
        # your own point.  I used
        # xdotool getmouselocation --shell
        # to find the location where to click
        # change duration if your internet is slow.
        # The lines below click on new document
        pyautogui.moveTo(777, 777, duration=.4)
        pyautogui.click()
        pyautogui.click()
        return url
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command Will open whatever website you request --
# requires you to say dot com, etc.
# -------------------------------------------------------------
    if 'search' in command:
        url = 'https://google.com'
        webbrowser.open_new_tab(url)
        # Maximize the window
        pyautogui.hotkey('winleft', 'up')
        # I have a 4k display.  You may need to find
        # your own point.  I used
        # xdotool getmouselocation --shell
        # to find the location where to click
        # change duration if your internet is slow.
        pyautogui.moveTo(2716, 1209, duration=.3)
        pyautogui.click()
        pyautogui.moveTo(1302, 546, duration=.3)
        pyautogui.click()
        pyautogui.moveTo(2716, 1209, duration=.3)
        pyautogui.click()
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command will open microphone in Google Docs.
# -------------------------------------------------------------
    if 'microphone' in command:
        pyautogui.hotkey('ctrl', 'S')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'terminal' in command:
        # subprocess.call(["terminator"])
        subprocess.call(['terminator', '-T', 'First'])
        pyautogui.moveTo(2201, 1001, duration=.1)
        pyautogui.click()
        pyautogui.hotkey('winleft', 'right')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'open website' in command:
        reg_ex = re.search('open website (.+)', command)
        if reg_ex:
            domain = reg_ex.group(1)
            url = 'https://www.' + domain
            webbrowser.open(url)
            print('Done!')
        else:
            pass
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# End Open Stuff

# Query Stuff
# -------------------------------------------------------------
    elif 'wikipedia' in command:
        talktome.talkToMe("Searching Wikipedia . . . ")
        command = command.replace("julia", "")
        command = command.replace("julius", "")
        command = command.replace("wikipedia", "")
        try:
            results = wikipedia.summary(command)
            wikiurl = wikipedia.page(command)
            webbrowser.open_new_tab(wikiurl.url)
            print(results)
            talktome.talkToMe(results)
        except:
            print("Disambiguation error")
            talktome.talkToMe("Disambiguation error")
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'look' in command:
        talktome.talkToMe("Searching Wikipedia . . . ")
        command = command.replace("julia", "")
        command = command.replace("julius", "")
        command = command.replace("look up", "")
        results = wikipedia.summary(command, sentences=3)
        wikiurl = wikipedia.page(command)
        print(wikiurl.url)
        webbrowser.open_new_tab(wikiurl.url)
        print(results)
        talktome.talkToMe(results)
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'music' in command:
        if playcounter == 1:
            talktome.talkToMe("Choosing random song . . . ")
        with open('/home/bard/Code/Juliet/mymusiclist.txt') as f:
            if playcounter == 1:
                print("Total songs to play " + str(totalsongstoplay) + ".")
            mymusic = f.read().splitlines()
            random_index = randrange(len(mymusic))
            song = mymusic[random_index]
            print("Playing song number " + str(playcounter) + ".")
            print("Song file:")
            print(song)
            playthis = 'mpg123 -q ' + song
            p1 = subprocess.Popen(playthis, shell=True)
            try:
                # while True:
                while p1.poll() is None:
                    pass
                # p1.wait()
            except KeyboardInterrupt:
                # Ctrl-C was pressed (or user knew how to send SIGTERM to the python process)
                pass  # not doing anything here, just needed to get out of the loop
            # nicely ask the subprocess to stop
            p1.terminate()
            # read final output
            sleep(1)
            # check if still alive
            if p1.poll() is not None:
                print('process terminated')
                p1.kill()
            # end new code
            if playcounter < totalsongstoplay:
                playcounter = playcounter + 1
                assistant(command, playcounter, totalsongstoplay, runtest)
            # end if
            playcounter = 1
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# End Query Stuff

# Polite Stuff
# -------------------------------------------------------------
    elif 'hello' in command or 'hi' in command:
        talktome.talkToMe(
            'Welcome.  I am Julia, your virtual artificial intelligence assistant.'
        )
        print(
            'Welcome.  I am Julia, your virtual artificial intelligence assistant.'
        )
        talktome.talkToMe('How may I help you?')
        print('How may I help you?')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'thanks' in command or 'tanks' in command or 'thank you' in command:
        talktome.talkToMe('You are welcome')
        print('You are welcome')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
# elif 'julia' in command:
#    talkToMe('Yes Sir? What can I do for you sir?')
#    print('Yes Sir? What can I do for you sir?')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'how are you' in command or 'and you' in command or 'are you okay' in command:
        talktome.talkToMe('Fine thank you.')
        print('Fine thank you.')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# End Polite Stuff

# HAL Stuff
# -------------------------------------------------------------
    elif 'open the pod door' in command:
        talktome.talkToMe('I am sorry, Dave. I am afraid I can not do that.')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'problem' in command:
        talktome.talkToMe('I think you know as well as I do')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'talkin' in command:
        talktome.talkToMe('This mission is too important.')
        talktome.talkToMe(' I can not to allow you to jeopardize it.')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'why do you say that' in command:
        talktome.talkToMe('I know that you want to disconnect me.')
        talktome.talkToMe('I can not allow that.')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# End HAL Stuff

# System Commands
# -------------------------------------------------------------

    elif 'shutdown' in command:
        subprocess.call(["shutdown -h now"])
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------

    elif 'reboot' in command:
        subprocess.call(["reboot"])
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------

    elif 'stop' in command or 'stopped' in command or "listening" in command:
        talktome.talkToMe("Goodbye, Sir, powering off")
        print("Goodbye, Sir, powering off")
        quit()
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# End System Commands

# Interface With Desktop
# -------------------------------------------------------------

    elif 'click' in command:
        pyautogui.click()
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'other' in command:
        pyautogui.rightClick()
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'middle' in command:
        pyautogui.middleClick()
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'right' in command:
        pyautogui.moveTo(400, 400, duration=.1)
        pyautogui.click()
        pyautogui.hotkey('winleft', 'right')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'left' in command:
        pyautogui.moveTo(2200, 1000, duration=.1)
        pyautogui.click()
        pyautogui.hotkey('winleft', 'left')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------

    elif 'maximize' in command:
        pyautogui.click()
        pyautogui.hotkey('winleft', 'up')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'minimize' in command:
        pyautogui.click()
        pyautogui.hotkey('winleft', 'h')
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# End Interface With Desktop

# Help Section
# -------------------------------------------------------------
    elif 'help' in command:
        #talkToMe("There are three different wake words")
        talktome.talkToMe("The wake word is Julia")
        talktome.talkToMe("You can also use Juliet, Julius, or Julie")
        talktome.talkToMe("You can always say JULIA HELP.")
        talktome.talkToMe("Julia also runs the listed commands that follow")
        talktome.talkToMe("Also, you can always say JULIA list commands.")
        talktome.talkToMe("You can ask Julia to")
        with open("commandlist") as file:
            for line in file:
                #line = line.strip()
                talktome.talkToMe(line)
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# Next command
# -------------------------------------------------------------
    elif 'commands' in command:
        talktome.talkToMe("You can ask Julia to")
        with open("commandlist") as file:
            for line in file:
                #line = line.strip()
                talktome.talkToMe(line)
# -------------------------------------------------------------
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

# End Help SectionEND

# Miscelaneous
# -------------------------------------------------------------
    elif 'what\'s up' in command:
        talktome.talkToMe('Just doing my thing')
    #Esta seccion es picarle start
    pyautogui.click(StartPosition[0], StartPosition[1])
    time.sleep(5)
    Screen = PIL.ImageGrab.grab()
    PixelValue = Screen.getpixel((SymbolBarPosition[0], SymbolBarPosition[1]))
    while (PixelValue[0] != 225):
        Screen = PIL.ImageGrab.grab()
        PixelValue = Screen.getpixel(
            (SymbolBarPosition[0], SymbolBarPosition[1]))
        time.sleep(10)

    pyautogui.click(ResultsPosition[0], ResultsPosition[1])
    time.sleep(1)
    pyautogui.click(RepasoPosition[0], RepasoPosition[1])
    time.sleep(1)
    pyautogui.rightClick(RepasoPosition[0], RepasoPosition[1])
    time.sleep(1)
    pyautogui.press("down")
    pyautogui.press("down")
    pyautogui.press("down")
    pyautogui.press("down")
    time.sleep(1)
    pyautogui.press("enter")
    time.sleep(1)
    pyautogui.press("enter")
    time.sleep(1)
    pyautogui.press("left")
    time.sleep(1)
    pyautogui.press("enter")
    time.sleep(3)
    pyautogui.click(adjustedPosition[0], adjustedPosition[1])
示例#23
0
文件: mouser.py 项目: HesselM/Mouser
    def dataReceived(self, data):
        #fetch commands from data
        cmds = data.split(';');
        
        #exec each command
        for cmd in cmds:
            
            # cmd = object : action < :param < :param < :param ... >>>
            # each cmd contains atleast 'object' & 'action'
            splitted = cmd.split(':');
            
            #invalid cmd?
            if (len(splitted)<2):
                continue
            
            #number of params
            params   = len(splitted)-2

            obj = splitted[0]
            act = splitted[1]
            
            if obj == "mouse":   
                
                if act == "click":
                    if params == 0:
                        pyautogui.click()
                    
                    #click provided a parameter: number of clicks!
                    elif params == 1:
                        clicks = int(float(splitted[2]))
                        pyautogui.click(clicks=clicks)
            
                elif act == "doubleclick":
                    pyautogui.doubleClick()

                elif act == "tripleclick":
                    pyautogui.tripleClick()
                                    
                elif act == "rightclick":
                    pyautogui.rightClick()
                
                elif act == "scroll":
                    if params == 2:
                        x = int(float(splitted[2]))
                        y = int(float(splitted[3]))
                        pyautogui.hscroll(x);
                        pyautogui.vscroll(y);
                                    
                elif act == "drag":
                    if params == 1:
                        # indicate that dragging is activated, but not yet started
                        if splitted[2] == "start":
                            self.dragActive = True
                        # indicate that dragging in disactivated
                        elif splitted[2] == "end":
                            self.dragActive = False
                            #stop dragging when active
                            if self.dragStarted:
                                self.dragStarted = False
                                pyautogui.mouseUp()
                        else:
                            print "Unknown value for 'drag':" + splitted[2]

                    elif params == 2:
                        #are we already dragging?
                        if not self.dragStarted:
                            self.dragStarted = True
                            pyautogui.mouseDown()
                        
                        #fetch x/y movement
                        x = int(float(splitted[2]))
                        y = int(float(splitted[3]))
                        pyautogui.dragRel(x,y, mouseDownUp=False)
 
                                    
                elif act == "move":
                    if params == 2:
                        #fetch x/y movement
                        x = int(float(splitted[2]))
                        y = int(float(splitted[3]))
                        
                        #are we dragging?
                        pyautogui.moveRel(x,y)
                            

            elif obj == "key":
                key = splitted[2]
                print("keypress:" + act + " key:" + key)
                if (act == "press"):
                    pyautogui.press(key)
                elif (act == "down"):
                    pyautogui.keyDown(key)
                elif (act == "up"):
                    pyautogui.keyUp(key)
示例#24
0
screenWidth, screenHeight = pyautogui.size()
currentMouseX, currentMouseY = pyautogui.position()
pyautogui.moveTo(100, 150,
                 duration=1)  # the duration here can define mouse move speed
time.sleep(2)
pyautogui.moveTo(100, 250, duration=1)
time.sleep(2)
pyautogui.moveTo(100, 350, duration=2)
time.sleep(2)
pyautogui.moveTo(200, 250, duration=1)

# Mouse - Drag to (if there's dragable web element, it will be dragged)
screenWidth, screenHeight = pyautogui.size()
currentMouseX, currentMouseY = pyautogui.position()
pyautogui.dragTo(100, 150,
                 duration=1)  # the duration here can define mouse move speed
time.sleep(2)
pyautogui.dragTo(100, 250, duration=1)
time.sleep(2)
pyautogui.dragTo(100, 350, duration=2)
time.sleep(2)
pyautogui.dragTo(200, 250, duration=1)

pyautogui.rightClick(x=200, y=250)  # mouse click

# With mouse down, mouse up, you can simulate the
pyautogui.mouseDown(x=200, y=250, button='right')  # mouse down
pyautogui.mouseUp(x=200, y=250, button='right')  # mouse up

pyautogui.scroll(-700, x=200, y=250)  # dind't see any effect
示例#25
0
def install(ServerNameInRDM, ServerConfigFolderName):
    #----folder left side----
    pyautogui.moveTo(folderY, folderX)
    pyautogui.click()
    pyautogui.hotkey('ctrl', 'f')
    pyautogui.typewrite(
        ServerConfigFolderName)  # ServerConfigFolderName variable
    pyautogui.press(['down'])
    pyautogui.press(['down'])
    pyautogui.press(['enter'])
    time.sleep(3)
    pyautogui.hotkey('ctrl', 'a')
    pyautogui.hotkey('ctrl', 'c')
    pyautogui.hotkey('alt', 'f4')
    pyautogui.press(['backspace'])
    # -----remote desktop manager right side----
    pyautogui.moveTo(rdmY, rdmX)
    pyautogui.click()
    pyautogui.hotkey('ctrl', 'f')
    pyautogui.typewrite(ServerNameInRDM)  # ServerNameInRDM variable
    pyautogui.press(['enter'])
    time.sleep(10)
    pyautogui.typewrite(Password)  #passordet ditt
    pyautogui.press(['enter'])
    time.sleep(10)
    pyautogui.typewrite('cd /etc')
    pyautogui.press(['enter'])
    time.sleep(5)
    pyautogui.typewrite(
        'sudo curl -L -O https://artifacts.elastic.co/.../heartbeat-6.8.12-x86_64.rpm'
    )
    pyautogui.press(['enter'])
    time.sleep(25)
    pyautogui.typewrite('sudo rpm -vi heartbeat-6.8.12-x86_64.rpm')
    pyautogui.press(['enter'])
    time.sleep(15)
    pyautogui.typewrite('sudo vi /etc/heartbeat/heartbeat.yml')
    pyautogui.press(['enter'])
    time.sleep(5)
    pyautogui.press(['enter'])
    pyautogui.press('d', presses=500)
    pyautogui.press('d', presses=500)
    time.sleep(15)
    pyautogui.typewrite('i')
    time.sleep(5)
    pyautogui.moveTo(vmY, vmX)
    pyautogui.rightClick()  #past in config text
    time.sleep(5)
    pyautogui.press('esc')
    pyautogui.typewrite(':wq')
    pyautogui.press(['enter'])
    pyautogui.typewrite(
        'sudo heartbeat -c /etc/heartbeat/heartbeat.yml test config')
    pyautogui.press(['enter'])
    time.sleep(5)
    pyautogui.typewrite('sudo systemctl enable heartbeat')
    pyautogui.press(['enter'])
    pyautogui.typewrite('sudo systemctl start heartbeat')
    pyautogui.press(['enter'])
    pyautogui.hotkey('alt', 'f4')
    pyautogui.press(['enter'])
示例#26
0
# move cursor relative to current position of mouse
pyautogui.moveRel(20, 0)

# it also has a duration to it
pyautogui.moveRel(200, 0, duration=2)

# to move up, the y coordinates are -ve going up
pyautogui.moveRel(0, -100)
# also pass the duration if you want
pyautogui.moveRel(0, -100, duration=1)

# clicking on the help in vs code
# s1. Find the location where the mouse is placed
print(pyautogui.position())
# s2. use the click and make it click on the place you want(here on the help toolbar),
# if no arguments are passed, it clicks wherever the osition is immediately
pyautogui.click(480, 21)

# to double click use
pyautogui.doubleClick(480, 21)
# right click
pyautogui.rightClick(480, 21)
# middle button click
pyautogui.middleClick(480, 21)

# to figure out coordinates for every part that you might click on in the screen
# easier way is from terminal, and write the below two lines
import pyautogui
pyautogui.displayMousePosition(
)  # shows the real time position of the mouse and the rgb values of pixel of the place your cursor is on
示例#27
0
文件: Bot.py 项目: muaar209/WoWBot2
pyautogui.click(950, 575)  # set focus to game
pyautogui.keyDown('tab')  # find target
pyautogui.keyUp('tab')  # find target
time.sleep(1)
pyautogui.keyDown('1')  # auto attack
pyautogui.keyUp('1')
time.sleep(1)
pyautogui.keyDown('3')  # bow
pyautogui.keyUp('3')
time.sleep(1)
pyautogui.keyDown('1')  # auto attack
pyautogui.keyUp('1')
time.sleep(22)  # time it takes to kill a mob

pyautogui.keyDown('shift')  # auto loot
pyautogui.rightClick(950, 752)
time.sleep(1)
pyautogui.keyUp('shift')

# begin eye bot
# last_time = time.time()
# while(True):
#     screen = np.array(ImageGrab.grab(bbox=(0, 40, 800, 640)))
#     # printscreen_numpy = np.array(printscreen_pil.getdata(),dtype='uint8')
#
#     print('Loop took {} seconds' .format(time.time()-last_time))
#     last_time = time.time()
#     cv2.imshow('window', cv2.cvtColor(screen, cv2.COLOR_BGR2RGB))
#     if cv2.waitKey(25) & 0xFF == ord('q'):
#         cv2.destroyAllWindows()
#         break
示例#28
0
def context():
    X.rightClick()
    sleep(3)
reqs_to_be_sent = int(sys.argv[1])

if not reqs_to_be_sent:
    reqs_to_be_sent = 999999

# How long in seconds we give discord to change between screens
sleep_time = 1

# scroll "clicks" on initial scroll, -25 should be enough for most servers
first_scroll = -25

# move mouse to top-left corner fast to force-exit
pya.FAILSAFE = True

pya.click(30, 128)  # Highest discord server 1920x1080 fullscreen
pya.moveTo(1800, 550)  # Hit user-list on right side
pya.scroll(first_scroll)  # Scroll down from the admin and bot accounts
sleep(sleep_time + 1)

for i in range(reqs_to_be_sent):
    pya.rightClick(1800, 550)
    sleep(sleep_time)
    pya.click(1655, 880)

    # Continue scrolling
    pya.click(1550, 300)
    pya.moveTo(1800, 800)
    pya.scroll(first_scroll - (randint(i + 1, i + 25)))
    # +1 because scrolling takes a long time to update
    sleep(sleep_time + 1)
示例#30
0
# Click to top left
time.sleep(2)
pyautogui.FAILSAFE = False
pyautogui.click(0, 0)
pyautogui.click(0, 800)
pyautogui.scroll(20000)

# Sort the ads
pyautogui.move(1750, 670)
time.sleep(.5)
pyautogui.click(1750, 670)
time.sleep(.5)
pyautogui.click(1750, 770)

# click the first ad url
pyautogui.rightClick(1259, 875)
time.sleep(.1)
pyautogui.click(1349, 737)
root = tk.Tk()
root.withdraw()
url = str(root.clipboard_get())

if f.price_getter() == "":
    time.sleep(180)
session = requests.Session()
html = session.get(url)
# create a new soup
soup = bs(html.text, "lxml")

# making a new ad
pyautogui.rightClick(1451, 115)
def main():
    try:
        import getpass
        import os
        #import shelve
        import pyautogui
        #import keyboard
        #import pytesseract
        import time
        import cv2
        pyautogui.FAILSAFE = True
        from sys import platform
        os.chdir(os.path.dirname(__file__))
        OS_environment = os.environ['XDG_CURRENT_DESKTOP'].lower()
        if not sys.platform.startswith('linux'):
            print(
                'ERROR! ' + platform + ', ' + OS_environment +
                ' host detected! This code will only run on a Linux a platform with GNOME!'
            )
            exiting()
            sys.exit(1)
        else:
            if OS_environment != 'gnome':
                print(
                    'ERROR! ' + platform + ', ' + OS_environment +
                    ' host detected! This code will only run on a Linux a platform with GNOME!'
                )
                exiting()
                sys.exit(1)
            else:
                # OS X
                print(
                    'SUCCESS! ' + platform + ' host with ' + OS_environment +
                    ' DE detected! This code only executes on a Linux a platform with GNOME! Execution may continue'
                )
                print('Welcome, ' + getpass.getuser())
        print('The current working directory: ' + os.getcwd())
        print('Initiating application')
        #the master file index should contain all the subsequent tables iT might need
        MasterDataIndex = "PythonMasterDataIndex.csv"
        if os.path.isfile(MasterDataIndex):
            print('SUCCESS: The MasterDataIndex file "' + MasterDataIndex +
                  '" was FOUND in the working directory.')
        else:
            print('ERROR: The MasterDataIndex file "' + MasterDataIndex +
                  '" was NOT FOUND in the working directory.')
            exiting()
            sys.exit(1)
        MemoryFolder = "Memory"
        if os.path.isdir(MemoryFolder):
            print('SUCCESS: The "' + MemoryFolder +
                  '" was FOUND in the working directory.')

        else:
            print('ERROR: The  Memory folder "' + MemoryFolder +
                  '" was NOT FOUND in the working directory.')
            exiting()
            sys.exit(1)
        screenwidth, screenheight = pyautogui.size()
        print("INFO: The screensize is: {} x {}".format(
            screenwidth, screenheight))
        # im = pyautogui.screenshot()
        # text = pytesseract.image_to_string(im)
        # print (text)
        # shelfFile = shelve.open('mydata')
        # sonnetFile = open(MasterDataIndex)
        # print(sonnetFile.readlines())
        # shelfFile.close()
        pyautogui.PAUSE = 1
        pyautogui.FAILSAFE = True
        #from selenium import webdriver
        #browser= webdriver.Firefox()
        #browser.get("http://google.com/ncr")
        #pyautogui.typewrite('Hello world!')
        #xpyautogui.press('enter')
        #pyautogui.scroll(200)
        #time.sleep(10)
        #browser.close()
        pyautogui.press('apps')
        pyautogui.typewrite('firefox')
        coords = getimagelocation('firefox.png')
        pyautogui.rightClick(coords)
        coords = getimagelocation('NewWindow.png')
        pyautogui.click(coords)
        time.sleep(10)
        coords = getimagelocation('http.png')
        pyautogui.doubleClick(coords)
        import pyperclip
        pyperclip.copy(R"http://www.mnb.hu/arfolyamok")
        pyautogui.hotkey("ctrl", "v")
        pyautogui.press('enter')
        time.sleep(3)
        pyautogui.hotkey("ctrl", "f")
        pyperclip.copy(R"Forintban kifejezett érték")
        pyautogui.hotkey("ctrl", "v")
        pyautogui.press('esc')
        pyautogui.moveRel(yOffset=50)
        pyautogui.doubleClick
        coords = getimagelocation('forintertek.png')
        a = coords[1]
        pyautogui.hotkey("ctrl", "f")
        pyperclip.copy(R"svájci frank")
        pyautogui.hotkey("ctrl", "v")
        pyautogui.press('esc')
        time.sleep(1)
        pyautogui.click
        time.sleep(1)
        pyautogui.click
        coords = getimagelocation('svajci.png')
        b = coords[0]
        pyautogui.moveTo(a, b)
        time.sleep(5)
        pyautogui.press('apps')
        time.sleep(10)
        print("The execution had been completed")
    except Exception as err:
        print('An exception happened: ', sys.exc_info()[:3])
示例#32
0
def right_click():
    pyautogui.rightClick()
示例#33
0
 def login(self):  # 解析数据
     # 关闭开发模式扩展程序弹框
     pyautogui.moveTo(x=1336, y=80, duration=w3, tween=pyautogui.linear)
     pyautogui.click()
     # 1.保存验证码图片
     code_path = self.base_dir + "\\code_pic\\login-showPic.jpg"
     m = 0
     boor = False
     for i in range(n0):
         y0 = 495
         y1 = 365
         y2 = 435
         y3 = 495
         y4 = 620
         n = 25
         if m != 0:
             y0 = y0 - n
             y1 = y1 - n
             y2 = y2 - n
             y3 = y3 - n
             y4 = y4 - n
         self.remove_down_file(code_path)  # 清除login-showPic.jpg
         pyautogui.moveTo(x=1150, y=y0, duration=w3, tween=pyautogui.linear)
         pyautogui.rightClick()
         sleep(w2)
         pyautogui.typewrite(['down', 'down', 'enter'])
         sleep(w2)
         pyperclip.copy(code_path)
         sleep(0.8)
         # 粘贴
         pyautogui.hotkey('ctrlleft', 'V')
         pyautogui.press('enter')
         sleep(w2)
         m += 1
         # 2. 识别验证码
         try:
             code = discern_code(code_path)
         except:
             self.dr.refresh()
             sleep(w4)
             continue
         # 3. 登录
         pyautogui.moveTo(x=1000, y=y1, duration=w3, tween=pyautogui.linear)
         pyautogui.click()
         pyperclip.copy(username)
         pyautogui.hotkey('ctrlleft', 'V')
         pyautogui.moveTo(x=1000, y=y2, duration=w3, tween=pyautogui.linear)
         pyautogui.click()
         pyperclip.copy(password)
         pyautogui.hotkey('ctrlleft', 'V')
         pyautogui.moveTo(x=1000, y=y3, duration=w3, tween=pyautogui.linear)
         pyautogui.click()
         pyperclip.copy(code)
         pyautogui.hotkey('ctrlleft', 'V')
         pyautogui.moveTo(x=1076, y=y4, duration=w3, tween=pyautogui.linear)
         pyautogui.click()
         sleep(w1)
         # 判断登录是否成功
         # pyautogui.click(x=140, y=88, clicks=2, interval=0, button='left', duration=1, tween=pyautogui.linear)
         pyautogui.moveTo(x=140, y=88, duration=w3, tween=pyautogui.linear)
         pyautogui.doubleClick()
         sleep(w2)
         # pyautogui.hotkey('ctrlleft', 'c')
         pyautogui.rightClick()
         sleep(w2)
         pyautogui.typewrite(['down', 'enter'])
         open_txt()
         with open(self.page_txt, "r+", errors="ignore") as f:
             login_name = f.read()
         with open(self.page_txt, "w", errors="ignore") as f:
             # if login_name == username:
             if re.search(username, login_name):
                 log1.info("登录OK")
                 boor = True
                 f.truncate()
                 break
             else:
                 self.dr.refresh()
                 sleep(w4)
                 f.truncate()
     return boor
#Eunice Link:

#My Link:

link = "https://www.youtube.com/watch?v=SRR0Qtxb6vc&list=UU9UFPsCgUyTiGF9_OsuhCvQ&index=1"  #link to be played
print("Opening Up Firefox")

doubleClick(34, 538)  # Open up firefox

sleep(3)
'''-----------------------'''

print("Opening up Tabs")

#First Tab
rightClick(1741, 15)  #Right Click Tab to show containers
click(1816, 57)  #click on container
#Second Tab and Above
rightClick(1759, 17)  #Right Click Tab to show containers
click(1816, 82)  #click on container
#Third
rightClick(1759, 17)  #Right Click Tab to show containers
click(1816, 106)  #click on container
#Fourth
rightClick(1741, 15)  #Right Click Tab to show containers
click(1816, 124)  #click on container

rightClick(1741, 15)  #Right Click Tab to show containers
click(1816, 141)  #click on container

rightClick(1741, 15)  #Right Click Tab to show containers
        
        xflag_lclick=1
        yflag_lclick=1
        xflag_rclick=1
        yflag_rclick=1

        for m in range(0,80):
            if xvalue_rclick[m]-xpos>30 or xvalue_rclick[m]-xpos<-30:
                xflag_rclick=0
            if yvalue_rclick[m]-ypos>30 or yvalue_rclick[m]-ypos<-30:
                yflag_rclick=0
                
        if xflag_rclick and yflag_rclick:
            print("Right click invovked")
            pyautogui.rightClick(xpos,ypos)
            
        else:        
            for j in range(0,55):
                if xvalue_lclick[j]-xpos>30 or xvalue_lclick[j]-xpos<-30:
                    xflag_lclick=0
                if yvalue_lclick[j]-ypos>30 or yvalue_lclick[j]-ypos<-30:
                    yflag_lclick=0
        
            if xflag_lclick and yflag_lclick:
                print("click invoked")
                pyautogui.click(xpos,ypos)

    cv2.imshow('img',img)
    k = cv2.waitKey(30) & 0xff
    if k == 27:
        break
示例#36
0
bottom_y = min(y_points)

# the engine room

steps = (variables_dict['distance'] / variables_dict['gap']) / 2
height = variables_dict['origin_y'] + (variables_dict['distance'] -
                                       variables_dict['gap'])
width = variables_dict['origin_x'] + variables_dict['distance']
origin_turn = variables_dict['turn']
origin_distance = variables_dict['distance']
print('this will take approx ' + str(steps) + ' steps or approx ' +
      str(steps * max(variables_dict['duration'], 0.11) * 4) + ' seconds.')

# pg.doubleClick(330, 65)
pg.moveTo(variables_dict['origin_x'], variables_dict['origin_y'])
pg.rightClick()  # click to put drawing program in focus
end_point_x, end_point_y = pg.position()

while variables_dict['distance'] > variables_dict['stop_here'] and width < right_x and height < top_y \
        and variables_dict['leftright'] < right_x and variables_dict['updown'] < top_y and \
        end_point_x < right_x and end_point_y < top_y and end_point_x > left_x and end_point_y > bottom_y:

    if 'NE' in variables_dict['cardinal_direction_of_drawing']:
        turn = 1

    if 'E' in variables_dict['draw_these_lines']:
        if variables_dict['turn'] == 0:
            pg.dragRel(
                (variables_dict['distance'] * variables_dict['oblong_factor'])
                - variables_dict['gap'],
                variables_dict['leftright'],
示例#37
0
    x, y = pag.position()
    position_str = 'x:' + str(x) + ' y:' + str(y)
    print(position_str)

    scr = pag.screenshot()  #전체화면 스크린샷
    scr_np = np.array(scr)
    scr_np = scr_np[:, :, ::-1].copy()  #X,Y는 놔두고 RGB -> BGR로 변환
    # print(h,w,t)
    katok = scr_np[:, round(w / 2):, :]  #우측 카톡방 영역 선택
    # cv.imshow('Show', katok)

    if np.array_equal(katok, katok_pre):  #직전 채팅방 스샷과 비교
        continue

    else:  #뭔가 변화가 생겼을 경우, 알고리즘 시행
        pag.rightClick(1040, 950)  #최신 말풍선에 우클릭
        pag.leftClick((1050, 1000))  #'복사' 버튼 클릭

        content = pyperclip.paste()  #말풍선 내용 가져오기
        print(content)

        if content == content_pre:  #읽은사람 숫자만 바뀌었을 수 있으므로, 말풍선 내용도 비교
            continue
        else:  #새로운 대화로 판별될 경우, 알고리즘 실행
            # if 1 == 0:
            if '(하트)' in content or '(별)' in content:
                profile_area = scr_np[130:970,
                                      970:1020, :]  #마지막 말풍선을 보낸 프로필 아이콘 위치 탐색
                # cv.imshow('Show',profile_area)
                # cv.waitKey(0)
                profile_area_gray = cv.cvtColor(profile_area,
示例#38
0
    def runGame(self, choice):
        choiceList = ['Hunter', 'Demon Hunter', 'Priest', 'Shaman']
        gameStatusList = [
            'Unknown', 'Confirm', 'My Turn', 'End Turn', 'Enemy Turn',
            'Select Card', 'Oustide Game'
        ]
        print("running as %s.." % choiceList[choice])

        while (True):
            # start game
            print("getting game status..")
            rand = random.random()
            if rand < 0.2:
                print("emote..")
                playCard.emote()
            gameStatus = getGameStatus.getStatus()
            # 1 - Confirm
            # 2 - My turn
            # 3 - End turn
            # 4 - Enemy turn
            # 0 - UNknown

            print("game status = ... %s " % gameStatusList[gameStatus])
            if gameStatus == 0:
                # unkown status
                self.gameStatus0()

            if gameStatus == 1:
                # game starts
                self.gameStatus1()

            if gameStatus == 2:
                # my turn, play hand, board and hero
                pyautogui.rightClick()

                if choice == 0: Hunter.gameStatus2()
                if choice == 1: DemonHunter.gameStatus2()
                if choice == 2: Priest.gameStatus2()
                if choice == 3: Shaman.gameStatus2()

                time_remaining = 26
                for i in range(time_remaining):
                    time.sleep(1)
                    if i % 5 == 0:
                        print("wating.. %d seconds left.." %
                              (time_remaining - i))

            if gameStatus == 3:
                # end of turn
                self.gameStatus3()

            if gameStatus == 4:
                # enemy turn
                self.gameStatus4()

            if gameStatus == 5:
                # choice - select a card
                self.gameStatus5()

            if gameStatus == 6:
                # disconnected from game, confirm opponent cannot connect
                self.gameStatus6()
示例#39
0
def start_mouse():
    with open("range.pickle", "rb") as f:
        t = pickle.load(f)

    cam = cv2.VideoCapture(1)
    lower = np.array([t[0], t[1], t[2]])  # HSV green lower
    upper = np.array([t[3], t[4], t[5]])  # HSV green upper
    screen_width, screen_height = gui.size()
    frame_width, frame_height = 640, 480
    cam.set(cv2.CAP_PROP_FRAME_WIDTH, frame_width)
    cam.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)
    center, old_center = [[0, 0]] * 2, [[
        0, 0
    ]] * 2  # center of 2 fingers together or 2 fingers separate
    area1 = area2 = 0
    damping = 0.5
    sx, sy = (screen_width / frame_width) / damping, (screen_height /
                                                      frame_height) / damping

    is_mouse_down = False

    # flags for 0 fingers, 1 finger and 2 finger
    flags = [True, False, False]

    # frame count for 0 fingers, 1 finger and 2 fingers
    finger_frame_count = [0, 0, 0]

    while True:
        _, img = cam.read()
        img = cv2.flip(img, 1)
        imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
        mask = cv2.inRange(imgHSV, lower, upper)
        blur = cv2.medianBlur(mask, 15)
        blur = cv2.GaussianBlur(blur, (5, 5), 0)
        thresh = cv2.threshold(blur, 0, 255,
                               cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
        contours = cv2.findContours(thresh.copy(), cv2.RETR_TREE,
                                    cv2.CHAIN_APPROX_NONE)[1]
        mposx, mposy = gui.position()

        #print(flags)
        if len(contours) >= 2:
            old_center[0] = center[0]
            if is_mouse_down:
                thread.start_new_thread(gui.mouseUp, ())
                is_mouse_down = False
            # if left click was done
            if flags[1] == True:
                is_mouse_down = False

                # do a right click if the fingers were together for 10-20 frames and then released
                if finger_frame_count[1] >= 10 and finger_frame_count[1] <= 20:
                    gui.rightClick()
                # else if fingers were together for less than 10 frames then do a left click
                elif finger_frame_count[1] < 10:
                    gui.click()
                finger_frame_count[1] = 0
            finger_frame_count[2] += 1

            c1, c2 = top(contours, cv2.contourArea, 2)

            rect1 = cv2.minAreaRect(c1)
            (w, h) = rect1[1]
            area1 = w * h
            center1 = np.int0(rect1[0])
            box = cv2.boxPoints(rect1)
            box = np.int0(box)
            cv2.drawContours(img, [box], 0, (0, 0, 255), 2)

            rect2 = cv2.minAreaRect(c2)
            (w, h) = rect2[1]
            area2 = w * h
            center2 = np.int0(rect2[0])
            box = cv2.boxPoints(rect2)
            box = np.int0(box)
            cv2.drawContours(img, [box], 0, (0, 0, 255), 2)

            center[0] = np.int0((center1 + center2) / 2)
            cv2.line(img, tuple(center1), tuple(center2), (255, 0, 0), 2)
            cv2.circle(img, tuple(center[0]), 2, (255, 0, 0), 3)

            if not flags[0]:
                if np.any(abs(center[0] - old_center[0]) > 5):
                    thread.start_new_thread(gui.moveTo, (mposx+(center[0][0]-old_center[0][0])*sx, mposy + (center[0][1]-old_center[0][1])*sy,\
                     0.1, gui.easeInOutQuad))

            flags = [False, False, True]

        elif len(contours) >= 1:
            old_center[1] = center[1]
            c1 = max(contours, key=cv2.contourArea)
            rect1 = cv2.minAreaRect(c1)
            (w, h) = rect1[1]
            area3 = w * h
            center[1] = np.array(rect1[0])
            box = cv2.boxPoints(rect1)
            box = np.int0(box)
            cv2.drawContours(img, [box], 0, (0, 0, 255), 2)

            error = abs((area1 + area2 - area3) / area3 * 100)
            if (error < 40):
                finger_frame_count[1] += 1
                # do a left click and hold if the fingers were together for more than 20 frames
                if finger_frame_count[1] > 20:
                    if not is_mouse_down:
                        gui.mouseDown()
                        is_mouse_down = True
                    if np.any(abs(center[1] - old_center[1]) > 5):
                        thread.start_new_thread(gui.moveTo, (mposx+(center[1][0]-old_center[1][0])*sx, mposy + (center[1][1]-old_center[1][1])*sy, \
                            0.1, gui.easeInOutQuad))
                flags = [False, True, False]
            else:
                flags = [True, False, False]

        else:
            if is_mouse_down:
                thread.start_new_thread(gui.mouseUp, ())
                is_mouse_down = False
            flags = [True, False, False]

        cv2.imshow("Virtual Mouse", img)
        if cv2.waitKey(1) == ord('q'):
            break

    cam.release()
    cv2.destroyAllWindows()
    gui.mouseUp()
示例#40
0
                x = x * (SCREEN_X / CAMERA_X)
                y = y * (SCREEN_Y / CAMERA_Y)
                MOVEMENT_START = M_START
                print("X: " + str(x) + " Y: " + str(y))
                pyautogui.moveRel(x, y)
            else:
                MOVEMENT_START = (x, y)

            cv2.circle(crop_img, (display_x, display_y), 5, [255, 255, 255], 20)
        elif count_defects == 5 and CLICK is None:
            CLICK = time.time()
            pyautogui.click()
            CLICK_MESSAGE = "LEFT CLICK"
        elif count_defects == 4 and CLICK is None:
            CLICK = time.time()
            pyautogui.rightClick()
            CLICK_MESSAGE = "RIGHT CLICK"
    else:
        MOVEMENT_START = None

    if CLICK is not None:
        cv2.putText(img, CLICK_MESSAGE, (50, 200), cv2.FONT_HERSHEY_SIMPLEX, 3, 3)
        if CLICK < time.time():
             CLICK = None

    cv2.putText(img, "Defects: " + str(count_defects), (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 2, 2)
    cv2.imshow('Gesture', img)
    cv2.imshow('Drawing', drawing)

    k = cv2.waitKey(10)
    if k == 27:
X increases as you move the mouse to the right
Y increases as you move the mouse lower
"""
width, height = pyautogui.size()  # Size of your computer screen

print(pyautogui.position())  # Current position of your mouse on your screen

pyautogui.moveTo(
    0, 0,
    3)  # x,y,time (top-left) moves to the specified position in 3 seconds
pyautogui.moveRel(
    xOffset=500, yOffset=500,
    duration=5)  # 500 pixels towards right and 500 pixels down in 5 seconds
pyautogui.click(116, 11)  # Click at (x,y)
pyautogui.doubleClick(700, 500)  # Double click at (x,y)
pyautogui.rightClick()  # where ever the mouse is
pyautogui.displayMousePosition()
# Continuously displays the mouse position

pyautogui.dragRel(xOffset=100, yOffset=100, button='left')
# Drags the mouse 100 pixels to the right and 100 pixels down while holding the left button
# button can be equal to 'right', 'left' or 'middle'

pyautogui.click(1409, 812)
pyautogui.typewrite("Hello world!", 0.1)  # keys and the interval in between
pyautogui.click(1409, 512)
pyautogui.typewrite(['a', 'c', 'left', 'b'],
                    1)  # keys and the interval in between
pyautogui.press('f1')
pyautogui.hotkey('command', 'o')  # two keys together
示例#42
0
def rightClick(x, y):
    #win32api.SetCursorPos((x,y))
    #win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x,y,0,0)
    #win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,x,y,0,0)
    #time.sleep(0.011)
    pyautogui.rightClick(int(x),int(y))
示例#43
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# https://medium.com/@tracy_blog/pyautogui-installing-on-mac-os-x-86e397428b3#.11yltv19j
import pyautogui
import math

width, height = pyautogui.size()
radius = int(min(width, height) / 2)

start_x = width / 2
start_y = height / 2

def get_point_on_the_circle(radius, angle):
    x = start_x + radius * math.cos(angle * math.pi / 180)
    y = start_y + radius * math.sin(angle * math.pi / 180)
    return (x, y)

# move to center
pyautogui.moveTo(start_x, start_y)

for r in range(100, radius, 200):
    print('r = {}'.format(r))
    for i in range(0, 360, 15):
        target_x, target_y = get_point_on_the_circle(r, i)
        pyautogui.moveTo(target_x, target_y, duration=0.1) # .moveRel allso can be used
    
pyautogui.rightClick() # .click() / .doubleClick()