Beispiel #1
0
def press_key(key_name, num_times=1, duration=0, interval=0):
    for _ in range(num_times):
        press_key_down(key_name)
        if duration > 0 and wc.is_window_foreground():
            time.sleep(duration)
        press_key_up(key_name)
        if interval > 0 and wc.is_window_foreground():
            time.sleep(interval)
def move_mouse_to(x, y, is_global_coords=False):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for mouse event')
        wc.wait_for_window_foreground()
    if not is_global_coords:
        x, y = gwg.local_to_global_coords((x, y))
    pag.moveTo(x, y)
def screenshot(file_name=None, region=None):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for screenshot...')
        wc.wait_for_window_foreground()
    return pag.screenshot(
        imageFilename=file_name, region=region if
        region is not None else gwg.get_game_window_rect())
def locate_in_image(needle, haystack, confidence=0.95):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for image search...')
        wc.wait_for_window_foreground()
    return pag.locate(
        needle, haystack, confidence=confidence,
        region=gwg.get_game_window_rect())
Beispiel #5
0
def press_key_up(key_name):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for key event...')
        wc.wait_for_window_foreground()
    return pag.keyUp(key_name)
Beispiel #6
0
def press_key_down(key_name):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for key event...')
        wc.wait_for_window_foreground()
    pag.keyDown(key_name)
Beispiel #7
0
def press_key_sequence(*keys):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for key event...')
        wc.wait_for_window_foreground()
    pag.hotkey(*keys)
def locate_in_region(img_url, region, confidence=0.95):
    if not wc.is_window_foreground():
        print('waiting for window to be foreground for image search...')
        wc.wait_for_window_foreground()
    return pag.locateOnScreen(
        img_url, region=region, confidence=confidence)