def run(self):
        try:
            failed_attempt = 0
            if self.program_window_name != "":
                while pyautogui.getWindow(self.program_window_name) == None and \
                        failed_attempt < 5:
                    logger.info(pyautogui.getWindow(self.program_window_name))
                    time.sleep(1)
                    failed_attempt += 1
                # if there are too many failed attempts, we will send a kill signal
                if failed_attempt < 5:
                    # if it has a window for monkey to play with
                    self.minimize_self()
                    target_window = pyautogui.getWindow(
                        self.program_window_name)
                    self.move_to_center(target_window, pyautogui.size())
                    for _ in range(20):
                        time.sleep(1)
                        self.random_press_key(target_window)
                        self.random_click(target_window)
                        self.random_scrolling(target_window)

            self.proc.wait()

            # kill process after program finishes
            logger.info(self.result_path)
            # close all the windows
            os.system("copy \"" + self.result_path + "\" Z:\\ ")
        except KeyboardInterrupt:
            print '\n Done.'
Example #2
0
    def organizar_as_janelas(self, numero_de_divisoes_da_tela,
                             lista_de_janelas):
        tamanho_da_tela = pyautogui.size()
        conjunto_de_informacoes_das_janelas = []

        largura_da_janela = int(tamanho_da_tela[0] /
                                numero_de_divisoes_da_tela)
        altura_da_janela = int(tamanho_da_tela[1] / numero_de_divisoes_da_tela)

        for idx, item in enumerate(lista_de_janelas):

            posicao_x_da_janela_na_tela = (largura_da_janela - 15) * int(
                (idx) / numero_de_divisoes_da_tela)
            posicao_y_da_janela_na_tela = (altura_da_janela - 10) * (
                (idx) % numero_de_divisoes_da_tela)

            pyautogui.getWindow(item).resize(largura_da_janela,
                                             altura_da_janela)
            pyautogui.getWindow(item).move(posicao_x_da_janela_na_tela,
                                           posicao_y_da_janela_na_tela)

            informacoes_da_janela = {
                'titulo':
                item,
                'dimencao': (largura_da_janela, altura_da_janela),
                'posicao':
                (posicao_x_da_janela_na_tela, posicao_y_da_janela_na_tela)
            }

            conjunto_de_informacoes_das_janelas.append(informacoes_da_janela)

        return print(conjunto_de_informacoes_das_janelas)
def findWindowAndPosition(title):
    all = pa.getWindows()
    for i in all:
        if title in i:
            r_window = i
        else:
            continue
    pa.getWindow(r_window).set_foreground()
    result = pa.getWindow(r_window).get_position()
    return result
Example #4
0
 def openWindow(self, toOpen):
     # Look into "start" command for Windows
     if (platform.system() == "Windows"):
         window_names = auto.getWindows().keys()
         for window_name in window_names: auto.getWindow(window_name).minimize()
         for window_name in window_names:
             if toOpen in window_name and "Patient Information" not in window_name:
                 auto.getWindow(window_name).maximize()
                 break
     else: os.system("open -a " + toOpen.replace(" ", "\\ "))
Example #5
0
def openWindow(toOpen):
    if (platform.system() == "Windows"):
        window_names = auto.getWindows().keys()
        for window_name in window_names:
            auto.getWindow(window_name).minimize()
            if (toOpen in window_name):
                xef_window_name = window_name
        xef_window = auto.getWindow(xef_window_name)
        xef_window.maximize()
    else:
        # auto.hotkey("command", "space")
        # auto.typewrite(toOpen)
        # auto.press("enter")
        auto.hotkey("command", "tab")
Example #6
0
def do_stuff():
    try:
        db_window = pa.getWindow('連絡車予約')
        db_window.maximize()
        db_window.set_foreground()
    except AttributeError:
        db_window = pa.getWindow('HGJ-S MG承認車両予約')
        db_window.maximize()
        db_window.set_foreground()
        pa.hotkey('ctrl', 'shift', 'tab')
        time.sleep(1)
        print('Error encountered')

    def get_data(filename="backup.txt"):
        pa.press('f9')
        pa.hotkey('alt', 'f')
        pa.press(['e', 'enter'])

        while True:
            if ('書き出し' in pa.getWindows().keys()):
                break

        pa.hotkey('alt', 'n')
        pa.typewrite('C')
        wsh = comclt.Dispatch("WScript.Shell")
        wsh.SendKeys(":")
        pa.typewrite("\\xampp\\htdocs\\Car_stat\\")
        pa.typewrite(filename)

        pa.press(['enter', 'enter'])

        while True:
            if ('構造化テキストの書き出し' in pa.getWindows().keys()):
                break
        pa.hotkey('alt', 'i')
        pa.press('enter')
        print(pa.getWindows().keys())

    get_data('file1.txt')
    pa.hotkey('ctrl', 'tab')
    time.sleep(.3)
    get_data('file2.txt')
    pa.hotkey('ctrl', 'shift', 'tab')

    db_window.minimize()
    browser = pa.getWindow('Firefox')
    browser.maximize()
    browser.set_foreground()
Example #7
0
    def run_gui(self):
        window_names = auto.getWindows().keys()
        rex = re.compile(
            self.xef_file_name + ' - Microsoft\\xae Kinect Studio',
            re.IGNORECASE)

        matched_keys = [
            window_name for window_name in window_names
            if rex.search(window_name) is not None
        ]
        xef_window_name = matched_keys[0]

        xef_window = auto.getWindow(xef_window_name)
        xef_window.maximize()

        ## Connect Kinect Studio
        res = auto.locateCenterOnScreen(
            os.path.join('.', 'Images', 'connect.PNG'))
        if res is not None:
            cx, cy = res
            auto.click(cx, cy)
            auto.moveTo(self.width / 2, self.height / 2)
        else:
            print('Kinect Studio already connected')

        ## Enable color stream
        res = auto.locateCenterOnScreen(
            os.path.join('.', 'Images', 'activate.PNG'))
        if res is not None:
            cx, cy = res
            auto.click(cx, cy)
            auto.moveTo(self.width / 2, self.height / 2)
        else:
            print('Color stream already connected')

        ## Play video
        res = auto.locateCenterOnScreen(os.path.join('.', 'Images',
                                                     'play.PNG'))
        if res is not None:
            cx, cy = res
            auto.click(cx, cy)
            auto.moveTo(self.width / 2, self.height / 2)
        else:
            print('Play button not found')

        while True:
            ## Closing condition
            _res = auto.locateCenterOnScreen(
                os.path.join('.', 'Images', 'stop_cond.PNG'))
            if _res is None:
                cx, cy = auto.locateCenterOnScreen(
                    os.path.join('.', 'Images', 'close_button.PNG'))
                auto.click(cx, cy)
                auto.moveTo(self.width / 2, self.height / 2)
                break
            else:
                # print '. ',
                time.sleep(0.1)
Example #8
0
def focus_window(window_name):
    """
    Get window and move it to front

   Args:
        window_name (str): Name of the window i.e. Untitled - Notepad
    """
    window = pyautogui.getWindow(window_name)
    window.set_foreground()
Example #9
0
def MoveWin(x, y):
    try:
        win = pyautogui.getWindow(
            'DPC-230 Emulation - FIFO data files conversion'
        )  # returns a “Win” object
        # Current_win_pos = win.position() # returns (x, y) of top-left corner
        win.move(x, y)
    except:
        print("'DPC-230 Emulation - FIFO data files conversion' is not open!")
Example #10
0
    def __init__(self, users):

        self.users = users
        
        #pyautogui.failsafe = True # Force Quit at Top Left Corner with Cursor
        os.startfile("C:\\Program Files\\Open Media LLC\\combin\\combin.exe")
        self.createCountdown(30)

        pyautogui.getWindow("Combin").minimize()
        pyautogui.getWindow("Combin").maximize()
        time.sleep(1)

        pyautogui.hotkey("alt", "2") # Search Tab
        time.sleep(1)
        self.searchFunction()
        self.createCountdown(500)
        print("USERS LOADED")
        self.likeFollow()
Example #11
0
 def getWindow(self, name: str = '', id: int = 0):
     eval(self.__action)
     window = None
     temp = id if id > 0 else name
     if temp == '':
         self.__Exception('You must specify a name or ID')
     else:
         window = pyautogui.getWindow(temp)
     return window
Example #12
0
def start_d2d2_sniffer():
    commands = ["start", "cmd", "/k"]
    p = Popen(commands, shell=True, stdin=PIPE, stdout=PIPE, universal_newlines=True)
    sleep(0.3)
    title = pyautogui.getWindow("system32")
    title.set_foreground()
    pyautogui.typewrite("cd sniffer\n")
    pyautogui.typewrite("d2d2_sniffer /port=COM2\n")
    return p
Example #13
0
 def __init__(self):
     '''Initialization'''
     with open ('SwiperConfig.json') as json_data_file:
         config = json.load(json_data_file).get("tinder")
     self.Emulator_Name = config.get("emulator")
     self.Emulator_Window = pyautogui.getWindow(self.Emulator_Name)
     self.X_Start_Offset = config.get("x_start_offset")
     self.Y_Start_Offset = config.get("y_start_offset")
     self.Start_Img_Name = config.get("start_img_name")
     self.Start_Pos = pyautogui.locateCenterOnScreen('tinderLogo.png')
     if (self.Emulator_Window == None or self.Start_Pos == None):
         raise Exception ('No Emulator Window Dectected!!!')
Example #14
0
    def searchFunction(self):

        print("Searching Users' Followers from [users] list..")
        for user in self.users:

            pyautogui.click(240, 140) # Add Search Button
            time.sleep(.5)
            pyautogui.click(1170, 150) # Users Button
            time.sleep(.5)
            pyautogui.click(1400, 680) # Advanced Search
            time.sleep(.5)
            pyautogui.click(1400, 700) # User Active Button
            time.sleep(.5)
            pyautogui.click(1000, 350) # Username Field
            time.sleep(.5)
            pyautogui.typewrite(user) # Type Username
            time.sleep(2.5) # Wait for Correct User to Show Up
            pyautogui.click(1000, 380) # Correct User
            pyautogui.click(1020, 640) # Enter Button

        pyautogui.getWindow("Combin").minimize()
        print("Waiting for all users to load finish..")
Example #15
0
 def organizar_mesas(self,divisoes):
     tamanho_da_tela = pyautogui.size()
     altura = int((tamanho_da_tela[1] - 20)/divisoes)
     largura = int(altura * (1.35))
     i = 0
     for chave in self.dicionario_de_mesas:
         janela = pyautogui.getWindow(chave)
         posicao_x = (largura - 20)* int( i / divisoes) - 10
         posicao_y = (altura - 10)* int( i % divisoes)
         dupla = (posicao_x + 10,posicao_y,largura - 20,altura - 10)
         self.dicionario_de_mesas[chave] = dupla
         janela.resize( largura, altura)
         janela.move(posicao_x,posicao_y)
         i += 1
def findWindow(p_title):
    time.sleep(3)
    all = pa.getWindows()
    # print(all)
    for i in all:
        if p_title in i:
            result = i
            print(f'{result} 윈도우 여부 확인~')
        else:
            continue
    win = pa.getWindow(result)
    coord_win = win.get_position()
    print(f'결재창의 위치 {coord_win}를 찾습니다.')
    # input('결재창을 선택하세요.')
    return coord_win
Example #17
0
 def run(self):
     while True:
         try:
             for title, _ in auto.getWindows().items():
                 if not title.startswith('fgauto'):
                     continue
                 if title not in self._ths:
                     try:
                         win = auto.getWindow(title)
                         w = Actor(title, win)
                         w.setDaemon(True)
                         w.start()
                     except Exception as e:
                         log().error('new worker failed:{}'.format(e),
                                     exc_info=True)
                     else:
                         self._ths[title] = w
                 else:
                     pass
         except Exception as e:
             log().error('Main error {}'.format(e), exc_info=True)
         time.sleep(10)
Example #18
0
	desktopName = ""
	pinCode     = ""
	
	dict = cmd_parse(desktopName, pinCode)
	
	desktopName = dict['key-desktopname']
    pinCode     = dict['key-pincode']
	
	if ( (desktopName == "") or (pinCode == "")):
	    raise Exception("Input desktop name or PIN password is not correct.")
		return -1
	
	print "Desktop name is [%s] and PIN password is [%s]." % (desktopName, pinCode)
	
	#win = pyautogui.getWindow('rh73demo - Desktop Viewer')
	win = pyautogui.getWindow(desktopName)
	win.set_foreground()
	time.sleep(2)
	loc = pyautogui.locateOnScreen('pin.png')
	if loc == None:
		raise Exception("Cannot find icon for pin.")
	else:
		x, y = pyautogui.center(loc)
		pyautogui.click(x, y)
		time.sleep(2)
		#pyautogui.typewrite('000000')
		pyautogui.typewrite(pinCode)
		time.sleep(0.1)
		pyautogui.press('tab')
		time.sleep(0.1)
		pyautogui.press('enter')
Example #19
0
import pyautogui as pygui
import time

choice = input('Enter name of your paint program')

pygui.press('win')
pygui.typewrite(choice)
pygui.press('enter')

paint_window = pygui.getWindow(choice)


def select_tool(toolname):
    if toolname == 'brush':
        pygui.press('b')
    elif toolname == 'bucket':
        pygui.press('f')
    elif toolname == 'eraser':
        pygui.press('e')


def fill_square(x=0, y=0):
    pygui.moveRel(x, y)
    pygui.press('f')
    pygui.click()


def create_square(size, x=0, y=0):
    pygui.dragRel(size + x, 0, duration=.05)
    pygui.dragRel(0, size + y, duration=.05)
    pygui.dragRel(-size - x, 0, duration=.05)
 def minimize_self(self):
     window_list = pyautogui.getWindows()
     for win in window_list:
         if "cmd.exe" in win or "python.exe" in win:
             pyautogui.getWindow(win).minimize()
Example #21
0
#! python3
import pyautogui, sys
while True:
    title = input('please type tile:')
    try:
        win = pyautogui.getWindow(title)
    except Exception:
        print('wrong title {}'.format(title))
    else:
        break
print('Press Ctrl-C to quit.')
try:
    while True:
        x, y = pyautogui.position()
        positionStr = 'X: ' + str(x).rjust(4) + ' Y: ' + str(y).rjust(4)
        pos = win.get_position()
        left, top, _, _ = pos
        positionStr += ' <Win {} {}> REL ({}, {})'.format(
            title, pos, x - left, y - top)
        print(positionStr, end='')
        print('\b' * len(positionStr), end='', flush=True)
except KeyboardInterrupt:
    print('\n')
Example #22
0
import pyautogui

## Window handling features:
list_ = pyautogui.getWindows(
)  # returns a dict of window titles mapped to window IDs
# pyautogui.getWindow(str_title_or_int_id) # returns a “Win” object
win = pyautogui.getWindow(
    'DPC-230 Emulation - FIFO data files conversion')  # returns a “Win” object
win.move(100, 100)

# win.resize(width, height)
# win.maximize()
# win.minimize()
# win.restore()
# win.close()
win.position()  # returns (x, y) of top-left corner
# win.moveRel(x=0, y=0) # moves relative to the x, y of top-left corner of the window
# win.clickRel(x=0, y=0, clicks=1, interval=0.0, button=’left’) # click relative to the x, y of top-left corner of the window

pyautogui.click(150, 110)

print(list_, '\n', win)
Example #23
0
def getWindow():
    return pagui.getWindow("League of Legends")
Example #24
0
except WindowsError:
    print "dnplayer InstallDir query failed. not installed in the system, please install it before using this script"
    sys.exit(0)   

# 获取窗口位置
left, top, right, bottom = win32gui.GetWindowRect(handle)
#获取某个句柄的类名和标题
title = win32gui.GetWindowText(handle)     
clsname = win32gui.GetClassName(handle)

print 'Title of  ldplayer:', title
print 'Class of  ldplayer:', clsname

# 十进制
print 'Handle of ldplayer:',"%x" %(handle)

# 搜索子窗口
# 枚举子窗口
hwndChildList = []     
win32gui.EnumChildWindows(handle, lambda hwnd, param: param.append(hwnd),  hwndChildList)

print 'Child Windows:', hwndChildList

menuHandle = win32gui.GetMenu(handle)

print menuHandle

my_window = pyautogui.getWindow(u'雷电模拟器') 
print my_window
my_window.resize(400, 400)
my_window.moveRel(x=0, y=0)
Example #25
0
def getPosition(p_win):
    pa.getWindow(p_win).set_foreground()
    result = pa.getWindow(p_win).get_position()
    return result
defaultScreenshotFoldername = 'Hearthstone packs'

desktopPath = os.path.join(r"C:\Users",os.getlogin(),'Desktop')
screenshotPath = os.path.join(r"C:\Users",os.getlogin(),'Pictures')
screenshotFolderName = input("Folder name for pack screenshots: ")
if not screenshotFolderName:
   screenshotPath = os.path.join(screenshotPath,defaultScreenshotFoldername)
else:
   screenshotPath = os.path.join(screenshotPath,screenshotFolderName)

if not os.path.exists(screenshotPath):
    os.makedirs(screenshotPath)

packCount = int(input("Enter number of packs to be opened: "))

hearthstoneWindow = pyautogui.getWindow('Hearthstone')
time.sleep(3)


def countCoordinatesOfPoint(percentages):
    try:
        w1,h1,w2,h2 = hearthstoneWindow.get_position()
        x = round(w1 + (w2-w1)*percentages[0])
        y = round(h1 + (h2-h1)*percentages[1])
        return x,y;
    except:
        SystemExit(0)


def clickInWindow(percentages,delay):
    x,y = countCoordinatesOfPoint(percentages)
Example #27
0
def getPosition(p_win):
    pa.getWindow(p_win).set_foreground()
    result = pa.getWindow(p_win).get_position()
    print('윈도우 위치값 확인!')
    return result
Example #28
0
import re

<<<<<<< HEAD
sys.path.append('C:/Drive-W/Internal_tools/Libraries/IOLibrary/trunk/out')
from IOWrapper import IOWrapper

def create_log():
    currentDateTime = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
    filename = currentDateTime + ".log"
    currentdir = os.getcwd()
    path = os.path.join(currentdir, "report", filename)
=======
commands = ["start", "cmd", "/k", "dir"]
p = Popen(commands, shell=True, stdin=PIPE, stdout=PIPE, universal_newlines=True)
sleep(0.3)
title = pyautogui.getWindow("system32")
title.set_foreground()
print(title)
pyautogui.typewrite("allo\n")
pyautogui.typewrite("cd..\n")
processId = p.pid
print("Le process id est: {}" .format(processId))

title = pyautogui.getWindow("system32")
title.set_foreground()
pyautogui.keyDown('altleft')
pyautogui.keyDown('F4')

pyautogui.keyUp('altleft')
pyautogui.keyUp('F4')
p.kill()
Example #29
0
from appIsOpenCheck import appIsOpenCheck
from lib import clearAppScreen
from lib import menuSelect
from lib import appScreenCheck
import pyautogui, time

# Detect screen resolution
screenResolution = pyautogui.size()

# Determin if QAD application is open and add focus
appIsOpenCheck()

while True:
    window = pyautogui.getWindow(appIsOpenCheck())
    if window:
        window.set_foreground()
        break

# Maximize app
pyautogui.hotkey('alt', ' ', 'x')
time.sleep(1)

clearAppScreen.clearAppScreen()

cert = 'A'
supplierName = 'test'
supplierSearchName = 'test-370-'
supplierAddressStreet = 'Test'
supplierAddressZip = '11111'
supplierAddressCity = 'Test'
supplierAddressState = 'TX'
#sellMarket()
#flattenTrade()

isAutoSend = False

interval = [
    'today', 'WTD', '1 day', '2 day', '3 day', '4 day', '5 day', '10 day',
    '15 day', '20 day', '30 day', '90 day', '180 day', '360 day', 'YTD',
    '1 month', '3 month', '6 month', '9 month', '1 year', '2 year', '3 year',
    '4 year', '5 year', '10 year', '15 year', '20 year', 'max'
]

dayPeriod = ['day', '2 day', '3 day', '4 day', 'week ', 'month']

#check build number if incorrect think.get_position()
think = pg.getWindow("thinkorswim [build 1920]")
threshold = 99
loop = True
sleepTime = 1

trades = []


def filler():
    pass


def recordLog(input):
    input += "\n"
    with open("tradeLogs.csv", "a") as file:
        file.write(input)