Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

[solved]Pynput - capturing CTRL + C

EDIT: The solution is to use key.name

So assuming I use the example code:

PHP Code

<?php 
from pynput
.keyboard import Key, Listener

def on_press
(key):
    print(
'{0} pressed'.format(
        
key))

def on_release(key):
    print(
'{0} release'.format(
        
key))
    if 
key == Key.esc:
        
# Stop listener
        
return False

# Collect events until released
with Listener(
        
on_press=on_press,
        
on_release=on_release) as listener:
    
listener.join() 

When you press CTRL + C and release it, the release function outputs:
'\x03' Which I believe is ascii for ctrl^c, which I could handle with a simple dictionary I believe.

The issue is the keypress function gets this character: 
Which I can do nothing with...

Anyone got any ideas on what I can do?

EDIT: The documentation shows "Controller.modifiers" but not much on how it's used.

I really hope this isn't a stupid question, I'm completely lost.
[Image: 5BgQiIm.gif]
What I did when I created my keylogger was figure out what ascii code was printed when that combination was used, so I don't know how reliable it is, but it looked similar to this:
if key.char == "":
string += "[CTRL-C]"
This doesn't work for some combinations like CTRL-Z, but it does for CTRL-C and V

EDIT: The ascii code isn't showing up but it is meant to be that icon for \x03
(Jul 31, 2017 01:36 PM)_Pr0xy Wrote:  What I did when I created my keylogger was figure out what ascii code was printed when that combination was used, so I don't know how reliable it is, but it looked similar to this:
if key.char == "":
string += "[CTRL-C]"
This doesn't work for some combinations like CTRL-Z, but it does for CTRL-C and V

Yes, that'd work with the keyrelease function, but it doesn't work with the keydown function... because the results are sometimes the same.

Thank you though for the input 👍
[Image: 5BgQiIm.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by ShallowMEJan 11, 2020 11:07 PM 2 177 Jan 11, 2020 11:07 PM
Last Post: ShallowME
[Python] by f4keg0dNov 11, 2019 04:32 AM 4 454 Nov 11, 2019 04:32 AM
Last Post: f4keg0d
[Python] by CyberErrorJan 9, 2019 10:29 AM 4 166 Jan 9, 2019 10:29 AM
Last Post: Ghxst