@Corsaka/

Virtual Piano to AHK converter

Python

No description

fork
loading
Files
  • main.py
main.py
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
44
45
46
47
import re #imports regular expressions

#groups of notes
one = r"[a-zA-Z0-9\!\@\$\%\^\*\(]"
two = r"\[" + r"[a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(]" + r"\]"
three = r"\[" + r"[a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(]" + r"\]"
four = r"\[" + r"[a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(]" + r"\]"
five = r"\[" + r"[a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(]" + r"\]"
six = r"\[" + r"[a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(][a-zA-Z0-9\!\@\$\%\^\*\(]" + r"\]"

while True:
  rawInput = input("Please send text:\n") #raw input
  uInput = re.split(r"\s",rawInput) #split input
  output = [] #start of output

  if rawInput == "end":
    break

  for i in range(len(uInput)):
    if re.match(six,uInput[i]): #6 chars
      sixL = list(uInput[i])
      output.append("Send {" + sixL[1] + "}{" + sixL[2] + "}{" + sixL[3] + "}{" + sixL[4] + "}{" + sixL[5] + "}{" + sixL[6] + "}\n")
    elif re.match(five,uInput[i]): #5 chars
      fiveL = list(uInput[i])
      output.append("Send {" + fiveL[1] + "}{" + fiveL[2] + "}{" + fiveL[3] + "}{" + fiveL[4] + "}{" + fiveL[5] + "}\n")
    elif re.match(four,uInput[i]): #4 chars
      fourL = list(uInput[i])
      output.append("Send {" + fourL[1] + "}{" + fourL[2] + "}{" + fourL[3] + "}{" + fourL[4] + "}\n")
    elif re.match(three,uInput[i]): #3 chars
      threeL = list(uInput[i])
      output.append("Send {" + threeL[1] + "}{" + threeL[2] + "}{" + threeL[3] + "}\n")
    elif re.match(two,uInput[i]): #2 chars
      twoL = list(uInput[i])
      output.append("Send {" + twoL[1] + "}{" + twoL[2] + "}\n")
    elif re.match(one,uInput[i]): #1 char
      output.append("Send {" + str(uInput[i])+"}\n")
    elif uInput[i] == "-":
      output.append("Sleep 100\n")
    elif uInput[i] == "--":
      output.append("Sleep 300\n")
    elif uInput[i] == "---":
      output.append("Sleep 500\n")
    elif uInput[i] == "|":
      output.append("Sleep 700\n")
    output.append("Sleep 100\n")

  print("".join(output))