Esempio n. 1
0
    def __init__(self, parent=None):
        super(Ui_MainWindow, self).__init__(parent)
        self.is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
        self.tray_icon = QSystemTrayIcon(self)
        self.settings_file = {}
        # will  be used for setting hot keysvisu
        self.firewall_active = False
        self.hold_control = False
        #  will be used to set up hot keys to turn on and off firewall

        self.ip_address_scope = ""

        self.setupUi()

        self.firewall_status()

        self.setupTrayIcon()
        self.set_up_help_window()

        self.hot_keys = self.get_hot_keys()

        self.hot_keys_setup = GlobalHotKeys(self.hot_keys)
        self.hot_keys_setup.start()

        if not self.is_admin:
            self.notAdmin()
Esempio n. 2
0
 def __init__(self, selector):
     self.selector = selector
     self.started = False
     self.key_listener = Listener(self.on_key_press)
     self.hotkey_listener = GlobalHotKeys({
         '<ctrl>+d': self.on_ctrl_d_press,
         '<ctrl>+f': self.on_ctrl_f_press
     })
Esempio n. 3
0
    def update_global_hot_key(self):

        if self.hot_keys_setup.is_alive():

            self.hot_keys_setup.stop()

            self.hot_keys_setup = GlobalHotKeys(self.get_hot_keys())
            self.hot_keys_setup.start()
Esempio n. 4
0
    def _create_bindings(mapping, ctrl):
        """
        Create hotkey bindings from the mapping to the controller actions.

        Args:
            mapping a dictionary with the key as the hotkey combination and the
            value as the controller action.
        """
        mapdict = {
            k: HotKeyHandler.get_function(ctrl, v) for k, v in mapping.items()}
        ghk = GlobalHotKeys(mapdict)
        ghk.start()
Esempio n. 5
0
    def test_hotkeys(self):
        q = queue.Queue()

        with GlobalHotKeys({
                '<ctrl>+<shift>+a': lambda: q.put('a'),
                '<ctrl>+<shift>+b': lambda: q.put('b'),
                '<ctrl>+<shift>+c': lambda: q.put('c')}):
            notify('Press <ctrl>+<shift>+a')
            self.assertEqual('a', q.get())

            notify('Press <ctrl>+<shift>+b')
            self.assertEqual('b', q.get())

            notify('Press <ctrl>+<shift>+c')
            self.assertEqual('c', q.get())
Esempio n. 6
0
    def hotkeyInit(self):
        cl = Helpers()
        notification.notify(
            title="Assistant ready.",
            message="<i>Press hotkey to activate voice recognition.</i>",
            app_icon=defIcon,
            timeout=3,
        )

        try:
            with GlobalHotKeys({
                    actKey: cl.on_activate_act,
                    escKey: cl.on_activate_esc
            }) as h:
                h.join()
        except TypeError:
            # Tidy up (kill leftover procs, exit)
            cl.kill_proc()
            sys.exit(0)
Esempio n. 7
0
    def stop_pressing(self):
        print("stop pressing")
        self.running = False

    def exit(self):
        self.stop_pressing()
        self.program_running = False

    def run(self):
        while self.program_running:
            while self.running:
                time.sleep(self.delay)
                keyboard.press(Key.cmd)
                keyboard.press("\\")
                keyboard.release(Key.cmd)
                keyboard.release("\\")
            time.sleep(0.1)


keyboard = Controller()
press_thread = HotkeyClick(delay)
press_thread.start()

# start: option + shift + ]
# stop: option + shift + [
with GlobalHotKeys({
        '’': press_thread.start_pressing,
        '”': press_thread.stop_pressing
}) as h:
    h.join()
Esempio n. 8
0
                sys.exit()

        for i in currency_number_copy.keys():
            # 用过的数量 = 原来的数量 - 剩余的数量
            currency_number_copy[i] -= currency_number[i]
        used_chaos = float(
            currency_number_copy['chaos']) * chaos_chaos + float(
                currency_number_copy['scouring']) * scouring_chaos + float(
                    currency_number_copy['transmutation']
                ) * transmutation_chaos + float(
                    currency_number_copy['alc']) * alc_chaos + float(
                        currency_number_copy['aug']) * aug_chaos + float(
                            currency_number_copy['alt']) * alt_chaos + float(
                                currency_number_copy['reg']) * reg_chaos
        print('此装备使用了' + str(currency_number_copy) + '约使用了' + str(used_chaos) +
              '混沌石')
        # print('剩余' + str(currency_number))
        # 通货基准值重定义
        currency_number_copy = currency_number.copy()


if __name__ == '__main__':
    # 直接绑定快捷键
    with GlobalHotKeys({
            '<alt>+1': get_screenpoint,
            '<alt>+2': get_item_location,
            '<alt>+3': make_gear,
            '<alt>+q': exit_sys
    }) as h:
        h.join()
Esempio n. 9
0
        T.insert(END, ''.join(WholeString))
        print(float(str(indexOf) + "." + str(TempIndex2-1)))
        print(''.join(WholeString))
        T.delete(1.0, float(str(indexOf+1) + "." + str(TempIndex2)))
        TheFile.write(''.join(WholeString))
        TheFile.close()


 
def on_release(key):
    global WholeString, COMBINATION
    '''if key in COMBINATION:
        sleep(0.3)
        current.remove(key)
        try:
            T.delete(1.0, END)
        except:
            pass
        T.insert(END, current)'''

listener = Listener(on_press=on_press, on_release=on_release)
listener.start()


def on_activate_o():
    openFile("")

ctrlO = GlobalHotKeys({'<ctrl>+o': on_activate_o})
ctrlO.start()

root.mainloop()
Esempio n. 10
0
        def inner(*args, **kargs):

            GlobalHotKeys({hotkey: func})
    main_function(DASHOTKEY3)

def transfer_function4():
    main_function(DASHOTKEY4)

def transfer_function5():
    main_function(DASHOTKEY5)

# Assign Python hotkeys to DAS script hotkeys
HOTKEY1 = "<F1>"
HOTKEY2 = "<F2>"
HOTKEY3 = "<F3>"
HOTKEY4 = "<F4>"
HOTKEY5 = "<F5>"

DASHOTKEY1 = Key.f1
DASHOTKEY2 = Key.f2
DASHOTKEY3 = Key.f3
DASHOTKEY4 = Key.f4
DASHOTKEY5 = Key.f5

with GlobalHotKeys({
        HOTKEY1 : transfer_function1,
        HOTKEY2 : transfer_function2,
        HOTKEY3 : transfer_function3,
        HOTKEY4 : transfer_function4,
        HOTKEY5 : transfer_function5}) as MappedResult:
    MappedResult.join()

# TODO 
# Reduce copipaste in the code somehow
Esempio n. 12
0
def hotkey_listen():
    with GlobalHotKeys({'<ctrl>+<alt>+t': on_activate_t}) as hot:
        hot.join()
Esempio n. 13
0
def Check_Availability():
    if not path.exists(fileLocation):
        f = open(fileLocation, "w")
        f.close()
        firstList = ['key', 'keydown_time', 'keyup_time', 'fatigue level']
        thread1 = threading.Thread(target=Writer.Write().write_file,
                                   args=(
                                       firstList,
                                       fileLocation,
                                   ))
        thread1.start()


KeyboardListner = Listener(on_press=on_press, on_release=on_release)
HotKeyListner = GlobalHotKeys({
    '<ctrl>+<alt>+h': on_Pause,
    '<ctrl>+<alt>+i': on_Resume
})


def startPopup():
    threading.Thread(target=PopUI.PopUIStarter,
                     args=('PopUIThread', queue)).start()


def starter():
    startPopup()
    KeyboardListner.start()
    HotKeyListner.start()
    KeyboardListner.join()
    HotKeyListner.join()