-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotkeys-paste.py
More file actions
30 lines (25 loc) · 898 Bytes
/
hotkeys-paste.py
File metadata and controls
30 lines (25 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pandas as pd
import keyboard
import sys
import time
# Read the messages and shortcut keys from the Excel file
df = pd.read_excel('messages.xlsx')
# Convert the dataframe to a dictionary
messages = df.set_index('Shortcut')['Message'].to_dict()
# Define a function to paste a message based on the given key
def paste_message(key):
if key in messages:
message = messages[key]
keyboard.press_and_release('ctrl+v')
keyboard.write(message)
print(f'วางข้อความแล้ว : {message}')
# Register the shortcut keys
for key in messages:
keyboard.add_hotkey(key, paste_message, args=(key,))
# Start the keyboard listener
print('ปุ่มลัดพร้อมทำงาน. กด ctrl+alt+q เพื่อปิด.')
while True:
if keyboard.is_pressed('ctrl+alt+q'):
sys.exit()
else:
time.sleep(0.01)