let's look at this script which is working very well. it's seems fast, it uses pyinput.…
- User
let's look at this script which is working very well. it's seems fast, it uses pyinput. are there any other way to optimized it. dunno if using regex is the right solution, or removin pyperclip and using typewriter could be a solution. also remaining with the current state of the script could it be enhanced in some other ways?
from pynput.keyboard import Key, Controller import pyperclip import time
def paste_numbers(): keyboard = Controller()
Collect numbers from user input print("Enter the numbers to paste (semicolons and new lines separated):") print("(Press Enter on an empty line to finish input)") numbers = [] while True: line = input() if not line: break numbers.extend([num.strip() for num in line.strip().split(';') if num.strip()])
total_numbers = len(numbers) print(f"Total numbers to paste: {total_numbers}")
Provide time to switch to GeoZeb print("Switch to GeoZeb. Starting in 5 seconds...") time.sleep(5)
Make the first cell editable keyboard.press(Key.f2) keyboard.release(Key.f2) time.sleep(0.001)
count = 0 for number in numbers:
Copy number to clipboard pyperclip.copy(number) time.sleep(0.01) # Ensure clipboard is updated
Paste number using Ctrl+V with keyboard.pressed(Key.ctrl): keyboard.press('v') keyboard.release('v') time.sleep(0.01)
Press Tab to move to next cell keyboard.press(Key.tab) keyboard.release(Key.tab)
count += 1 if count % 3 == 0 and count != total_numbers:
Wrapping logic: move to the next row keyboard.press(Key.tab) keyboard.release(Key.tab) time.sleep(0.01) keyboard.press(Key.f2) keyboard.release(Key.f2) time.sleep(0.01)
Final actions after all numbers are pasted time.sleep(0.01) keyboard.press(Key.space) keyboard.release(Key.space) time.sleep(0.01) # Ensure the 'space' keypress is registered
if name == 'main': paste_numbers()
- Assistant