Example #1
0
def screenshot_main():  
    ''''' 
    Function:主函数,注册快捷键 
    Input:NONE 
    Output: NONE 
    author: socrates 
    blog:http://blog.csdn.net/dyx1024 
    date:2012-03-10 
    '''           
          
    #创建hotkey句柄   
    hot_handle = pyhk.pyhk()  
      
    fun = hook_kev_screenshot()  
   
    #注册抓取全屏快捷键CTRL+F1  
    hot_handle.addHotkey(['Ctrl', 'F1'], fun.capture_fullscreen)  
      
    #注册抓取当前窗口快捷键CTRL+F2  
    hot_handle.addHotkey(['Ctrl', 'F2'], fun.capture_current_windows)  
      
    #注册抓取所选区域快捷键CTRL+F3  
    hot_handle.addHotkey(['Ctrl', 'F3'], fun.capture_choose_windows)  
   
    #开始运行  
    hot_handle.start()  
Example #2
0
    def initUI(self):
        QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
        self.setToolTip('This is a <b>QWidget</b> widget')

        btn1 = QtGui.QPushButton('SEND', self)
        btn1.resize(btn1.sizeHint())
        btn1.move(20, 20)
        btn1.clicked.connect(self.send_img)
        #btn1.clicked.connect(self.close_application)
        btn2 = QtGui.QPushButton('START', self)
        btn2.resize(btn1.sizeHint())
        btn2.move(150, 20)
        btn2.clicked.connect(self.start)

        btn3 = QtGui.QPushButton('STOP', self)
        btn3.resize(btn1.sizeHint())
        btn3.move(300, 20)
        #btn1.clicked.connect(lambda:self.run('client.py'))

        qbtn = QtGui.QPushButton('Quit', self)
        qbtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
        qbtn.resize(qbtn.sizeHint())
        qbtn.move(400, 20)
        self.setGeometry(50, 50, 500, 300)
        self.setWindowTitle('CLIENT')

        #subprocess.call(['pythonw','3.py'])
        self.show()
        hot = pyhk.pyhk()
        id1 = hot.addHotkey(['Ctrl', 'S'], self.send_img)
        hot.start()
    def __init__(self):
        msg_TaskbarRestart = RegisterWindowMessage("TaskbarCreated");
        message_map = {
                msg_TaskbarRestart: self.OnRestart,
                win32con.WM_DESTROY: self.OnDestroy,
                win32con.WM_COMMAND: self.OnCommand,
                win32con.WM_USER+20 : self.OnTaskbarNotify,
        }

        # Register the Window class.
        wc = WNDCLASS()
        hinst = wc.hInstance = GetModuleHandle(None)
        wc.lpszClassName = "PythonTaskbarDemo"
        wc.style = win32con.CS_VREDRAW | win32con.CS_HREDRAW;
        wc.hCursor = LoadCursor( 0, win32con.IDC_ARROW )
        wc.hbrBackground = win32con.COLOR_WINDOW
        wc.lpfnWndProc = message_map # could also specify a wndproc.
        classAtom = RegisterClass(wc)

        # Create the Window.
        style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU
        self.hwnd = CreateWindow( classAtom, "SlugKey", style, \
                0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, \
                0, 0, hinst, None)
        UpdateWindow(self.hwnd)
        self._DoCreateIcons()

        #create pyhk class instance
        hot = pyhk.pyhk()
         
        #add hotkey
        hot.addHotkey(['Ctrl','F12'],slugify_clipboard_string)
         
        #start looking for hotkey.
        hot.start()
Example #4
0
 def pyhk(self):  # pyhk instance
     if not self._pyhk:
         if skos.WIN:
             from pyhk import pyhk
             self._pyhk = pyhk()
         else:
             self._pyhk = dummy_pyhk()
     return self._pyhk
Example #5
0
 def run(self):
     hot = pyhk.pyhk()
     # add hotkey
     try:
         hot.addHotkey(['Alt', 'F1'], captureFunction)
         # start looking for hotkey.
         hot.start()
     except:
         print '注册失败'
Example #6
0
 def run(self):
     hot = pyhk.pyhk()
     # add hotkey
     try:
         hot.addHotkey(['Alt', 'F1'], captureFunction)
         # start looking for hotkey.
         hot.start()
     except:
         print '注册失败'
Example #7
0
    def __init__(self, *args):
        '''
        :type palette: QPalette
        '''
        QWidget.__init__(self, *args)

        # setup global hotkeys
        self.hk = pyhk.pyhk()
        self.reinstall_hook()

        # init pomodoro state
        self.pomodoro = Pomodoro()

        # Let the whole window be a glass
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint)
        self.setWindowFlags(self.windowFlags() | Qt.WindowStaysOnTopHint)
        # label styling
        self.format = "{0:02d}:{1:02d}"
        self.setLayout(QVBoxLayout())
        self.label = QLabel()
        self.default_style = {
            'ff': 'Hack',
            'fg': Config.COLOR_NORMAL,
            'size': '50px'
        }
        self.stylesheet = '''
                QLabel {{
                    font-family: {ff};
                    color: {fg};
                    font-size: {size};
                }}
                '''
        computed_style = self.stylesheet.format(**self.default_style);
        print computed_style
        self.label.setStyleSheet(computed_style)
        self.layout().addWidget(self.label)
        effect = QGraphicsDropShadowEffect()
        effect.setBlurRadius(10)
        effect.setOffset(3)
        effect.setColor(Qt.black)
        self.label.setGraphicsEffect(effect)
        # make mouse move event propagated to parent widget
        self.label.setAttribute(Qt.WA_TransparentForMouseEvents)
        # I don't know why the code below is needed
        # from ctypes import windll, c_int, byref
        # windll.dwmapi.DwmExtendFrameIntoClientArea(c_int(self.winId()), byref(c_int(-1)))
        self.move(50, 50)
        self.ldown = False
        self.startTimer(100)
Example #8
0
def main():
    print(Str.cyan.Twinkle("""Please Use Ctrl+F1 to capture the fullscreen and save.
or use Ctrl+F2 to capture the current window and save to Desktop.
or use Ctrl+F3 to capture the image and paste into Clipboard with full screen.
or use Ctrl+F4 to capture the image and paste into Clipboard with current window."""))
    print(Str.cyan.Twinkle("Use the 'q' to escape the PROGRAM. Use Ctrl+Alt+Q to shutdown the fxxking computer."))
    hot_handle = pyhk.pyhk()
    hot_handle.addHotkey(['Ctrl', 'F1'], capture_fullscreen)
    hot_handle.addHotkey(['Ctrl', 'F2'], capture_current_windows)
    hot_handle.addHotkey(['Ctrl', 'F3'], paste_into_clipboard_full)
    hot_handle.addHotkey(['Ctrl', 'F4'], paste_into_clipboard_window)
    hot_handle.addHotkey(["Q"], sys.exit)
    hot_handle.addHotkey(["Ctrl","Alt","Q"], shutdown)
    hot_handle.addHotkey(["Ctrl","Alt","A"], music)
    hot_handle.start()
Example #9
0
def main():
    '''
    main function
    '''        
    hot_handle = pyhk.pyhk()
    
    print "read the soft key location from file softkey.conf\n"
    soft_key.createPoints()
    soft_key.ReadConfigFromFile()
    print "read the flash config from file\n"
    ReadFromFile()
    
    print "register commit with F2\n"
    hot_handle.addHotkey(['F2'], commit, isThread=True)

    hot_handle.start()
Example #10
0
def main():
    '''
    Function:Ö÷º¯Êý£¬×¢²á¿ì½Ý¼ü
    Input£ºNONE
    Output: NONE
    author: socrates
    blog:http://blog.csdn.net/dyx1024
    date:2012-03-10
    '''        
     
    #´´½¨hotkey¾ä±ú
    hot_handle = pyhk.pyhk()
  
    #×¢²áץȡȫÆÁ¿ì½Ý¼üCTRL+F1
    hot_handle.addHotkey(['Ctrl', 'F1'], capture_fullscreen)
     
     
    hot_handle.addHotkey(['Ctrl', 'F2'], getPic)
  
    #¿ªÊ¼ÔËÐÐ
    hot_handle.start()
Example #11
0
    def registerEvents(self):
        if HOTKEYS_ENABLED:
            self.hot = pyhk.pyhk()
            self.hot.addHotkey(['Return'], self.speak_contents, isThread=True)
        else:
            self.entry_message.bind('<Key-Return>', self.speak_contents)

        def checkBinary():
            try:
                retcode = call("espeak")
                if retcode < 0:
                    print >> sys.stderr, "espeak was terminated by signal", -retcode
                else:
                    print >> sys.stderr, "espeak returned", retcode
            except OSError as e:
                print >> sys.stderr, "Execution failed:", e
                return False
            return True

        if checkBinary():
            print("proceed")
        else:
            print("find new file")
            options = {}

            options['title'] = "Locate eSpeak application"
            options['parent'] = self.parent
            options['initialdir'] = "C:\\Program Files (x86)\\"
            options['filetypes'] = [('executables', '.exe'),
                                    ('all files', '.*')]

            retfilename = askopenfilename(**options)

            if retfilename == "":
                print("dialog cancelled")
            else:
                print("app location:", retfilename)
                self.app.set(retfilename)
Example #12
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        hot = pyhk.pyhk()
        self.shortcuts = 'CTRL+1:hide CTRL+2:normal CTRL+3:maximized CTRL+T:stays on top(default) CTRL+B:bottom CTRL+N:normal'
        hot.addHotkey(['Ctrl', '1'], self.hide)
        hot.addHotkey(['Ctrl', '2'], self.showNormal)
        hot.addHotkey(['Ctrl', '3'], self.showMaximized)
        hot.addHotkey(['Ctrl', 'T'], self.change_on_top)
        hot.addHotkey(['Ctrl', 'B'], self.change_on_bottom)
        hot.addHotkey(['Ctrl', 'N'], self.change_on_normal)

        self.setupUi(self)

        self.setWindowTitle("{} - {}".format(config.appName, config.appVersion))
        self.setWindowFlags(Qt.WindowStaysOnTopHint)

        self.open_pushButton.clicked.connect(self.open_log)
        self.close_pushButton.clicked.connect(self.close_log)

        self.create_actions()
        self.create_tray_icon()
        self.open_logs()
Example #13
0
    def registerEvents(self):
        if HOTKEYS_ENABLED:
           self.hot = pyhk.pyhk()
           self.hot.addHotkey(['Return'], self.speak_contents, isThread=True)
        else:
           self.entry_message.bind('<Key-Return>', self.speak_contents)

        def checkBinary():
            try:
                retcode = call("espeak")
                if retcode < 0:
                    print >>sys.stderr, "espeak was terminated by signal", -retcode
                else:
                    print >>sys.stderr, "espeak returned", retcode
            except OSError as e:
                print >>sys.stderr, "Execution failed:", e
                return False
            return True

        if checkBinary():
            print("proceed")
        else:
            print("find new file")
            options = {}

            options['title'] = "Locate eSpeak application"
            options['parent'] = self.parent
            options['initialdir'] = "C:\\Program Files (x86)\\"
            options['filetypes'] = [('executables','.exe'),('all files','.*')]

            retfilename = askopenfilename(**options)

            if retfilename == "":
                print("dialog cancelled")
            else:
                print("app location:", retfilename)
                self.app.set(retfilename)
Example #14
0
def main():
    '''
    Function:主函数,注册快捷键
    Input:NONE
    Output: NONE
    author: socrates
    blog:http://blog.csdn.net/dyx1024
    date:2012-03-10
    '''         
    
    #创建hotkey句柄 
    hot_handle = pyhk.pyhk()
 
    #注册抓取全屏快捷键CTRL+F1
    hot_handle.addHotkey(['Ctrl', 'F1'], capture_fullscreen)
    
    #注册抓取当前窗口快捷键CTRL+F2
    hot_handle.addHotkey(['Ctrl', 'F2'], capture_current_windows)
    
    #注册抓取所选区域快捷键CTRL+F3
    hot_handle.addHotkey(['Ctrl', 'F3'], capture_choose_windows)
 
    #开始运行
    hot_handle.start()
Example #15
0
import pyhk
import pyperclip
import requests

hot_handle = pyhk.pyhk()
hot_key = ['F4']
change_key = ['Ctrl', 'Q']


def fun():
    url = "https://nmsl.shadiao.app/api.php?lang=zh_cn"
    res = requests.get(url).text

    pyperclip.copy(res)


def changeKey():
    print("fu")


hot_handle.addHotkey(hot_key, fun)
hot_handle.addHotkey(change_key, changeKey)

hot_handle.start()
Example #16
0
def mousemove():
    global flage
    M = PyMouse()
    time.sleep(1)
    while flage == 1:
        time.sleep(0.02)
        a = M.position()
        M.click(x=a[0], y=a[1], n=1)
        if (flage == 0):
            break


def timec(t):
    global flage
    time.sleep(t)
    flage = 0
    pass


def exit():
    pass


if __name__ == '__main__':

    hot = pyhk.pyhk()
    hot.addHotkey(['mouse left', '4'], fun)
    hot.addHotkey(['4'], fun)
    hot.addHotkey(['Ctrl', '1'], exit)
    hot.start()
Example #17
0
import pyhk
 
def fun():
    print "Do something"
 
#create pyhk class instance
hot = pyhk.pyhk()
 
#add hotkey
hot.addHotkey(['Ctrl', 'Alt','7'],fun)
 
#start looking for hotkey.
hot.start()
Example #18
0
def hotkey_listener():
	file_listener = pyhk.pyhk()
	file_listener.addHotkey(['Ctrl', 'Alt','K'],clipboard_to_quickpad)
	file_listener.start()