-
Notifications
You must be signed in to change notification settings - Fork 3
/
_print_windows.py
34 lines (23 loc) · 1.04 KB
/
_print_windows.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# import pydevd_pycharm
# pydevd_pycharm.settrace('localhost', port=8282, stdoutToServer=True, stderrToServer=True)
from dragonfly import CompoundRule, Grammar, Window
from supporting import utils
class PrintWindowsRule(CompoundRule):
spec = "print [all] Windows" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
windows = Window.get_all_windows()
#windows.sort(key=lambda x: x.executable)
for window in windows:
if utils.windowIsValid(window):
print "{:7} : {:75} : {}".format(window.handle, window.executable.encode("utf-8"), window.title.encode("utf-8"))
# window.executable.lower()
# window.title.lower()
# window.is_visible
# window.name
# window.classname
print_windows_grammar = Grammar("print windows according to Python")
print_windows_grammar.add_rule(PrintWindowsRule())
print_windows_grammar.load()
def unload():
global print_windows_grammar
print_windows_grammar = utils.unloadHelper(print_windows_grammar, __name__)