def findWindow(): all = pa.getWindows() for i in all: if 'http://bms.ken.go.kr/?USERID=driver' in i: r_window = i else: continue return r_window
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)
def retornar_lista_de_janelas_com_a_palavra_chave_no_titulo( self, palavra_chave): dicionario_de_janelas = pyautogui.getWindows() lista_de_janelas_com_a_palavra_chave = [] for item in dicionario_de_janelas: if item.find(palavra_chave) != -1: lista_de_janelas_com_a_palavra_chave.append(item) return lista_de_janelas_com_a_palavra_chave
def findWindow(): all = pa.getWindows() for i in all: if "That's Speaking" in i: r_window = i print('강의창 확인~') else: continue return r_window
def findWindow(): all = pa.getWindows() for i in all: if 'https://klef.goe.go.kr/?USERID=driver' in i: r_window = i print('결재창 여부 확인~') else: continue return r_window
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
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(" ", "\\ "))
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")
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())
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
def find_window(title_contents): try: visible_windows = pyautogui.getWindows() for title in visible_windows: if title_contents in title: return pyautogui.Window(visible_windows[title]) except AttributeError as e: if "has no attribute 'getWindows" in str(e): from libs._window_x11 import Window, getWindows, getWindow visible_windows = getWindows() for title in visible_windows: if title_contents in title: return Window(visible_windows[title]) pass return None
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)
def final(_main): #문서처리 작업 시작 print('문서처리 시작....') clickIwant(_main, 버튼_문서처리) # 문서처리창 작업하기 sub_02 = findWindow(neis_confirm) # 문서처리창 확인 클릭하기 print('확인 클릭....') 문서처리_확인 = [714, 126] clickIwant(sub_02, 문서처리_확인) # for i in range(2): # time.sleep(4) # pa.hotkey('enter') # # print('결재 완료') # 작업처리 _main, cmd = setup() select_card(_main, cmd) final(_main) test = pa.getWindows() for i in test: print(i)
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()
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)
def gestureCommands(self, sequence): print "getting command:", sequence (commandID, actionID) = (-1, -1) commandAction = sequence ################################################################## ############# CHECK THAT THE COMMAND IS VALID #################### ################################################################## if (sequence.find(" ") != -1): commandAction = sequence[:sequence.find(" ")] self.status["params"] = sequence[sequence.find(" ") + 1:] #elif (self.status["hold_action"] is None): self.status["params"] = "" else: self.status["params"] = "" if (commandAction.find("_") != -1): try: commandID = int(commandAction[:commandAction.find("_")]) actionID = int(commandAction[commandAction.find("_") + 1:]) command = self.actionList[commandID][0] action = self.actionList[commandID][actionID] except ValueError: print "Unrecognized sequence of commands!\n" return False except IndexError: print "Incorrect commands!\n" return False else: print "Invalid command entered!\n" return False ############# FINISH CHECKING ##################### # default command is the modifier and groupt1_command the context # RESET CONTEXT AND MODIFIER if (self.status["defaultCommand"] != command and self.status["defaultCommand"] is not None): # if is changing from one command to another and not from a reset` print "resetting context", self.status["defaultCommand"], command self.status["defaultCommand"] = None auto.mouseUp() if (self.status["group1_command"] != command and self.status["group1_command"] is not None): # if is changing from one command to another and not from a reset` print "resetting modifier", self.status["group1_command"], command self.status["defaultCommand"] = None self.status["group1_command"] = None auto.mouseUp() #################################################### ################## ADMIN COMANDS ################### #################################################### if (command == "Admin" and action != "Admin"): if (action == "Quit"): removeImagesPrompt() sys.exit(0) elif (action == "Get Status"): print "------\nself.status\n------" print "Previous action: " + self.status["prev_action"] print "Panel Dimension: " + str(self.status["panel_dim"][0]) + 'x' + str(self.status["panel_dim"][1]) print "Active panel: " + str(self.status["active_panel"][0]) + 'x' + str(self.status["active_panel"][1]) print "Patient information window: " + ("opened" if self.status["window_open"] else "closed") print "" elif (action == "Reset"): if (self.status["params"] == "All"): calibration.resetAll() if (self.status["params"] == "TopBar"): calibration.resetTopBarHeight() elif (self.status["params"] == "RightClick"): calibration.resetRightClick() elif (self.status["params"] == "Presets"): calibration.resetRightOptions("presets", 8.5) elif (self.status["params"] == "ScaleRotateFlip"): calibration.resetRightOptions("scaleRotateFlip", 9.5) (self.status["topBarHeight"], self.status["optionH"], self.status["rightHR"], self.status["rightPlus"], self.status["rightIcons"], self.status["rightOffset"], self.status["rightBoxW"], self.status["rightBoxH"]) = calibration.getAll() f = open(calibrationPath, "w") f.write(json.dumps(self.status, indent=4, separators=(',', ': '))) f.close() # if (self.status["hold_action"] is not None): # sequence = self.status["hold_action"] # self.status["hold_action"] = "held" # return gestureCommands(sequence) #################################################### ###################### SCROLL ###################### #################################################### elif (command == "Scroll" and action != "Scroll"): self.moveToActivePanel() auto.click() scrollAmount = (50 if self.status["params"] == "" else int(self.status["params"])) auto.PAUSE = 0 for i in range(scrollAmount): auto.press("right" if action == "Up" else "left") auto.PAUSE = 0.25 auto.click() #################################################### ####################### FLIP ####################### #################################################### elif (command == "Flip" and action != "Flip"): self.moveToActivePanel() auto.click(button='right') auto.PAUSE = 0.1 auto.press("0") auto.press("s") time.sleep(self.menuSleep) auto.press("0") auto.press("h" if action == "Horizontal" else "v") auto.PAUSE = 0.25 #################################################### ##################### ROTATE ####################### #################################################### elif (command == "Rotate" and action != "Rotate"): self.moveToActivePanel() auto.click(button='right') auto.PAUSE = 0.1 auto.press("0") auto.press("s") time.sleep(self.menuSleep) auto.press("0") auto.press("r") if (action != "Clockwise"): auto.press("down") auto.press("enter") auto.PAUSE = 0.25 #################################################### ##################### ZOOM ######################### #################################################### elif (command == "Zoom"): splitParams = self.status["params"].split("_") # If performing just the context # or an a modifier alone if actionID == 0 or\ (self.status["defaultCommand"] is None and commandID !=0): self.moveToActivePanel() auto.click() auto.click(button='right') auto.PAUSE = 0.1 auto.press("z") auto.mouseDown() # add the context if we are just performing a context self.status["defaultCommand"] = command # if we are performing a zoom in or a zoom out if actionID != 0: # Get the level, acording to the params or default if (len(splitParams) % 2 == 1 and self.status["params"] != ""): level = (-1 * int(splitParams[0]) if action == "In" else int([0])) else: level = (-100 if action == "In" else 100) if (len(splitParams) <= 1): (moveToX, moveToY) = auto.position() else: (moveToX, moveToY) = (int(splitParams[len(splitParams) - 2]), int(splitParams[len(splitParams) - 1])) auto.moveTo(moveToX, moveToY) auto.mouseDown() auto.moveTo(moveToX, moveToY + level) #auto.mouseUp() self.status["group1_command"] = command #################################################### ################## SWITCH PANEL #################### #################################################### elif (command == "Switch Panel" and action != "Switch Panel"): ind = int(actionID / 3) self.status["active_panel"][ind] += (-1 if action == "Left" or action == "Up" else 1) self.status["active_panel"][ind] = max(1, self.status["active_panel"][ind]) self.status["active_panel"][ind] = min(self.status["active_panel"][ind], self.status["panel_dim"][ind]) self.moveToActivePanel() auto.click() #################################################### ###################### PAN ######################### #################################################### elif (command == "Pan"): splitParams = self.status["params"].split("_") # If performing just the context # or an a modifier alone if actionID == 0 or\ (self.status["defaultCommand"] is None and commandID !=0): self.moveToActivePanel() auto.click() auto.click(button='right') auto.PAUSE = 0.1 auto.press("0") auto.press("p") auto.PAUSE = 0 auto.press("enter") # (auto.press(e) for e in ["p", "enter"]) auto.mouseDown() # add the context if we are just performing a context self.status["defaultCommand"] = command # if we are performing a pan modifier if actionID != 0: # Get the jump of the pan acording to the parameters if (len(splitParams) % 2 == 1 and self.status["params"] != ""): level = (int(splitParams[0]) if action == "Left" or action == "Up" else -1 * int(splitParams[0])) else: level = (40 if action == "Left" or action == "Up" else -40) # Get the initial position of the pan according to the parameters if (len(splitParams) <= 1): (moveToX, moveToY) = auto.position() else: (moveToX, moveToY) = (int(splitParams[len(splitParams) - 2]), int(splitParams[len(splitParams) - 1])) # Get the final position of the pan according to the command if (action == "Left" or action == "Right"): (toMoveX, toMoveY) = (moveToX + level, moveToY) else: (toMoveX, toMoveY) = (moveToX, moveToY + level) # Move the pan auto.moveTo(moveToX, moveToY) if self.status["defaultCommand"] is not None: auto.mouseDown() print "moving to:", toMoveX, toMoveY auto.moveTo(toMoveX, toMoveY) #auto.mouseUp() self.status["group1_command"] = command #################################################### ###################### WINDOW ###################### #################################################### # General way it should work, but it would have issues. # For now, don't test Window Open/Close (no 8_1 or 8_2) elif (command == "Window" and action != "Window"): # Coordinates on AHRQ Dell with scale 1.0: # (iconW, barW) = (57.0, 15.0) # (moveToX, moveToY) = (iconW * 5.5 + barW, (self.status["topBarHeight"] - 9.0) / 2.0) # # Coordinates on Mac with scale 2.0: # (iconW, barW) = (74.0, 19.0) # (moveToX, moveToY) = (iconW * 5.5 + barW, (macH + (self.status["topBarHeight"] - 9.0) / 2.0) / scale) # # Therefore, try using: # (iconW, barW) = (57.0 * self.status["topBarHeight"] / 169.0, 15.0 * self.status["topBarHeight"] / 169.0) # (moveToX, moveToY) = (iconW * 5.5 + barW, (macH + (self.status["topBarHeight"] - 9.0) / 2.0) / scale) # Uncomment the return to not ignore window #return True if (action == "Open" and not self.status["window_open"]): self.moveToActivePanel() auto.click() if (platform.system() == "Windows"): auto.hotkey("win", "alt", "e") time.sleep(5) else: # original Page with a dash time.sleep(1) regularPath = os.path.join("SCA_Images", "Window", "regular.png") regular = ImageGrab.grab(bbox=(0, self.macH, self.nativeW, self.nativeH)) regular.save(regularPath) # new page without the dash, "ICA Seamless Host Agent" auto.hotkey("alt", "tab") time.sleep(1) icaSHAPath = os.path.join("SCA_Images", "Window", "icaSHA.png") icaSHA = ImageGrab.grab(bbox=(0, self.macH, self.nativeW, self.nativeH)) icaSHA.save(icaSHAPath) auto.hotkey("alt", "tab") # patient info window pop-up auto.hotkey("command", "altleft", "e") time.sleep(5) auto.moveTo(0, self.height / 2.0) # patient info window without a dash patInfoPath = os.path.join("SCA_Images", "Window", "patInfo.png") patInfo = ImageGrab.grab(bbox=(0, self.macH, self.nativeW, self.nativeH)) patInfo.save(patInfoPath) # Get the patient information window box patInfoBox = ImageChops.difference(icaSHA, patInfo).getbbox() window = patInfo.crop(box=patInfoBox) window.save(os.path.join("SCA_Images", "Window", "window.png")) # Save Close seriesClosePath = os.path.join("SCA_Images", "Window", "Closes", "seriesClose.png") (x1, y1, x2, y2) = patInfoBox (tempX, tempY) = (x2, y1) (x1, y1) = (tempX + ((-14.0 - 90.0) * self.scale / 2.0), tempY + (3.0) * self.scale / 2.0) (x2, y2) = (tempX + (-14.0) * self.scale / 2.0, tempY + (43.0) * self.scale / 2.0) seriesClose = ImageGrab.grab(bbox=(x1, y1 + self.macH, x2, y2 + self.macH)) seriesClose.save(seriesClosePath) # patient info window gray without a dash auto.keyDown("alt") auto.press("tab") auto.press("tab") auto.keyUp("alt") time.sleep(1) patInfoGrayPath = os.path.join("SCA_Images", "Window", "patInfoGray.png") patInfoGray = ImageGrab.grab(bbox=(0, self.macH, self.nativeW, self.nativeH)) patInfoGray.save(patInfoGrayPath) window_gray = patInfoGray.crop(box=patInfoBox) window_gray.save(os.path.join("SCA_Images", "Window", "window_gray.png")) # Save Close_Gray seriesClose_GrayPath = os.path.join("SCA_Images", "Window", "Closes", "seriesClose_Gray.png") seriesClose_Gray = ImageGrab.grab(bbox=(x1, y1 + self.macH, x2, y2 + self.macH)) seriesClose_Gray.save(seriesClose_GrayPath) auto.hotkey("alt", "tab") # Hover over close box, save Close_Red auto.moveTo((x1 + x2) / (2.0 * self.scale), (y1 + y2) / (2.0 * self.scale) + self.macH / self.scale) time.sleep(1) patInfoRedPath = os.path.join("SCA_Images", "Window", "patInfoRed.png") patInfoRed = ImageGrab.grab(bbox=(0, self.macH, self.nativeW, self.nativeH)) patInfoRed.save(patInfoRedPath) window_red = patInfoRed.crop(box=patInfoBox) window_red.save(os.path.join("SCA_Images", "Window", "window_red.png")) seriesClose_RedPath = os.path.join("SCA_Images", "Window", "Closes", "seriesClose_Red.png") seriesClose_Red = ImageGrab.grab(bbox=(x1, y1 + self.macH, x2, y2 + self.macH)) seriesClose_Red.save(seriesClose_RedPath) self.status["window_open"] = True elif (action == "Close" and self.status["window_open"]): # Windows hasn't been tested but it should work if (platform.system() == "Windows"): # Have not tested the code below, but hopefully will work # Should do the following: # Minimize all windows except for ones inside Synapse window_names = auto.getWindows().keys() for window_name in window_names: if not (window_name.endswith(" - \\\\Remote")): auto.getWindow(window_name).minimize() window_names = auto.getWindows().keys() # Maximize only the "Patient Information" window that's in Synapse for window_name in window_names: try: if window_name.endswith(" - \\\\Remote") and window_name.startswith("Patient Information for "): xef_window = auto.getWindow(window_name) # Resize the window to be half screen-width x half screen-height # Click on the close button xef_window.maximize() xef_window.resize(width / 2.0, height / 2.0) (closeX, closeY) = (10 + (width * 90.0 / 1920.0), 2 + (width * 40.0 / 1920.0)) xef_window.clickRel(x=(width / 2.0 - closeX), y=closeY, clicks=1, button='left') break except Exception as e: continue #auto.hotkey("fn", "alt", "f4") else: for file in os.listdir(os.path.join("SCA_Images", "Window", "Closes")): if (not file.endswith(".png")): continue close = auto.locateCenterOnScreen(os.path.join("SCA_Images", "Window", "Closes", file)) if (close is not None): (x, y) = close auto.moveTo(x / scale, y / scale) auto.click() status["window_open"] = (not status["window_open"]) break #auto.hotkey("command", "fn", "f4") self.status["window_open"] = False #################################################### ################ MANUAL CONTRAST ################### #################################################### elif (command == "Manual Contrast"): splitParams = self.status["params"].split("_") if (self.status["defaultCommand"] is None): if (self.status["group1_command"] is None): self.moveToActivePanel() auto.click(button='right') (auto.press(e) for e in ["0", "w"]) if (command == action): self.status["defaultCommand"] = command auto.mouseDown() else: if (splitParams[0] != ""): level = (-1 * int(splitParams[0]) if action == "Decrease" else int(splitParams[0])) else: level = (-50 if action == "Decrease" else 50) (oldLocationX, oldLocationY) = auto.position() auto.mouseDown() auto.moveTo(oldLocationX, oldLocationY + level) self.status["group1_command"] = command else: (oldLocationX, oldLocationY) = auto.position() if (len(splitParams) == 1): if (self.status["params"] != ""): level = (-1 * int(splitParams[0]) if action == "Decrease" else int(splitParams[0])) else: level = (-50 if action == "Decrease" else 50) else: print "For " + command + ", you must pass a maximum of one argument." return False auto.moveTo(oldLocationX, oldLocationY + level) #################################################### ##################### LAYOUT ####################### #################################################### elif (command == "Layout" and action != "Layout"): # Coordinates on AHRQ Dell with scale 1.0: # (iconW, barW) = (57.0, 15.0) # (moveToX, moveToY) = (iconW * 10.5 + barW * 3.0, (self.status["topBarHeight"] - 9.0) / 2.0) # # Coordinates on Mac with scale 2.0: # (iconW, barW) = (74.0, 19.0) # (moveToX, moveToY) = (iconW * 10.5 + barW * 3.0, (macH + (self.status["topBarHeight"] - 9.0) / 2.0) / scale) # # Therefore, try using: # (iconW, barW) = (57.0 * self.status["topBarHeight"] / 169.0, 15.0 * self.status["topBarHeight"] / 169.0) # (moveToX, moveToY) = (iconW * 10.5 + barW * 3.0, (macH + (self.status["topBarHeight"] - 9.0) / 2.0) / scale) (oldLocationX, oldLocationY) = auto.position() auto.moveTo(oldLocationX, 0) time.sleep(1) (iconW, barW) = (57.0 * self.status["topBarHeight"] / 169.0, 15.0 * self.status["topBarHeight"] / 169.0) (moveToX, moveToY) = (iconW * 10.5 + barW * 3.0, (self.macH + (self.status["topBarHeight"] - 9.0) / 2.0) / self.scale) auto.moveTo(moveToX, moveToY) auto.click() time.sleep(5) if (platform.system() == "Windows"): window_names = auto.getWindows().keys() for window_name in window_names: try: if window_name.endswith(" - \\\\Remote") and window_name.startswith("Page Layout - "): (winX, winY) = auto.getWindow(window_name).position() (x1, y1) = (winX + 67.0 * width / 1920.0, winY + 95.0 * width / 1920.0) (jumpX, jumpY) = (93.0 * width / 1920.0, 97.0 * width / 1920.0) (self.status["panel_dim"][0], self.status["panel_dim"][1]) = (1, actionID) x1 += (self.status["panel_dim"][1] - 1) * jumpX auto.moveTo(x1, y1) auto.click() resetPanelMoves() moveToActivePanel() auto.click() break except Exception as e: continue else: # For mac # box = (1.0 * scale, status["topBarHeight"], -1.0 * scale, -1.0 * scale) # box = tuple(boundBoxNoDash[i] + box[i] for i in range(4)) # afterHoverPath = os.path.join("SCA_Images", "Layout", "afterHover.png") # ImageGrab.grab(bbox=box).save(afterHoverPath) # 429,54 on mac from topBar, without scale # if (platform.system() == "Windows"): auto.moveTo(642.0 * width / 1920.0, 80.0 * height / 1080.0) # else: auto.moveTo(857.0 / 2.0, (109.0 + 44.0) / 2.0) # (iconW, barW) = (57.0 * self.status["topBarHeight"] / 169.0, 15.0 * self.status["topBarHeight"] / 169.0) # (moveToX, moveToY) = (iconW * 10.5 + barW * 3.0, (macH + (self.status["topBarHeight"] - 9.0) / 2.0) / scale) # auto.moveTo(moveToX, moveToY) # auto.click() # time.sleep(5) # windowPath = os.path.join("SCA_Images", "Layout", "window.png") # ImageGrab.grab(bbox=box).save(windowPath) # diffLayoutPath = os.path.join("SCA_Images", "Layout", "diffLayout.png") # diffBox = get_bbox(afterHoverPath, windowPath) # (x1, y1, x2, y2) = (diffBox[i] + box[(i % 2)] for i in range(4)) # ImageGrab.grab(bbox=(x1, y1, x2, y2)).save(diffLayoutPath) # auto.moveTo(x1, y1) # time.sleep(2) # auto.moveTo(x1 / scale, y1 / scale) # time.sleep(2) # (x1, y1) = ((x1 + 91.0) / 2.0, (y1 + 127.0) / 2.0) # jumpX = (122.0 / 2.0) # (status["panel_dim"][0], status["panel_dim"][1]) = (1, actionID) # (x1, y1) = (472.0 + (actionID - 1) * 62.0, 217.0) # x1 += (status["panel_dim"][1] - 1) * jumpX # auto.moveTo(x1, y1) # auto.click() # resetPanelMoves() # moveToActivePanel() # auto.click() #################################################### ################ CONTRAST PRESETS ################## #################################################### elif (command == "Contrast Presets" and action != "Contrast Presets"): self.moveToActivePanel() auto.click() auto.click(button='right') auto.PAUSE = 0.1 (auto.press(e) for e in ["0", "i", "right"]) time.sleep(0.5) auto.press("0") for i in range(actionID + 1): auto.press("down") auto.press("enter") auto.PAUSE = 0.25 time.sleep(1) return True
def listWindows(self): eval(self.__action) windows = list(filter(None, pyautogui.getWindows().keys())) return windows
import re pa.FAILSAFE = True sec_between_keys = 0.25 sec_between_term = 3 sec_sleep = 0.5 #스크린샷 def screenGrab(): box = () im = IG.grab(box) im.save(os.getcwd() + '\\img\\full_snap__' + str(int(time.time())) + '.png', 'PNG') #화면이 켜질때 까지 기다리기 all = pa.getWindows() for i in all: if 'http://bms.ken.go.kr/?USERID=driver' in i: print(i, 'yes') else: continue pa.getWindow('카카오톡').set_foreground() te = pa.getWindow('카카오톡').get_position() print(te) ''' RAON K Hybrid Agent Study_webCrawling from 2018 [D:\OneDrive - 학현초등학교\Gdrive\★작업중\SW_PyCharm\studyPython from 2018] - ...\crawling\crawler_naver news_all_180802 .py [Study_webCrawling from 2018] - PyCharm ...\pyAutogui\pyAutoGui_Neis_Gyeljae_180906.py [Study_webCrawling from 2018] - PyCharm http://bms.ken.go.kr/?USERID=driver1&APPRIDLIST=J10CB182424951849000&APPRDEPTID=J100004848&APPR - Internet Explorer http://bms.ken.go.kr/ - 결재대기 | 업무관리시스템 - Internet Explorer
import pyautogui as at # here adding this comment def click(): at.click() def dclick(): at.doubleClick() scWidth, scHeight = at.size() curX, curY = at.position() print(scWidth, " : ", scHeight) print(curX, " : ", curY) at.moveTo(500, 150) click() dclick() dclick() at.typewrite("# here adding this comment") at.keyDown('ctrl') at.press(['enter', 's']) at.keyUp('ctrl') # at.scroll(-100) print(at.getWindows())
def registrar_lista_de_mesas(self): dicionario_de_telas = pyautogui.getWindows() for chave in dicionario_de_telas: if chave.find("No Limit Hold'em") != -1: self.dicionario_de_mesas.setdefault(chave,None)
from selenium import webdriver import time import pic try: import Image except ImportError: from PIL import Image import pyautogui print(pyautogui.position()) print(pyautogui.getWindows()) win = pyautogui.getWindow("0").get_position() print(win) # pyautogui.click() # pytesseract.pytesseract.tesseract_cmd = 'D:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe' # browser = webdriver.Firefox() # browser.implicitly_wait(5) # # # browser.get("https://safe.jd.com/findPwd/index.action") # time.sleep(1) # # browser.save_screenshot('login.png') #截取当前网页,该网页有我们需要的验证码 # imgelement = browser.find_element_by_class_name("ml10") # 定位验证码 # location = imgelement.location #获取验证码x,y轴坐标 # size = imgelement.size #获取验证码的长宽 # rangle = (int(location['x']), int(location['y']), int(location['x']+size['width']), int(location['y']+size['height'])) #写成我们需要截取的位置坐标 # i = Image.open("login.png") #打开截图 # frame4 = i.crop(rangle) #使用Image的crop函数,从截图中再次截取我们需要的区域 # frame4.save('code.png')