예제 #1
0
 def __init__(self, executable=None, title=None, time_in_seconds=1, repetitions=15, 
     rdescript="unnamed command (SFW)", blocking=False):
     assert executable!=None or title!=None, "SuperFocusWindow needs executable or title"
     def attempt_focus():
         for win in Window.get_all_windows():
             w=win
             found_match=True
             if title!=None:
                 found_match=title in w.title
             if found_match and executable!=None:
                 found_match=executable in w.executable
             if found_match:
                 try:
                     BringApp(w.executable).execute()
                 except Exception:
                     print("Unable to set focus:\ntitle: "+w.title+"\nexe: "+w.executable)
                 break
          
         # do not assume that it worked
         success = SuperFocusWindow.focus_was_success(title, executable)
         if not success:
             if title!=None:
                 print("title failure: ", title, w.title)
             if executable!=None:
                 print("executable failure: ", executable, w.executable, executable in w.executable)
         return success
         
     forward=[L(S(["cancel"], attempt_focus))]
     AsynchronousAction.__init__(self, forward, time_in_seconds=time_in_seconds, repetitions=repetitions, 
                                 rdescript=rdescript, blocking=blocking, 
                                 finisher=Function(lambda message: self.nexus().intermediary.text(message), message="SuperFocus Complete")+Key("escape"))
     self.show = False
예제 #2
0
파일: actions2.py 프로젝트: mrob95/caster
    def __init__(self,
                 base,
                 rspec="default",
                 rdescript="unnamed command (CA)",
                 instructions="instructions missing",
                 nexus=None):
        self.set_nexus(nexus)
        on_complete = AsynchronousAction.hmc_complete(
            lambda data: receive_response(data), self.nexus())
        AsynchronousAction.__init__(
            self, [L(S(["cancel"], on_complete))], 1, 60, rdescript, False
        )  # cannot block, if it does, it'll block its own confirm command

        self.base = base
        self.rspec = rspec
        self.instructions = instructions

        mutable_integer = {"value": 0}

        def receive_response(
            data
        ):  # signals to the stack to cease waiting, return True terminates
            '''
            receives response from homunculus, uses it to
            stop the stack and tell the ConfirmAction how
            to execute
            '''
            mutable_integer["value"] = data["confirm"]

        self.mutable_integer = mutable_integer
예제 #3
0
 def __init__(self, receiver, rspec="default", rdescript="unnamed command (BA)", repetitions=60,
              box_type=settings.QTYPE_DEFAULT, box_settings={}, log_failure=False):
     _ = {"tries": 0}
     self._ = _ # signals to the stack to cease waiting, return True terminates
     def check_for_response():
         try:
             _data = self.nexus().comm.get_com("hmc").get_message()
         except Exception:
             if log_failure: utilities.simple_log()
             _["tries"]+=1
             if _["tries"]>9: return True # try 10 times max if there's no Homonculus response
             else: return False
         if _data is None: return False
         try:
             _data.append(_["dragonfly_data"]) # pass dragonfly data into receiver function
             _["dragonfly_data"] = None
             receiver(_data)
         except Exception:
             if log_failure: utilities.simple_log()
         return True
         
     AsynchronousAction.__init__(self, # cannot block, if it does, it'll block its own confirm command
                                 [L(S(["cancel"], check_for_response, None))], 
                                 1, repetitions, rdescript, False)
     self.rspec = rspec
     self.box_type = box_type
     self.box_settings = box_settings # custom instructions for setting up the tk window ("Homunculus")
     self.log_failure = log_failure
예제 #4
0
    def __init__(self,
                 executable=None,
                 title=None,
                 time_in_seconds=1,
                 repetitions=15,
                 rdescript="unnamed command (SFW)",
                 blocking=False):
        assert executable != None or title != None, "SuperFocusWindow needs executable or title"

        def attempt_focus():
            for win in Window.get_all_windows():
                w = win
                found_match = True
                if title != None:
                    found_match = title in w.title
                if found_match and executable != None:
                    found_match = executable in w.executable
                if found_match:
                    try:
                        # this is still broken
                        win32gui.SetWindowPos(
                            w.handle, win32con.HWND_NOTOPMOST, 0, 0, 0, 0,
                            win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)
                        win32gui.SetWindowPos(
                            w.handle, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                            win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)
                        win32gui.SetWindowPos(
                            w.handle, win32con.HWND_NOTOPMOST, 0, 0, 0, 0,
                            win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE +
                            win32con.SWP_NOSIZE)
                        Key("alt").execute()
                        time.sleep(0.5)
                        win32gui.SetForegroundWindow(w.handle)
                        w.set_foreground()
                    except Exception:
                        utilities.report("Unable to set focus:\ntitle: " +
                                         w.title + "\nexe: " + w.executable)
                    break

            # do not assume that it worked
            success = SuperFocusWindow.focus_was_success(title, executable)
            if not success:
                if title != None:
                    print "title failure: ", title, w.title
                if executable != None:
                    print "executable failure: ", executable, w.executable, executable in w.executable
            return success

        forward = [L(S(["cancel"], attempt_focus))]
        AsynchronousAction.__init__(
            self,
            forward,
            time_in_seconds=time_in_seconds,
            repetitions=repetitions,
            rdescript=rdescript,
            blocking=blocking,
            finisher=Function(control.nexus().intermediary.text,
                              message="SuperFocus Complete") + Key("escape"))
        self.show = False
예제 #5
0
 def __init__(self, base, rspec="default", rdescript="unnamed command (RA)"):
     mutable_integer = {"value": 0}
     def check_response(): # signals to the stack to cease waiting, return True terminates
         return mutable_integer["value"]!=0
     self.mutable_integer = mutable_integer
     AsynchronousAction.__init__(self, 
                                 [L(S(["cancel"], check_response, None))], 
                                 1, 60, rdescript, False)# cannot block, if it does, it'll block its own confirm command
     self.base = base
     self.rspec = rspec
예제 #6
0
    def __init__(self,
                 base,
                 rspec="default",
                 rdescript="unnamed command (RA)"):
        mutable_integer = {"value": 0}

        def check_response(
        ):  # signals to the stack to cease waiting, return True terminates
            return mutable_integer["value"] != 0

        self.mutable_integer = mutable_integer
        AsynchronousAction.__init__(
            self, [L(S(["cancel"], check_response, None))], 1, 60, rdescript,
            False
        )  # cannot block, if it does, it'll block its own confirm command
        self.base = base
        self.rspec = rspec
예제 #7
0
파일: actions2.py 프로젝트: mrob95/caster
    def __init__(self,
                 receiver,
                 rspec="default",
                 rdescript="unnamed command (BA)",
                 repetitions=60,
                 box_type=settings.QTYPE_DEFAULT,
                 box_settings={},
                 log_failure=False):
        _ = {"tries": 0}
        self._ = _  # signals to the stack to cease waiting, return True terminates

        def check_for_response():
            try:
                _data = self.nexus().comm.get_com("hmc").get_message()
            except Exception:
                if log_failure: utilities.simple_log()
                _["tries"] += 1
                if _["tries"] > 9:
                    return True  # try 10 times max if there's no Homonculus response
                else:
                    return False
            if _data is None: return False
            try:
                _data.append(_["dragonfly_data"]
                             )  # pass dragonfly data into receiver function
                _["dragonfly_data"] = None
                receiver(_data)
            except Exception:
                if log_failure: utilities.simple_log()
            return True

        AsynchronousAction.__init__(
            self,  # cannot block, if it does, it'll block its own confirm command
            [L(S(["cancel"], check_for_response))],
            1,
            repetitions,
            rdescript,
            blocking=False)
        self.rspec = rspec
        self.box_type = box_type
        self.box_settings = box_settings  # custom instructions for setting up the tk window ("Homunculus")
        self.log_failure = log_failure
예제 #8
0
 def __init__(self, base, rspec="default", rdescript="unnamed command (CA)", instructions="instructions missing", nexus=None):
     self.set_nexus(nexus)
     on_complete = AsynchronousAction.hmc_complete(lambda data: receive_response(data), self.nexus())
     AsynchronousAction.__init__(self, 
                                 [L(S(["cancel"], on_complete, None))], 
                                 1, 60, rdescript, False)# cannot block, if it does, it'll block its own confirm command
     
     self.base = base
     self.rspec = rspec
     self.instructions = instructions
     
     
     mutable_integer = {"value": 0}
     def receive_response(data): # signals to the stack to cease waiting, return True terminates
         '''
         receives response from homunculus, uses it to
         stop the stack and tell the ConfirmAction how
         to execute
         '''
         mutable_integer["value"] = data["confirm"]
     self.mutable_integer = mutable_integer
예제 #9
0
 def __init__(self, executable=None, title=None, time_in_seconds=1, repetitions=15, 
     rdescript="unnamed command (SFW)", blocking=False):
     assert executable!=None or title!=None, "SuperFocusWindow needs executable or title"
     def attempt_focus():
         for win in Window.get_all_windows():
             w=win
             found_match=True
             if title!=None:
                 found_match=title in w.title
             if found_match and executable!=None:
                 found_match=executable in w.executable
             if found_match:
                 try:
                     # this is still broken
                     win32gui.SetWindowPos(w.handle,win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)  
                     win32gui.SetWindowPos(w.handle,win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)  
                     win32gui.SetWindowPos(w.handle,win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)
                     Key("alt").execute()
                     time.sleep(0.5)
                     win32gui.SetForegroundWindow(w.handle)
                     w.set_foreground()
                 except Exception:
                     utilities.report("Unable to set focus:\ntitle: "+w.title+"\nexe: "+w.executable)
                 break
          
         # do not assume that it worked
         success = SuperFocusWindow.focus_was_success(title, executable)
         if not success:
             if title!=None:
                 print "title failure: ", title, w.title
             if executable!=None:
                 print "executable failure: ", executable, w.executable, executable in w.executable
         return success
         
     forward=[L(S(["cancel"], attempt_focus))]
     AsynchronousAction.__init__(self, forward, time_in_seconds=time_in_seconds, repetitions=repetitions, 
                                 rdescript=rdescript, blocking=blocking, 
                                 finisher=Function(control.nexus().intermediary.text, message="SuperFocus Complete")+Key("escape"))
     self.show = False
     
예제 #10
0
파일: actions2.py 프로젝트: carver7/caster
 def __init__(self, action, t=3):
     AsynchronousAction.__init__(self, [L(S(["cancel"], action))], t, 100, "UC", False, None)
     self.show = True
예제 #11
0
파일: actions2.py 프로젝트: mrob95/caster
 def __init__(self, action, t=3):
     AsynchronousAction.__init__(self, [L(S(["cancel"], action))], t, 100,
                                 "UC", False, None)
     self.show = True