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 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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,667 Feb-18-2023, 02:49 PM
Last Post: deanhystad
  Attempting to read keyboard outside of console Jimmy998 5 3,805 Nov-25-2022, 08:17 PM
Last Post: Larz60+
  Need help with infinite loop & making hotkeys/shortcuts Graxum 1 1,887 Aug-22-2022, 02:57 AM
Last Post: deanhystad
  read a text file, find all integers, append to list oldtrafford 12 9,978 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Creating Shortcuts with python Oshadha 2 4,341 Jun-23-2022, 08:07 AM
Last Post: Oshadha
  Not able to read the text using pexpect/expect Bipinjohnson 7 6,790 Jan-10-2022, 11:21 AM
Last Post: Bipinjohnson
  [SOLVED] Read text file from some point till EOF? Winfried 1 3,569 Oct-10-2021, 10:29 PM
Last Post: Winfried
  Why changing data in a copied list changes the original list? plumberpy 3 3,115 Aug-14-2021, 02:26 AM
Last Post: plumberpy
  Open and read multiple text files and match words kozaizsvemira 3 8,577 Jul-07-2021, 11:27 AM
Last Post: Larz60+
  read terminal text from running program AArdvark_UK 2 2,656 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