Python Forum
Automatically read copied text from keyboard shortcuts
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automatically read copied text from keyboard shortcuts
#11
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'
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Read text file, modify it then write back Pavel_47 5 4,768 Feb-18-2023, 02:49 PM
Last Post: deanhystad
  Attempting to read keyboard outside of console Jimmy998 5 3,878 Nov-25-2022, 08:17 PM
Last Post: Larz60+
  Need help with infinite loop & making hotkeys/shortcuts Graxum 1 1,897 Aug-22-2022, 02:57 AM
Last Post: deanhystad
  read a text file, find all integers, append to list oldtrafford 12 10,082 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Creating Shortcuts with python Oshadha 2 4,419 Jun-23-2022, 08:07 AM
Last Post: Oshadha
  Not able to read the text using pexpect/expect Bipinjohnson 7 6,861 Jan-10-2022, 11:21 AM
Last Post: Bipinjohnson
  [SOLVED] Read text file from some point till EOF? Winfried 1 3,598 Oct-10-2021, 10:29 PM
Last Post: Winfried
  Why changing data in a copied list changes the original list? plumberpy 3 3,141 Aug-14-2021, 02:26 AM
Last Post: plumberpy
  Open and read multiple text files and match words kozaizsvemira 3 8,638 Jul-07-2021, 11:27 AM
Last Post: Larz60+
  read terminal text from running program AArdvark_UK 2 2,680 Aug-27-2020, 12:43 PM
Last Post: AArdvark_UK

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020