-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (30 loc) · 952 Bytes
/
main.py
File metadata and controls
43 lines (30 loc) · 952 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
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /usr/bin/env python3
##############################################
# this script reads a number from the clipboard,
# does some math with it, and pastes it back
##############################################
import os
import sys
from time import sleep
import clipboard_access as win_clipboard # should be in same DIR
from threading import Thread
##########################
########## Main ##########
##########################
modified = ""
while True:
s = ""
number = 0.0
try:
s = win_clipboard.Get()
number = float(s) * 3.0 / 5.0
except (TypeError, ValueError):
# the contents of the clipboard isn't text or isn't a number
s = ""
modified = ""
sleep(1)
if s != modified:
modified = "{:03.2f}".format(number)
print(s, "->", modified)
win_clipboard.Paste(modified)
sleep(0.1)