-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_i_view32.py
54 lines (46 loc) · 1.51 KB
/
_i_view32.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Rules only active when IrfanView is the foreground window should be placed in a file named i_view32.py.
This is for rules that use IrfanView at other times, such as when IrfanView is not open at all.
"""
print "importing " + __file__
from dragonfly import *
import Base
import inspect
import paths
from chajLib.ui import keyboard as kb
grammar = Base.ContinuousGrammar("supplementary always on irfan view grammar")
#decorator
def GrammarRule(rule):
if inspect.isclass(rule):
if issubclass(rule, Base.BaseQuickRules):
rule(grammar)
else:
grammar.add_rule(rule())
else:
grammar.add_rule(rule)
@GrammarRule
class FullScreenToIrfanView(Base.ContinuousRule):
spec = "screen to image"
def _process_recognition(self, node, extras):
kb.sendPrintScreen()
action = StartApp(paths.IRFANVIEW_PATH) + Pause("50") + Key("c-v")
action.execute()
@GrammarRule
class WindowToIrfanView(Base.ContinuousRule):
spec = "window to image"
def _process_recognition(self, node, extras):
kb.sendAltPrintScreen()
action = StartApp(paths.IRFANVIEW_PATH) + Pause("50") + Key("c-v")
action.execute()
@GrammarRule
class ClipboardToIrfanView(Base.ContinuousRule):
spec = "clipboard to image"
def _process_recognition(self, node, extras):
action = StartApp(paths.IRFANVIEW_PATH) + Pause("50") + Key("c-v")
action.execute()
grammar.load()
def unload():
global grammar
if grammar:
grammar.unload()
grammar = None