예제 #1
0
def test_activate():
    orig = Window.get_active()
    win, xfontsel = get_win('xfontsel', '-geometry', '+0+0')
    win.activate()
    time.sleep(0.5)
    active = Window.get_active()
    assert active.id == win.id
    orig.activate()
    time.sleep(0.5)
    active = Window.get_active()
    assert active.id == orig.id
예제 #2
0
파일: snap.py 프로젝트: sme3863/snapPy
	def __get_active_window(self): 
		try:
			window = Window.get_active()
			return window
		except ValueError:
			#catching Error in the wmctrl function list(), still holding already closed windows
			return None
예제 #3
0
def reposition_window():
    wins = Window.by_name_endswith('Widget vodafone.it')
    assert len(wins) == 1
    win = wins[0]
    win.resize_and_move(0, 0, win.w, win.h)
    win.activate()
    return win
예제 #4
0
파일: util.py 프로젝트: nnist/i3-resurrect
def windows_in_workspace(workspace):
    """
    Generator to iterate over windows in a workspace.

    Args:
        workspace: The name of the workspace whose windows to iterate over.
    """
    ws = get_workspace_tree(workspace)
    for con in windows_in_container(ws):
        # Get information on the window.
        try:
            window = Window.by_id(con['window'])[0]
        except ValueError as e:
            eprint(str(e))
            continue

        # Pre-emptively attempt to catch error
        try:
            window
        except NameError as e:
            eprint(str(e))
            continue

        if not window:
            continue

        yield (con, window)
예제 #5
0
파일: snap.py 프로젝트: sme3863/snapPy
def run_analysis():
	try:
		print("run in maximized window to get values for screen width and height")
		window = Window.get_active()
		return window.w, window.h
	except ValueError:
		#catching Error in the wmctrl function list(), still holding already closed windows
		return None
예제 #6
0
def check_geometry(geom):
    win, xclock = get_win('xclock', '-geometry', geom)
    win.resize_and_move(0, 0, 100, 200)
    win.set_geometry(geom)
    win2 = Window.by_name(xclock.NAME)[0]
    assert win2.x == win.x
    assert win2.y == win.y
    assert win2.w == win.w
    assert win2.h == win.h
예제 #7
0
def main_laptop():
    for win in Window.by_class('emacs.Emacs'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=526, y=0, w=2036, h=1300)

    for win in Window.by_role('autoterm'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=526, y=0, w=2036, h=1460)

    for win in Window.by_class('mail.google.com.Google-chrome'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=PANEL, y=0, w=1428, h=1440)

    for win in Window.by_class('web.whatsapp.com.Google-chrome'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=PANEL, y=0, w=1428, h=900)

    for win in Window.by_class(TELEGRAM):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=PANEL, y=200, w=1428, h=700)

    mattermost_class = 'mattermost.smithersbet.com.Google-chrome'  # chrome webapp
    #mattermost_class = 'mattermost.Mattermost' # native app
    for win in Window.by_class(mattermost_class):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=PANEL, y=0, w=1428, h=956)

    for win in Window.by_class('hexchat.Hexchat'):
        unmaximize(win)
        win.set_decorations(False)
        win.sticky()
        win.resize_and_move(x=PANEL, y=1440 - 960, w=1428, h=960)
        set_hexchat_font(13)

    for win in Window.by_class('google-chrome.Google-chrome'):
        # position this at the center of the main screen
        W = 1800
        X = PANEL + (2560 - W - PANEL) / 2
        win.resize_and_move(x=X, y=0, w=W, h=1440)

    for win in Window.by_class('conky.conky'):
        win.sticky()
예제 #8
0
def test_resize_and_move():
    win, xclock = get_win('xclock', '-geometry', '+100+200')
    ofs_x = win.x
    ofs_y = win.y
    win.resize_and_move(10, 20, 130, 140)
    win2 = Window.by_name(xclock.NAME)[0]
    assert win.id == win2.id
    # FIXME: these don't really work, see the XXX inside resize_and_move
    ## assert win2.x == 10 + ofs_x
    ## assert win2.y == 20 + ofs_y
    assert win2.w == 130
    assert win2.h == 140
예제 #9
0
파일: snap.py 프로젝트: sme3863/snapPy
	def __remove_closed_windows(self):
		try:
			windows = Window.list()
			open_windows = []
			for window in windows:
				open_windows.append(window[0])
			for key in self.original_window_sizes.keys():
				if key not in open_windows:
					self.__remove_window(key)
		except ValueError:
			#catching Error in the wmctrl function list(), still holding already closed windows
			pass
예제 #10
0
def main_dock():
    X0 = 0  # x position of the leftmost screen
    X1 = 1440  # x position of the center screen
    X2 = X1 + 3840  # x position of the rightmost screen

    for win in Window.by_class('emacs.Emacs'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=X1 + 1806, y=0, w=2036, h=1900)

    for win in Window.by_role('autoterm'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=X1 + 1809, y=0, w=2036, h=2160)

    for win in Window.by_class('mail.google.com.Google-chrome'):
        unmaximize(win)
        win.resize_and_move(x=1440 + 64, y=0, w=1740, h=1803)

    for win in Window.by_class('web.whatsapp.com.Google-chrome'):
        unmaximize(win)
        win.resize_and_move(x=0, y=0, w=1428, h=1200)
        win.sticky()

    for win in Window.by_class(TELEGRAM):
        unmaximize(win)
        win.resize_and_move(x=0, y=1288, w=1440, h=1000)
        win.sticky()

    mattermost_class = 'mattermost.smithersbet.com.Google-chrome'  # chrome webapp
    #mattermost_class = 'mattermost.Mattermost' # native app
    for win in Window.by_class(mattermost_class):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=X2, y=0, w=1080, h=956)
        win.sticky()

    for win in Window.by_class('hexchat.Hexchat'):
        unmaximize(win)
        win.set_decorations(False)
        win.resize_and_move(x=X2, y=960, w=1080, h=960)
        win.sticky()
        set_hexchat_font(9)

    for win in Window.by_class('google-chrome.Google-chrome'):
        # position this at the center of the main screen
        W = 2000
        X = X1 + PANEL + (3840 - 2000 - PANEL) / 2
        win.resize_and_move(x=X, y=0, w=W, h=2000)
예제 #11
0
 def recalled(self):
     if not os.path.isfile(self.rrun_file):
         return
     try:
         window_id_hex = readfile(self.rrun_file)
         if window_id_hex.startswith('run'):
             return True  # but we can't switch to the running window
         im_running = Window.by_id(int(window_id_hex, 16))
     except Exception as e:
         print e  ###
         return
     if im_running:
         writefile(self.rrun_file, 'run baby')
         im_running[0].activate()
         return True
예제 #12
0
def test_properties():
    def get_geometry(w):
        return (w.x, w.y, w.w, w.h)

    #
    w1, xclock = get_win('xclock')
    assert 'maximized_vert' not in w1.wm_state
    assert 'maximized_horz' not in w1.wm_state
    w1.set_properties(("toggle", "maximized_vert", "maximized_horz"))
    #
    # get a new instance of w1, to re-read the wm_state
    w2 = Window.by_id(int(w1.id, 16))[0]
    assert not (get_geometry(w1) == get_geometry(w2))
    assert 'maximized_vert' in w2.wm_state
    assert 'maximized_horz' in w2.wm_state
예제 #13
0
def test_Desktop_active():
    desktop = Desktop.get_active()
    win = Window.get_active()
    assert win.desktop == desktop.num
예제 #14
0
파일: gui.py 프로젝트: rezen/zap-recorder
import os.path
import time
import pyautogui
from subprocess import call
from wmctrl import Window

for win in Window.list():
    print(win)

# For ubuntu 16
# zap_main = Window.by_class('sun-awt-X11-XFramePeer.OWASP')[0]
zap_main = Window.by_class('OWASP')[0]
zap_main.set_properties(['add', 'maximized_vert', 'maximized_horz'])

pyautogui.screenshot('output/shot.png')

screenWidth, screenHeight = pyautogui.size()
currentMouseX, currentMouseY = pyautogui.position()
# pyautogui.moveRel(None, 10)  # move mouse 10 pixels down
# pyautogui.doubleClick()

# Mac force to start
# pyautogui.hotkey('command', 'space')
# pyautogui.typewrite('OWASP ZAP', interval=0.01)
# pyautogui.press('enter')

# Quick launch
pyautogui.moveTo(890, 94, duration=0.6)
pyautogui.click()
time.sleep(4)
pyautogui.hotkey('esc')
예제 #15
0
def main_emergency():
    for win in Window.list():
        if win.wm_class != 'plasmashell.plasmashell':
            win.move(0, 0)
예제 #16
0
def getStrings():
    stdscr.clear()
    windows = W.list()
    keys = ["f", "j", "d", "k", "s", "l", "a"]  # keys to chose the window
    keyComb = []  # generate a key Combination for each window
    if (len(keys) < len(windows)):
        count = 0
        isBreak = False
        for i in keys:
            for j in keys:
                if (count == len(windows)):
                    break
                    isBreak = True
                keyComb.append(i + j)
                count += 1
            if isBreak:
                break
    else:
        keyComb = keys[0:len(windows)]
    actice = W.get_active()  # dont show this program
    count = 0
    for win in windows:
        if win == actice:
            del windows[count]
            break
        count += 1
    windowNames = []  # get the correct name for programs in terminals
    for win in windows:
        name = win.wm_name
        pids = [win.pid]
        if (name == "termite"):  # TODO make it portable for other terminals
            pids = psutil.Process(pids[0]).children()
            if (len(pids) > 0):
                name = pids[0].name()
                if (name == "zsh"):  # TODO make it portable for other shells
                    pids = pids[0].children()
                    if (len(pids) > 0):
                        name = pids[0].name()
        windowNames.append(name)
    ws = [x.desktop for x in windows]
    windowNumber = [0] * (max(ws) + 1)
    for i in (ws):
        windowNumber[i] += 1
    count = 0
    countL = 0
    countWs = 0
    for i in windowNumber:  # print the lines
        if (i % 2 == 0):
            middle = (i / 2)
        else:
            middle = ((i + 1) / 2)
        for j in range(i):
            if (j == middle - 1):
                stdscr.addstr(
                    countL, 0,
                    str(countWs) + "| [" + keyComb[count] + "]: " +
                    windowNames[count])
            else:
                stdscr.addstr(
                    countL, 0,
                    " | [" + keyComb[count] + "]: " + windowNames[count])
            count += 1
            countL += 1
        if (i != 0):
            countL += 1  # print a empty line between workspaces
        countWs += 1
    stdscr.refresh()
    return keyComb, [x.id for x in windows], ws
예제 #17
0
 def save_my_window_id(self, rrun_file):
     writefile(rrun_file, Window.get_active().id)
예제 #18
0
 def move(self):
     if Window.get_active().id != MAIN_WINDOW.id:
         print >> sys.stderr, 'Lost focus, exiting'
         sys.exit(1)
     autopy.mouse.move(*self)
예제 #19
0
def test_list():
    xclock = Apps.get_xclock()
    wins = Window.list()
    names = [win.wm_name for win in wins]
    assert xclock.NAME in names
예제 #20
0
def get_win(name, *args):
    get_app = getattr(Apps, 'get_%s' % name)
    xapp = get_app(*args)
    win = Window.by_name(get_app.NAME)
    return win[0], xapp
예제 #21
0
#!/usr/bin/env python

import os
from wmctrl import Window


def unmaximize(win):
    return
    win.set_properties(['remove', 'maximized_vert', 'maximized_horz'])


WHATSAPP = Window.by_class('web.whatsapp.com.Google-chrome')[0]
TELEGRAM = Window.by_class('Telegram.TelegramDesktop')[0]


def tg():
    WHATSAPP.resize_and_move(x=0, y=0)
    TELEGRAM.resize_and_move(x=0, y=230)
    TELEGRAM.activate()


def wa():
    WHATSAPP.resize_and_move(x=0, y=230)
    WHATSAPP.activate()
    TELEGRAM.resize_and_move(x=0, y=0)


def tg():
    import gtk.gdk
    whatsapp = gtk.gdk.window_foreign_new(int(WHATSAPP.id, 16))
    telegram = gtk.gdk.window_foreign_new(int(TELEGRAM.id, 16))
예제 #22
0
파일: start.py 프로젝트: phgrey/splitter
 def __init__(self):
     self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
     self.window.show()
     print Window.list()
     self.window.connect("delete_event", self.delete_event)
     self.window.connect("destroy", self.destroy)