DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: DONE: Simulate keystrokes to scalable BPM  (Read 9,765 times)

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,772
    • Participated in NANY Challenge Three Times
    • Cody Award
    • Coding Snacks
    • Official Forum Clown
    • Volunteers/Staff
    • Writer
    • Hardware Hacker
    • DJ Badge - DJ
    • Linux User
DONE: Simulate keystrokes to scalable BPM
« on: August 28, 2011, 05:27 AM »
Anybody willing to code the following:

It would need to simulate key strokes, and send them to the active window, at a specific BPM

For instance, I would want to send the following keystrokes, to the active window:

Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M

They would be sent at the rate of 128 BPM (In this respect, for the left hand segment of Rufus Wainwright - Hallelujah)

If possible, I would like to also be able to set the program to be able to loop X times, then follow with a new set of orders (so looping that 4 times, then sending the next set of keys to the active window) - It would send each set, a designated number of times.

It should also be able to send multiple strokes at once, so if I wanted to send B Q E at the same time, it would do (at EXACTLY the same time)

BPM is hugely important in this, as its going to be used in conjunction with a Virtual MIDI Piano, So I would obviously want to be able to set a specific BPM for each song.

I know I'm pushing my luck, but I would also be able to set "BPM Markers" within the keymap file, so if it plays X at Y BPM, for N number of times, it could then also change BPM

As an extension (yay, more options), I would also be able to designate shortcuts to be sent to the active window (which will in-turn, change the transposition, the octave etc) (These are set by the MIDI Piano software itself)

IE

*128 4 (<--- signifies, 128 BPM, Repeat 4 times)
Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M
*192 8 (<---192 BPM, Repeat x4)
Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M
*128 8 CTLRA CTLRA (Change BPM back to 128, repeated 8 times, moving the transposition up 2 notches by sending CTRL-Right Arrow to the software)
Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M


It would be cool if those shortcuts are all able to be chosen and changed at any point using this softwares control menu, so I can add/remove shortcuts, or change stuff around to make life easier.


Its a big ask, so I thank in advance.

If you need any more information, ask! :D



« Last Edit: August 28, 2011, 08:58 AM by Stephen66515 »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: (Request) Simulate keystrokes to scalable BPM
« Reply #1 on: August 28, 2011, 08:31 AM »
fun idea..

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,772
    • Participated in NANY Challenge Three Times
    • Cody Award
    • Coding Snacks
    • Official Forum Clown
    • Volunteers/Staff
    • Writer
    • Hardware Hacker
    • DJ Badge - DJ
    • Linux User
Re: (Request) Simulate keystrokes to scalable BPM
« Reply #2 on: August 30, 2011, 12:07 AM »
No-one?  :huh:

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,649
    • Participated in NANY Challenge Eleven Times
    • Coding Snacks
    • Linux User
    • Hardware Hacker
Re: (Request) Simulate keystrokes to scalable BPM
« Reply #3 on: August 30, 2011, 06:51 AM »
Would it be something to add to WinSendKeys ? That comes with AutoIt source, so you could take a stab at it yourself ;)
/Ton
Ath's software collection, Quote: "A problem well stated is a problem half-solved." (Charles Kettering)

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: (Request) Simulate keystrokes to scalable BPM
« Reply #4 on: August 30, 2011, 12:31 PM »
Stephen, here's a simplified version of the script I gave you last night:

Code: (autohotkey)
myTunes =
(
*128 4
Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M
*192 8
Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M
*128 8
Q E T I T E Q E T I T E
N Q E Y E Q N Q E Y E Q
V N Q R Q N V N Q R Q N
B M W T W M B M W T W M
)

StringSplit, tArray, myTunes, *
Return


F1::
{
    Loop, % tArray0
    {
        Loop, Parse, tArray%A_Index%, `n, `r
        {
            If ( A_Index = 1 )
            {
                StringSplit, myTimingArray, A_LoopField, %A_Space%
                myBPMTime := Ceil( ( 60 / myTimingArray1 ) * 1000 )
                myRepeat  := myTimingArray2
            }
            Else
            {
                myKeyBlock .= A_LoopField . " "
            }
        }
    SendKeys( myKeyBlock, myBPMTime, myRepeat )
    myKeyBlock := ""
    }
}
Return


SendKeys( sKeys, nBPM, nRepeat )
{
    Loop, % nRepeat
    {
        Loop, Parse, sKeys, %A_Space%
        {
            If ( A_LoopField != "" )
            {
                SendInput, % A_LoopField
                Sleep, % nBPM
            }
        }
    }
}

ESC:: ExitApp

KynloStephen66515

  • Animated Giffer in Chief
  • Honorary Member
  • Joined in 2010
  • **
  • Posts: 3,772
    • Participated in NANY Challenge Three Times
    • Cody Award
    • Coding Snacks
    • Official Forum Clown
    • Volunteers/Staff
    • Writer
    • Hardware Hacker
    • DJ Badge - DJ
    • Linux User
Re: (Request) Simulate keystrokes to scalable BPM
« Reply #5 on: August 30, 2011, 04:31 PM »
:D

TYVM!
* Stephen66515 is happy now!

Original address: https://www.donationcoder.com/forum/index.php?topic=27786.0