title: How to convert midi files to keypresses (in Python)?
body: <p>I'm trying to read a MIDI file and then convert each note (midi number) to a simulated keypress on the keyboard (A,f,h,J,t...).</p>
  <p>I'm able to read any MIDI file with the python-midi library like this:</p>
  <pre><code>pattern = midi.read_midifile(&quot;example.mid&quot;)
  </code></pre>
  <p>and I can also simulate keypresses with pywin32 like this:</p>
  <pre><code>shell = win32com.client.Dispatch(&quot;WScript.Shell&quot;)
  shell.SendKeys(key)
  </code></pre>
  <p>But I have no idea on how to actually convert midi numbers (that are in midi files) to keypresses.</p>
  <p>To be more precise I'm trying to convert MIDI numbers to notes and then notes to keypresses according to <a href="http://virtualpiano.net/" rel="nofollow noreferrer">virtualpiano.net</a> (61-key) so that the program would play that piano by pressing the corresponding button on the keyboard (you can press key assist in settings of the piano to see which key is what button)</p>
  <p>Of course I would also have to wait between keypresses but that's easy enough.</p>
  <p>Any help is appreciated. (Windows 10 64-bit (32-bit Python 2.7))</p>