Exemplo n.º 1
0
 def register(self):
     for id, (modifier, key, func) in self.Mapping.items():
         if not func: continue  # 只注册有方法的热键
         if not user32.RegisterHotKey(None, id, modifier, key):
             common.log(
                 30,
                 "热键注册失败!ID: %s, MOD: %s, KEY: %s" % (id, modifier, key))
Exemplo n.º 2
0
    def __init__(self, filename):
        self.filename = filename  # 需要在这里指定子类的文件路径
        self.yaml = YAML()
        self.yaml.default_flow_style = False

        common.log(10, self.filename)
        self.configuration = None
        self.load_config()
Exemplo n.º 3
0
    def pick_next(self):
        if not self.check_active():
            common.log(40, "该配置文件中没有活跃的配置:配置文件:%s" % (self.filename))
            return

        if not self.picked_key: self.pick_item()
        self.cut_weight(self.picked_key)

        picked_key = self.picked_key
        while True:
            prev, cur, next = common.search_index(self.configuration,
                                                  picked_key)
            picked_key = list(self.configuration.keys())[next]
            if self.configuration[picked_key]['active']: break

        self.picked_key = picked_key
        self.add_weight(self.picked_key)
        return self.picked_key
Exemplo n.º 4
0
    def pick_items(self, samples=3, weight=True, switch=True):
        if not self.check_active():
            common.log(40, "该配置文件中没有活跃的配置:配置文件:%s" % (self.filename))
            return

        if samples > len(self.configuration.keys()):
            samples = len(self.configuration.keys())

        tmp = []

        for item in self.configuration:
            name, count, active = item, self.configuration[item][
                "count"], self.configuration[item]["active"]

            if switch == True and active == False: continue  # 判断是否要根据是否激活来取样

            if weight == True: count += 1  # 判断是否将计数作为权重来取样
            else: count = 1

            for i in range(count):  # 按照权重往临时表里增加内容
                tmp.append(name)

        return sample(tmp, samples)
Exemplo n.º 5
0
 def handle(self, id):
     f = self.Mapping[id][2]
     if f: f()
     else: common.log(20, "一个未被注册的热键调用了")
Exemplo n.º 6
0
 def trace_welcome(self):  # 线程开始
     common.log(10, '开始监控' + self.target_name)
Exemplo n.º 7
0
 def trace_shutdown(self):  # 线程结束
     common.log(10, '停止监控' + self.target_name)
Exemplo n.º 8
0
 def __init__(self):
     common.log(10, common.sentences_file)
     super().__init__(common.sentences_file)
Exemplo n.º 9
0
 def __init__(self):
     common.log(10, common.targets_file)
     super().__init__(common.targets_file)
Exemplo n.º 10
0
 def __init__(self):
     common.log(10, common.bombs_file)
     super().__init__(common.bombs_file)
Exemplo n.º 11
0
 def load_config(self):
     with open(self.filename, encoding='utf-8') as f:
         self.configuration = self.yaml.load(f)
         common.log(10, self.configuration)