pythoncom

I want to stop pythoncom working

久未见 提交于 2019-12-10 19:49:55
问题 I was writing a code about keylogging by pyHook. The following codes are example: import pythoncom as pc, pyHook as ph def KeyboardHook(event): print chr(event.Ascii) return True hm = ph.HookManager() hm.KeyDown = KeyboardHook hm.HookKeyboard() pc.PumpMessages() I want to stop pythoncom's PumpMessages method for a while later (for example five seconds). But I couldn't find any answer to it. I use: Windows 7, Python2.7 Thanks for answer. 回答1: You will have to use pythoncom.PumpWaitingMessages

Tkinter withdraw oddness with pyHook

两盒软妹~` 提交于 2019-12-08 07:10:43
问题 I have a Tkinter GUI application that I need to hide on a buttonpress. I cannot assume that the application will have focus, so I implemented pyHook, keylogger-style. However, whenever I call withdraw() from a function launched by pyHook, the window hangs and I have to force-close it. To test, I added a button inside the GUI itself to call exactly the same function, and it works just fine. What's going on? 'hiding' prints both times, so I know it is really hanging on the withdraw() call

pyHook stops receiving Key press events (randomly)?

荒凉一梦 提交于 2019-12-04 01:54:57
问题 I have a program that captures all key presses using pyHook, then runs a few functions. I notice that after a while (of random duration), the program was stop receiving key triggers, even though I am pressing keys? Is pyHook unstable? I'm not changing what keys are pressed or pressing them prematurely or anything like that. Here's my code: import time import win32api import win32con import pythoncom import pyHook import os import ctypes def Click(x,y): win32api.SetCursorPos((x,y)) win32api

pyHook stops receiving Key press events (randomly)?

允我心安 提交于 2019-12-01 10:33:33
I have a program that captures all key presses using pyHook, then runs a few functions. I notice that after a while (of random duration), the program was stop receiving key triggers, even though I am pressing keys? Is pyHook unstable? I'm not changing what keys are pressed or pressing them prematurely or anything like that. Here's my code: import time import win32api import win32con import pythoncom import pyHook import os import ctypes def Click(x,y): win32api.SetCursorPos((x,y)) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0

Python - pythoncom.com_error handling in Python 3.2.2

一笑奈何 提交于 2019-12-01 09:15:26
I am using Python 3.2.2, and building a Tkinter interface to do some Active Directory updating. I am having trouble trying to handle pythoncom.com_error exceptions. I grabbed some code from here: http://code.activestate.com/recipes/303345-create-an-account-in-ms-active-directory/ However, I use the following (straight from the above site) handle the exceptions raised: except pythoncom.com_error,(hr,msg,exc,arg): This code is consistent with many of the sites I have seen that handle these exceptions, however with Python 3.2.2, I get a syntax error if I include the comma after "pythoncom.com

Python - pythoncom.com_error handling in Python 3.2.2

半城伤御伤魂 提交于 2019-12-01 06:52:07
问题 I am using Python 3.2.2, and building a Tkinter interface to do some Active Directory updating. I am having trouble trying to handle pythoncom.com_error exceptions. I grabbed some code from here: http://code.activestate.com/recipes/303345-create-an-account-in-ms-active-directory/ However, I use the following (straight from the above site) handle the exceptions raised: except pythoncom.com_error,(hr,msg,exc,arg): This code is consistent with many of the sites I have seen that handle these

How to copy a table from excel to word using pythonCOM

吃可爱长大的小学妹 提交于 2019-12-01 06:42:01
Is it possible to get the table from excel file and paste it to the word document saving its excel style? I didn't find adequate documentation about win32com and all its methods. I've found a method PasteExcelTable , and I guess I should select the table from excel before invoking this method. I do the following: from win32com import client excel = client.Dispatch("Excel.Application") word = client.Dispatch("Word.Application") doc = word.Documents.Open("C:/word_file.docx") book = excel.Workbooks.Open("C:/excel_file.xlsx") sheet = book.Worksheets(1) sheet.Range("A1:D20").Select # Selected the

How to copy a table from excel to word using pythonCOM

这一生的挚爱 提交于 2019-12-01 04:35:50
问题 Is it possible to get the table from excel file and paste it to the word document saving its excel style? I didn't find adequate documentation about win32com and all its methods. I've found a method PasteExcelTable , and I guess I should select the table from excel before invoking this method. I do the following: from win32com import client excel = client.Dispatch("Excel.Application") word = client.Dispatch("Word.Application") doc = word.Documents.Open("C:/word_file.docx") book = excel

ImportError: No module named pywintypes

六月ゝ 毕业季﹏ 提交于 2019-11-29 18:01:49
问题 I am working to make a small keylogger with Python, by using the pyHook, pythoncom and Pywin32 modules. Here is my code: import pyHook, pythoncom, sys, logging file_log = 'C:\\important\\log.txt' def OnKeyboardEvent (event): logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s') chr(event.Ascii) logging.log(10, chr(Event.Ascii)) return True hooks_manager=pyHook.HookManager() hooks_manager.KeyDown = OnKeyboardEvent hooks_manager.HookKeyboard() pythoncom.PumpMessages(

Ending a Program Mid-Run

試著忘記壹切 提交于 2019-11-27 15:23:28
pythoncom.PumpMessages() From what I understand this line basically tells the program to wait forever. For my purposes it seems to be working. However, I'd like to be able to end the program given the right stimulus. How would one go about ending the above line, or stopping the program from running any further. According to these docs , pythoncom.PumpMessages() : Pumps all messages for the current thread until a WM_QUIT message. So one way to stop collecting messages is by posting a WM_QUIT message to the message queue by using the ctypes library to call PostQuitMessage : ctypes.windll.user32