Example #1
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    print("Press Ctrl+Shift+A any where. Ctrl+Shift+E exits the app.")

    # Setup a global keyboard shortcut to print "Hello World" on pressing
    # the shortcut
    keybinder.init()

    def callback():
        print("hello world")
    def exit_app():
        window.close()
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+E", exit_app)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    app.exec_()
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+E")
Example #2
0
    def run(self):
        '''运行并显示窗口'''
        self.mainWindow.move(*self._position)
        # 输入结束信号连接run槽
        self.ui.lineEdit.editingFinished.connect(self.call_action)
        # 重写keyPressEvent
        self.ui.lineEdit.keyPressEvent = self.keypressevent(
            self.ui.lineEdit.keyPressEvent)
        # 去除顶栏 和 一直在顶部
        self.mainWindow.setWindowFlags(QtCore.Qt.FramelessWindowHint
                                       | QtCore.Qt.WindowStaysOnTopHint)

        self._getconfig()
        self._loadconfig()
        self._writeconfig()

        pyperclip.determine_clipboard()
        keybinder.init()
        keybinder.register_hotkey(self.mainWindow.winId(), "Shift+Ctrl+A",
                                  self.callback)
        keybinder.register_hotkey(self.mainWindow.winId(), "Shift+Ctrl+E",
                                  self.mainWindow.close)

        win_event_filter = WinEventFilter(keybinder)
        event_dispatcher = QtCore.QAbstractEventDispatcher.instance()
        event_dispatcher.installNativeEventFilter(win_event_filter)

        sys.exit(self.app.exec_())
        keybinder.unregister_hotkey(self.mainWindow.winId(), "Shift+Ctrl+A")
        keybinder.unregister_hotkey(self.mainWindow.winId(), "Shift+Ctrl+F")
Example #3
0
    def __init__(self):
        sys.excepthook = self.excepthook
        self.app = QApplication([])
        self.app.setQuitOnLastWindowClosed(False)
        self.icon = QIcon("./src/favicon.ico")

        self.tray = QSystemTrayIcon()
        self.tray.setIcon(self.icon)
        self.tray.setVisible(True)
        self.tray.messageClicked.connect(lambda *args: print(args))

        self.menu = QMenu()
        self._actions = []
        quit = QAction("Quit")
        quit.triggered.connect(self.app.quit)
        self._actions.append(quit)
        # self.menu.addAction(quit)
        self.tray.setContextMenu(self.menu)

        keybinder.init()
        self.win_event_filter = WinEventFilter(keybinder)
        self.event_dispatcher = QAbstractEventDispatcher.instance()
        self.event_dispatcher.installNativeEventFilter(self.win_event_filter)

        handler.on(GEvents.on_make_toast, self.on_make_toast)
Example #4
0
def main():
    default_settings = {
        "window_height": "all",  # all, half
        "result_format": "latex",  # latex, word
        "use_dev_api": False,
        "shot_hot_key": "Alt+D",
        "ocr_hot_key": "Alt+S",
        "link": "",  # "",
        "account": "",  # 手机号或者开发者账号
        "passwd": ""  # 动态密码或者开发者密码
    }
    welcom_msg = '''
    Pacoo 公式识别桌面版
    【在 2020.10.31 下载使用本软件可向客服(微信号:pacoo1614)领取66次免费识别次数。】
    
    使用说明:
    1. 按下快捷键:Alt+D
    2. 框出要识别的公式
    3. 在需要插入公式的地方粘贴
    '''
    print(welcom_msg)
    op.play_sound("welcome")
    try:
        homeDir = os.path.expanduser("~")
        with open(homeDir + "\\pacoo.conf", "r") as f:
            settings = json.load(f)
    except:
        settings = default_settings
    app = QApplication(sys.argv)
    window = MyWin(settings)

    keybinder.init()
    unregistered = False

    def callback():
        print("hello world")

    def start_oct():
        window.click_btn()

    def exit_app():
        window.close()

    def unregister():
        keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
        print("unregister and register previous binding")
        keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)

    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)
    keybinder.register_hotkey(window.winId(), "Alt+D", start_oct)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    sys.exit(app.exec_())
Example #5
0
def main():
    app = QApplication(sys.argv)
    keybinder.init()
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
Example #6
0
    def setup_shortcuts(self):
        # self.translate_shortcut = QtWidgets.QShortcut(
        #     QtGui.QKeySequence('Ctrl+D'),
        #     self.main_window
        # )
        # self.translate_shortcut.activated.connect(lambda: self.click_translate())

        # shortcut when not focus
        keybinder.init()
        keybinder.register_hotkey(self.main_window.winId(), 'Ctrl+D',
                                  self.translate_selected_text)
        self.win_event_filter = WinEventFilter(keybinder)
        self.event_dispatcher = QtCore.QAbstractEventDispatcher.instance()
        self.event_dispatcher.installNativeEventFilter(self.win_event_filter)
Example #7
0
    def create_shortcut_connections(self):
        keybinder.init()
        # Are certain keys impossible to shortcut with pyqtkeybind
        # keybinder.register_hotkey(self.winId(), "MediaTogglePlayPause", self.music_control_box.toggle_play_pause)
        # keybinder.register_hotkey(self.winId(), "MediaPlay", self.music_control_box.play_button.plb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaPause", self.music_control_box.pause_button.pb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaNext", self.music_control_box.next_button.nb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaPrevious", self.music_control_box.previous_button.prb_clicked)
        # keybinder.register_hotkey(self.winId(), "MediaStop", self.music_control_box.stop_button.sb_clicked)

        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Home", self.music_control_box.toggle_play_pause)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Up", self.music_control_box.volume_slider.increase_volume)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Down", self.music_control_box.volume_slider.decrease_volume)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Right", self.music_control_box.next_button.nb_clicked)
        keybinder.register_hotkey(self.winId(), "Ctrl+Alt+Left", self.music_control_box.previous_button.prb_clicked)

        self.win_event_filter = util.WinEventFilter(keybinder)
        self.event_dispatcher = QAbstractEventDispatcher.instance()
        self.event_dispatcher.installNativeEventFilter(self.win_event_filter)
Example #8
0
def main() -> None:
    import sys

    app = QApplication(sys.argv)
    screen_count = QDesktopWidget().screenCount()

    info_app = InfoPad(screen_count)

    # Register hotkeys
    keybinder.init()
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F13", info_app.grid_sd)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F14", info_app.grid_su)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F15", info_app.grid_9)

    keybinder.register_hotkey(info_app.winId(), "Ctrl+F16", info_app.grid_1)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F17", info_app.grid_2)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F18", info_app.grid_3)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F19", info_app.grid_4)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F20", info_app.grid_5)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F21", info_app.grid_6)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F22", info_app.grid_7)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+F23", info_app.grid_8)

    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F13", info_app.grid_home)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F14", info_app.grid_mm)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F15", info_app.grid_ou)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F16", info_app.grid_od)
    keybinder.register_hotkey(info_app.winId(), "Ctrl+Alt+F17", info_app.grid_view_o)

    # Install native event filter
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    # If three monitors detected, move window to thirds screen and make it fullscreen
    if screen_count == 3:
        monitor = QDesktopWidget().screenGeometry(2)
        info_app.move(monitor.left(), monitor.top())
        info_app.showFullScreen()

    sys.exit(app.exec_())
Example #9
0
def main():
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.QMainWindow()

    print("Sample app for pyqtkeybind:")
    print("\tPress Ctrl+Shift+A any where to trigger a callback.")
    print("\tCtrl+Shift+F unregisters and re-registers previous callback.")
    print("\tCtrl+Shift+E exits the app.")

    # Setup a global keyboard shortcut to print "Hello World" on pressing
    # the shortcut
    keybinder.init()
    unregistered = False

    def callback():
        print("hello world")

    def exit_app():
        window.close()

    def unregister():
        keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
        print("unregister and register previous binding")
        keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)

    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+A", callback)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+E", exit_app)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F", unregister)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    app.exec_()
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+A")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+E")
def main():
    global tagselector
    app = QApplication(sys.argv)
    nonShownMainWindow = QMainWindow()
    print('Tag File is at: "%s"' % TAGFILE)
    print('global shortcut to raise the tag selector window is: "%s"' %
          GLOBAL_SHOW_HOTKEY)

    tagselector = FuzzySearchDialog()
    tagselector.show()  #initial loading takes quite long so do it now
    tagselector.hide()

    #when I extracted this to a new class and a different file this didn't work in 2019-05.
    keybinder.init()
    filter = WinEventFilter(keybinder)
    keybinder.register_hotkey(nonShownMainWindow.winId(), GLOBAL_SHOW_HOTKEY,
                              onGlobalShowHotkey)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(filter)

    app.exec_()
    keybinder.unregister_hotkey(nonShownMainWindow.winId(),
                                GLOBAL_SHOW_HOTKEY)  #necessary?
Example #11
0
def main():
    import sys

    app = QApplication(sys.argv)

    widget = MyWidget()
    win = MainWindow(widget)

    def callback():
        widget.show()

    if 'Darwin' not in platform.system():
        from pyqtkeybind import keybinder
        keybinder.init()
        keybinder.register_hotkey(win.winId(), "Ctrl+Shift+1", callback)

        # Install a native event filter to receive events from the OS
        win_event_filter = WinEventFilter(keybinder)
        event_dispatcher = QAbstractEventDispatcher.instance()
        event_dispatcher.installNativeEventFilter(win_event_filter)

        keybinder.unregister_hotkey(win.winId(), 0x0, 0x0)
    sys.exit(app.exec())
Example #12
0
def main():
    logging.config.fileConfig("conf/logging.conf")
    app = qt.QApplication(sys.argv)
    window = QuickAddWindow(NotionNotesRepository(sys.argv[1]))

    keybinder.init()
    set_global_shortcut(window, "Ctrl+T")
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()

    menu = QMenu()
    quit_action = menu.addAction("Quit")
    quit_action.triggered.connect(app.quit)

    icon = QIcon("media/icon.png")
    tray_icon = qt.QSystemTrayIcon(icon, parent=app)
    tray_icon.setToolTip("An amazing quick add for notion")
    tray_icon.show()
    tray_icon.setContextMenu(menu)

    sys.exit(app.exec_())
Example #13
0
if __name__ == "__main__":
    app = QApplication(sys.argv)

    hotkeysList = getHotkeys()
    window = MainWindow()

    def add(item):
        window.addItem(item)

    def start():
        window.startButton.click()

    def stopAction():
        window.thStop()

    def exit_app():
        window.stop_threads = True
        window.close()
        sys.exit(app.exec())

    keybinder.init()
    activeHotkeys(*hotkeysList)

    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    sys.exit(app.exec())
    deactiveHotkeys(*hotkeysList)
Example #14
0
def main():
    # sys._excepthook = sys.excepthook
    #
    # def exception_hook(exctype, value, traceback):
    #     print(exctype, value, traceback)
    #     sys._excepthook(exctype, value, traceback)
    #     sys.exit(1)
    #
    # sys.excepthook = exception_hook

    app = QtWidgets.QApplication(sys.argv)
    window = MainWindow()

    print(
        "This will show a quick view of your keybindings (corsair only currently)."
    )
    print("Until I can figure out how to hide this window, just minimize it.")
    print("\tPress Ctrl+Shift+F10 any where to trigger a callback.")
    # print("\tCtrl+Shift+F unregisters and re-registers previous callback.")
    print("\tCtrl+Shift+E exits the app.")

    # Setup a global keyboard shortcut to print "Hello World" on pressing
    # the shortcut
    keybinder.init()
    unregistered = False

    def on_toggle():

        global latch
        nonlocal window

        if latch:
            window.show()
            latch = False
            print("worked On")
        else:
            window.hide()
            latch = True
            print("worked Off")

    def exit_app():
        window.close()

    def unregister():
        keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F10")
        print("unregister and register previous binding")
        keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F10", on_toggle)

    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F10", on_toggle)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+E", exit_app)
    keybinder.register_hotkey(window.winId(), "Shift+Ctrl+F", unregister)

    # Install a native event filter to receive events from the OS
    win_event_filter = WinEventFilter(keybinder)
    event_dispatcher = QAbstractEventDispatcher.instance()
    event_dispatcher.installNativeEventFilter(win_event_filter)

    window.show()
    app.exec_()
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F10")
    # keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+F")
    keybinder.unregister_hotkey(window.winId(), "Shift+Ctrl+E")