Пример #1
0
def open_chrome():
    # path to chrome
    chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'

    # open chrome maximized and allow access to pywinauto
    chrome = Application(backend='uia')
    chrome.start(chrome_dir +
                 ' --force-renderer-accessibility --start-maximized')

    # sleep for random time to allow page to load and go to zoominfo.com
    time.sleep(float(decimal.Decimal(random.randrange(50, 150)) / 100))

    send_keys("zoominfo.com {ENTER 2}")

    # sleep for enough time for me to move mouse to the 'login' button to get coordinates
    time.sleep(float(decimal.Decimal(random.randrange(150, 300)) / 100))
    time.sleep(7)

    # print coordinates of mouse over the login button
    position = pyautogui.position()
    print(position)

    # move mouse to and click on the login button
    pywinauto.mouse.click(button='left', coords=(1737, 104))

    time.sleep(float(decimal.Decimal(random.randrange(150, 300)) / 100))
Пример #2
0
def run_chrome():
    # закрываем хром, если запущен, и открываем заного с нужным настройками
    pid = get_processes('chrome.exe')
    kill_processes(pid)
    chrome_dir = r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
    chrome = Application(backend='uia')
    chrome.start(
        chrome_dir +
        ' --remote-debugging-port=9222 --force-renderer-accessibility --start-maximized'
    )
    time.sleep(2)
Пример #3
0
# encoding: utf-8
from os import path
from pywinauto import Desktop, Application

chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
tab_log_in = u'Meet Google Drive - One place for all your files (Incognito)'
tab_drive = 'My Drive - Google Drive (Incognito)'

# # start google chrome
chrome = Application(backend='uia')
chrome.start(
    chrome_dir +
    ' --force-renderer-accessibility --incognito --start-maximized '
    'https://accounts.google.com/ServiceLogin?service=wise&passive=1209600&continue=https:'
    '//drive.google.com/?urp%3Dhttps://www.google.ru/_/chrome/newtab?espv%253D2%2526ie%253DUT%23&followup='
    'https://drive.google.com/?urp%3Dhttps://www.google.ru/_/chrome/newtab?espv%253D2%2526ie%253DUT'
    '&ltmpl=drive&emr=1#identifier')

# wait while a page is loading
chrome[tab_log_in].child_window(title_re='Reload.*',
                                control_type='Button').wait('visible',
                                                            timeout=10)
ch_window = chrome[tab_drive].child_window(title="Google Chrome",
                                           control_type="Custom")

# log in
chrome.window().type_keys('TestPywinauto{ENTER}')  # username
chrome[tab_log_in].child_window(title="Google Chrome", control_type="Custom").\
    child_window(title="Back", control_type="Image").wait(wait_for='visible', timeout=10)

chrome.window().type_keys('testpywinauto123{ENTER}')  # password
Пример #4
0
# Imports
import pyautogui
import time
from pywinauto import Application

# Set Google Chrome directory
chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
# recorder_dir = 

# Start Google Chrome and point to URL
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --start-maximized ' '[REDACTED-URL]')

# Sleep for five seconds waiting for connection
time.sleep(5)

# Login
pyautogui.typewrite('Guest\n', interval=0.1)

# Click mute button
# pyautogui.click(x=X_COORD, y=Y_COORD, button='left')

# Click maximize button
# pyautogui.click(x=X_COORD, y=Y_COORD, button='left')

# Start recording application
# recorder = Application()
# recorder.start(recorder_dir + ' )

# Click record full screen button
# pyautogui.click(x=X_COORD, y=Y_COORD, button='left')
timeNow = (datetime.datetime.now().time())
dateTime = (datetime.datetime.now())
timeNowSt = str(timeNow)

print(timeNow)

timeNowSt = timeNowSt.split(":")

if timeNowSt[0] == "16" and timeNowSt[1] == "20":

    notepad = "%windir%\system32\notepad.exe"

    app_1 = Application()

    app_1.start("Notepad.exe")

    app_1["Notepad"]["Edit"].set_edit_text("F*****g 420!")

    time.sleep(3)

    app_1.Notepad.MenuSelect("File -> Exit")

    app_1.Notepad.DontSave.Click()

    app.start(chrome + ' --force-renderer-accessibility --start-maximized '
              'https://www.youtube.com/watch?v=3xXwKQMo3Fc')

elif timeNowSt[0] == "04" and timeNowSt[1] == "20":

    notepad = "%windir%\system32\notepad.exe"
Пример #6
0
class RealBandController:
    """An object for controlling RealBand."""
    _TARGET_VERSION = '2018.0.2.5'

    def __init__(self, binary_path=r'C:\RealBand\RealBand.exe', try_connect=True):
        self.realband_version = _get_exe_version(binary_path)
        if self.realband_version != self._TARGET_VERSION:
            print('This code was written for RealBand {}, your version is {}. '
                  'Proceed with caution.'
                  .format(self._TARGET_VERSION, self.realband_version), file=sys.stderr)

        self._app = Application(backend='win32')
        if try_connect:
            try:
                self._app.connect(path=binary_path)
            except ProcessNotFoundError:
                try_connect = False
        if not try_connect:
            self._app.start(binary_path)
            self._app.wait_cpu_usage_lower(threshold=5)

        def get_ready():
            rb_window = self._app.window(class_name='RealBand')
            if rb_window.exists() and rb_window.is_visible() and rb_window.is_enabled():
                return

            # Reject attempts to recover from a crash
            dialog = self._app.window(class_name='#32770')
            dialog_text = dialog.StaticWrapper2.element_info.name
            if ('Okay to restore all the default settings' in dialog_text or
                'Recover data from last session' in dialog_text):
                dialog.Button2.click()

            raise TimeoutError()

        wait_until_passes(func=get_ready,
                          exceptions=(ElementNotFoundError, TimeoutError),
                          timeout=15, retry_interval=1)

        self._song_pane = self._app.RealBand.children(
            class_name='TPanelWithCanvas')[10]

    @property
    def app(self):
        return self._app

    def kill(self):
        self._app.kill()
        for proc in psutil.process_iter():
            if proc.name() in ['bbw2.exe', 'RealBand.exe']:
                print('Killing', proc, file=sys.stderr)
                try:
                    proc.kill()
                except psutil.NoSuchProcess:
                    traceback.print_exc(file=sys.stderr)

    def load_song(self, path):
        """Load a song from the given file."""
        self._menu_select('File->Open')
        self._open_file(path)
        try:
            # Get the annoying Comments window out of the way
            self._app.Comments.minimize()
        except MatchError:
            pass

    def load_style(self, path):
        """Load a style from the given file."""
        self.wait_ready()

        def open_dialog():
            # Bring up the style popup menu and choose to open a style file
            self._song_pane.click_input(coords=(44, 73), absolute=False)
            menu = self._app.window(class_name='#32768')
            menu.menu_item('File Open Style').click_input()

        wait_until_passes(func=open_dialog,
                          exceptions=ElementNotFoundError,
                          timeout=120, retry_interval=0.4)
        self._open_file(path)

    def _open_file(self, path):
        """Input a path in the file open dialog."""
        path = os.path.normpath(os.path.abspath(path))
        while True:
            dialog = self._app.window(class_name='#32770')
            dialog.wait('ready')

            # If asked whether to save changes, say no
            try:
                dialog_text = dialog.StaticWrapper2.element_info.name
                if 'Save it?' in dialog_text:
                    dialog.Button2.click()
                    continue
            except MatchError:
                pass
            break

        dialog.Edit1.set_edit_text(path)
        dialog.Edit1.send_keystrokes('{ENTER}')
        self.wait_ready(timeout=60)

    def save_song(self, path, filetype='MIDI File (.MID) (*.MID)'):
        """Save the current song under the given filename."""
        path = os.path.normpath(os.path.abspath(path))

        self._menu_select('File->Save As')
        file_dialog = self._app.window(class_name='#32770')
        file_dialog.wait('ready')
        file_dialog.ComboBox2.select(filetype)
        file_dialog.Edit1.set_edit_text(path)
        file_dialog.Edit1.send_keystrokes('{ENTER}')
        self.wait_ready()

    def generate_all(self):
        """Generate all Band-in-a-Box tracks."""
        self._menu_select('Generate->Generate All BB Tracks')
        self.wait_ready()

    def set_key(self, key, transpose=False):
        """Set the key of the song."""
        if transpose:
            raise NotImplementedError('transpose not implemented')

        self._menu_select('Edit->Key Signature')

        key_dialog = self._app.window(class_name='TKEY')
        key_dialog.wait('ready')
        key_dialog.TComboBox1.select(key)
        key_dialog.TRadioButton4.click()  # No Transpose
        key_dialog.TButton3.click()  # OK
        self.wait_ready()

    @property
    def key_signature(self):
        """The key signature of the song."""
        text = self._get_menu_item_text('Edit->Key Signature')
        return re.search(r'\[([A-G].?)\]$', text).group(1)

    @property
    def time_signature(self):
        """The time signature (meter) of the song."""
        text = self._get_menu_item_text('Edit->Meter (Time Signature)')
        return re.search(r'\[([0-9]+/[0-9]+)\]$', text).group(1)

    @property
    def tempo(self):
        """The tempo of the song."""
        text = self._get_menu_item_text('Edit->Tempo')
        return float(re.search(r'\[([0-9.,]+)\]$', text).group(1))

    def _get_menu_item_text(self, path, timeout=10, retry_interval=0.5):
        def get_text():
            return self._app.RealBand.menu_item(path).text()

        return wait_until_passes(func=get_text,
                                 exceptions=(ElementNotEnabled, RuntimeError),
                                 timeout=timeout,
                                 retry_interval=retry_interval)


    def _menu_select(self, path, timeout=10, retry_interval=0.5):
        self.wait_ready()

        def select_option():
            self._app.RealBand.menu_select(path)

        wait_until_passes(func=select_option,
                          exceptions=(ElementNotEnabled, RuntimeError),
                          timeout=timeout,
                          retry_interval=retry_interval)

    def wait_ready(self, timeout=30):
        self._app.RealBand.wait('ready', timeout=timeout)
Пример #7
0
def open(application_name):
    app  = Application()
    app.start(application_name)
Пример #8
0
    atznow = datetime.now(pytz.timezone(zone)).time()
    atznow = str(atznow)
    tz = (pytz.timezone(zone))
    tz = str(tz)
    timeNowSt = str(timeNow)
    tz = tz + ", Exactly: " + atznow
    atznow = atznow.split(":")
    timeNowSt = timeNowSt.split(":")

    if atznow[0] == "21" and atznow[1] == "58":

        fourtwenty = "420 in: " + tz

if fourtwenty != "Not 420 n***a":

    notepad = "%windir%\system32\notepad.exe"
    app_1 = Application()
    app_1.start("Notepad.exe")
    app_1["Notepad"]["Edit"].set_edit_text(fourtwenty)
    time.sleep(2)
    app_1.Notepad.MenuSelect("File -> Exit")
    app_1.Notepad.DontSave.Click()
    fourtwenty = str(fourtwenty).split(',')
    fourtwenty = (fourtwenty[0].replace("'", ''))
    fourtwenty = str(fourtwenty).replace("420 in:", '')
    app.start(chrome + ' --force-renderer-accessibility --start-maximized '
              'https://www.google.com.co/')
    time.sleep(1)
    SendKeys('{F6}' + fourtwenty + '{ENTER}', with_spaces=True)
Пример #9
0
from os import path
from pywinauto import Application
import win32api

rhino = "C:\Program Files\Rhinoceros 5 (64-bit)\System\Rhino.exe"

app = Application(backend="uia")

app.start(rhino)

print(app.top_window())
Пример #10
0
timeNow = (datetime.datetime.now().time())
dateTime = (datetime.datetime.now())
timeNowSt = str(timeNow)

print(timeNow)

timeNowSt = timeNowSt.split(":")

if timeNowSt[0] == "16" and timeNowSt[1] == "20":

    notepad = "%windir%\system32\notepad.exe"

    app_1 = Application()

    app_1.start("Notepad.exe")

    app_1["Notepad"]["Edit"].set_edit_text("F*****g 420!")

elif timeNowSt[0] == "04" and timeNowSt[1] == "20":

    notepad = "%windir%\system32\notepad.exe"

    app_1 = Application()

    app_1.start("Notepad.exe")

    app_1["Notepad"]["Edit"].set_edit_text("F*****g 420!")

else:
Пример #11
0
import time

from pywinauto import Application, findwindows, Desktop
from pywinauto.timings import wait_until
from appium import webdriver

desktop = Desktop(backend="uia")
nordlocker_app = Application()
nordlocker_app.start('C:\\Program Files\\NordLocker\\NordLauncher.exe',
                     timeout=10)
connected_nordlocker = Application(backend="uia")

try:
    connected_nordlocker.connect(title='NordLocker')
except findwindows.WindowAmbiguousError:
    wins = findwindows.find_elements(active_only=True, title="NordLocker")
    connected_nordlocker.connect(handle=wins[0].handle)
except findwindows.ElementNotFoundError:
    wait_until(
        30, 0.5, lambda: len(
            findwindows.find_elements(active_only=True, title="NordLocker")) >
        0)
    wins = findwindows.find_elements(active_only=True, title="NordLocker")
    connected_nordlocker.connect(handle=wins[0].handle)

main_screen = connected_nordlocker.window(title='NordLocker')


def timeoutError():
    main_screen = connected_nordlocker.window(title='NordLocker')
    try:
Пример #12
0
class BandInABoxController:
    """An object for controlling Band-in-a-Box."""
    _TARGET_VERSION = '2018.0.0.520'

    def __init__(self, binary_path=r'C:\bb\bbw.exe', try_connect=True):
        self.biab_version = _get_exe_version(binary_path)
        if self.biab_version != self._TARGET_VERSION:
            print('This code was written for Band-in-a-Box {}, your version is {}. '
                  'Proceed with caution.'
                  .format(self._TARGET_VERSION, self.biab_version), file=sys.stderr)

        self._app = Application(backend='win32')
        if try_connect:
            try:
                self._app.connect(path=binary_path)
            except ProcessNotFoundError:
                try_connect = False
        if not try_connect:
            self._app.start(binary_path)
            self._app.wait_cpu_usage_lower(threshold=5)

        def get_ready():
            rb_window = self._app.window(class_name='TBandWindow')
            if rb_window.exists() and rb_window.is_visible() and rb_window.is_enabled():
                return

            raise TimeoutError()

        wait_until_passes(func=get_ready,
                          exceptions=(ElementNotFoundError, TimeoutError),
                          timeout=15, retry_interval=1)

    @property
    def app(self):
        return self._app

    def kill(self):
        self._app.kill()
        for proc in psutil.process_iter():
            if proc.name() == 'bbw.exe':
                print('Killing', proc, file=sys.stderr)
                try:
                    proc.kill()
                except psutil.NoSuchProcess:
                    traceback.print_exc(file=sys.stderr)

    def load_song(self, path):
        """Load a song from the given file."""
        self.menu_select('File->Open')
        self._open_file(path)

    def _open_file(self, path):
        """Input a path in the file open dialog."""
        while True:
            dialog = self._app.window(class_name='#32770')
            dialog.wait('ready')

            # If asked whether to save changes, say no
            try:
                dialog_text = dialog.StaticWrapper2.element_info.name
                if 'Save it?' in dialog_text:
                    dialog.Button2.click()
                    continue
            except MatchError:
                pass
            break

        dialog.Edit1.set_edit_text(path)
        dialog.Edit1.send_keystrokes('{ENTER}')
        self._wait_ready(timeout=60)

    def save_song(self, path):
        """Save the current song under the given filename."""
        self.menu_select('File->Save song As')

        file_dialog = self._app.window(class_name='#32770')
        file_dialog.wait('ready')
        file_dialog.Edit1.set_edit_text(path)
        file_dialog.Edit1.send_keystrokes('{ENTER}')
        self._wait_ready()

    def menu_select(self, path, timeout=10, retry_interval=0.5):
        self._wait_ready()

        def select_option():
            self._app.TBandWindow.menu_select(path)

        wait_until_passes(func=select_option,
                          exceptions=(ElementNotEnabled, RuntimeError),
                          timeout=timeout,
                          retry_interval=retry_interval)

    def _wait_ready(self, timeout=30):
        self._app.TBandWindow.wait('ready', timeout=timeout)
Пример #13
0
from pywinauto import Application
import  time
app = Application()
app.start('notepad.exe')
#app.UntitledNotepad.MenuItem('Edit -> Paste').Select()
app.Notepad.MenuItem('Edit -> Paste').Select()
app.notepad.TypeKeys('Hello World')

time.sleep(1)
app.notepad.TypeKeys('^+{ENTER}')

time.sleep(1)
app.Notepad.MenuItem('File -> Exit').Select()
#OK = 'Cancel'
#about_dlg[OK].Click()
app['Notepad']['Cancel'].Click()


Пример #14
0
#print(app.print_control_identifiers())

path = "C:\\Users\\feli2\\Documents\\Cali.txt"

f = open(path, 'r')
f = f.read()
f = f.split('\n')

#print(str(f) + "F**K")

for i in f:

    objOne = (i).split(' ')
    print(str(objOne) + "YES")
    objOne = BeautifulSoup(str(objOne), "html.parser")
    app.start(chrome + ' --force-renderer-accessibility --start-maximized ' +
              "https://www.google.com")

    time.sleep(1)

    SendKeys('{F6}' + str(objOne))
    SendKeys('{ENTER}')
    '''for j in objOne:

        out = j.split('\n')

        #print(str(out) + "NO")

        for x in out: 
            #x = x.replace('[edit]', ' ')
            #x = x.replace(';', ' ')
            #out = (out.replace('&ndash',' '))
# encoding: utf-8
from os import path
from pywinauto import Desktop, Application

chrome_dir = r'"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"'
tab_log_in = u'Meet Google Drive - One place for all your files (Incognito)'
tab_drive = 'My Drive - Google Drive (Incognito)'

# # start google chrome
chrome = Application(backend='uia')
chrome.start(chrome_dir + ' --force-renderer-accessibility --incognito --start-maximized '
             'https://accounts.google.com/ServiceLogin?service=wise&passive=1209600&continue=https:'
             '//drive.google.com/?urp%3Dhttps://www.google.ru/_/chrome/newtab?espv%253D2%2526ie%253DUT%23&followup='
             'https://drive.google.com/?urp%3Dhttps://www.google.ru/_/chrome/newtab?espv%253D2%2526ie%253DUT'
             '&ltmpl=drive&emr=1#identifier')

# wait while a page is loading
chrome[tab_log_in].child_window(title_re='Reload.*', control_type='Button').wait('visible', timeout=10)
ch_window = chrome[tab_drive].child_window(title="Google Chrome", control_type="Custom")

# log in
chrome.window().type_keys('TestPywinauto{ENTER}')  # username
chrome[tab_log_in].child_window(title="Google Chrome", control_type="Custom").\
    child_window(title="Back", control_type="Image").wait(wait_for='visible', timeout=10)

chrome.window().type_keys('testpywinauto123{ENTER}')  # password
ch_window.child_window(title="Getting started PDF", control_type="ListItem").wait(wait_for='visible')

# start explorer in the current path
dir_path = path.join(path.dirname(path.realpath(__file__)), 'UIA_Drive')
explorer = Application().start('explorer.exe ' + dir_path)