Exemplo n.º 1
0
def getActive():
    global state
    global current_active
    tittle = gw.getActiveWindowTitle()
    keyword = "osu!"
    keyword_full = "osu!  - "
    if keyword in str(tittle):
        if keyword_full in str(tittle):
            if ".osu" in str(tittle):
                state = tittle.replace("osu!  - ", "").replace(".osu", "")
                current_active = "edit"
            else:
                state = tittle.replace("osu!  - ", "")
                current_active = "play"
        else:
            state = "Idle"
        if state == "osu!":
            state = "Idle"
        elif "watching" in state:
            specname = tittle.replace("osu!  -  (watching ", "").replace(")", "")
            state = f"Spectating {specname}"
            current_active = "spectate"
    else:
        state = "AFK"
    return state, current_active
Exemplo n.º 2
0
def getActive():
    global state
    global active
    title = gw.getActiveWindowTitle()
    keyword = "osu!"
    keyword_full = "osu!  - "
    if keyword in str(title):
        if keyword_full in str(title):
            if ".osu" in str(title):
                state = title.replace("osu!  - ", "").replace(".osu", "")
                active = "Editing beatmap"
            else:
                state = title.replace("osu!  - ", "")
                active = "Playing"
        else:
            state = "Idle"
        if state == "osu!":
            state = "Idle"
        elif "watching" in state:
            specname = title.replace("osu!  -  (watching ", "").replace(")", "")
            state = f"Spectating {specname}"
            active = "Spectating"
    else:
        state = "AFK"
    return state, active
Exemplo n.º 3
0
def on_release(key):
    # print('{0} release'.format(key))
    logger.info("Key: {} {}".format(key, pygetwindow.getActiveWindowTitle().replace(' ', '')))
    
    if key == Key.esc:
        # Stop listener
        k_listener.stop()
        m_listener.stop()
        make_html()
Exemplo n.º 4
0
 def usingBrowser(self, browser=None):
     if browser == None:
         browser = self.activeBrowser()
         if browser == None:
             return False
     windows = gw.getActiveWindowTitle().split(" ")
     if browser in windows:
         return True
     else:
         return False
Exemplo n.º 5
0
 def activeBrowser(self):
     while True:
         try:
             windows = gw.getActiveWindowTitle().split(" ")
             break
         except:
             pass
     for i in windows:
         if i in browser_list:
             browser = i
             return browser
Exemplo n.º 6
0
    def resetPlane(self):
        current_window = gw.getWindowsWithTitle(gw.getActiveWindowTitle())[0]
        xplane_window = gw.getWindowsWithTitle("X-System")[0]
        sleep(0.01)
        xplane_window.activate()
        sleep(0.01)
        key.ResetXPlane()
        sleep(0.01)
        current_window.activate()

        # Re-apply landing gear switch
        self.sendDREF("sim/cockpit2/controls/gear_handle_down", 1)
        self.sendDREF("sim/cockpit/switches/gear_handle_status", 1)
        self.sendDREF("sim/cockpit2/controls/parking_brake_ratio", 0)
        # Reset time to 10:00 (32400.0)
        self.sendDREF("sim/time/zulu_time/sec", 32400.0)
        sleep(1)
        self.sendVIEW(ViewType.Chase)
        self.pauseSim(False)
def pick_move(board, time_left_on_clock):
    """
    takes in a chess.Board
    as well as time_left_on_clock in seconds
    returns a chess.Move
    """

    mouse_was_down = False

    while True:
        if win.getActiveWindowTitle() == "Engine Battles":
            window = win.getActiveWindow()
            if window is not None:
                fs = (window.height - 39) // 8

                mx, my = mouse.get_position()
                wx, wy = window.left, window.top

                x = mx - wx - 8
                y = my - wy - 31

                file = x // fs
                rank = y // fs

                if mouse.is_pressed():
                    if not mouse_was_down:
                        if 0 <= rank < 8 and 0 <= file < 8:
                            start = f"{'abcdefgh'[file]}{8-rank}"


#                            print("down:", start)
                        mouse_was_down = True
                else:
                    if mouse_was_down:
                        if 0 <= rank < 8 and 0 <= file < 8:
                            end = f"{'abcdefgh'[file]}{8-rank}"
                            #                            print("up:", end)
                            if start != end:
                                move = chess.Move.from_uci(start + end)
                                if board.is_legal(move):
                                    return move
                        mouse_was_down = False
Exemplo n.º 8
0
def click(x, y, button, pressed):
    if pressed:
        # print(x, y, button)
        logger.info("Mouse: {} {} {} {}".format(x, y, button, pygetwindow.getActiveWindowTitle().replace(' ', '')))
Exemplo n.º 9
0
def active_window():
    return gw.getActiveWindowTitle()
Exemplo n.º 10
0
    def send_action(self, action) -> None:

        if gw.getActiveWindowTitle() != self.app_name:
            pass

        keyboard.press(action)