Python Forum
Automatically read copied text from keyboard shortcuts - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Automatically read copied text from keyboard shortcuts (/thread-2271.html)

Pages: 1 2


RE: Automatically read copied text from keyboard shortcuts - wavic - Mar-10-2017

Well, I am in unknown territory but...  Smile
Try 

import pyhook
from pyHook.HookManager import HookConstants

def OnKeyboardEvent(event):

   if event.Key.lower() == 'lcontrol' and pyhook.GetKeyState(HookConstants.VKeyToID('VK_CONTROL'):
       print "Control or win or tab or alt is pressed"
       if event.Ascii == 99:
           print "control+c is pressed"
           exit()

   else:
       print 'MessageName:',event.MessageName
       print 'Ascii:', repr(event.Ascii), repr(chr(event.Ascii))
       print 'Key:', repr(event.Key)
       print 'KeyID:', repr(event.KeyID)
       print 'ScanCode:', repr(event.ScanCode)
       print '---'
       print "The pressed key does not match Control+c"

hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages ()
You have to know if the ctrl key is down also when you check for 'c'