Jump to content

Recommended Posts

Posted

Not much to say...I got bored and made a piano.

Can be played with F1-F8 or by clicking, haven't figured out how to make it play for as long as you hold down though :P

Suggestions are welcome.

;By Robert Woollins AKA BobiusMaximus

Hotkeyset("{F1}","F1")
Hotkeyset("{F2}","F2")
Hotkeyset("{F3}","F3")
Hotkeyset("{F4}","F4")
Hotkeyset("{F5}","F5")
Hotkeyset("{F6}","F6")
Hotkeyset("{F7}","F7")
Hotkeyset("{F8}","F8")


#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Bobs Piano", 336, 106, 256, 155)
$C1 = GUICtrlCreateButton("C", 8, 8, 33, 81, 0)
$D1 = GUICtrlCreateButton("D", 48, 8, 33, 81, 0)
$E1 = GUICtrlCreateButton("E", 88, 8, 33, 81, 0)
$F1 = GUICtrlCreateButton("F", 128, 8, 33, 81, 0)
$G1 = GUICtrlCreateButton("G", 168, 8, 33, 81, 0)
$A1 = GUICtrlCreateButton("A", 208, 8, 33, 81, 0)
$B1 = GUICtrlCreateButton("B", 248, 8, 33, 81, 0)
$C2 = GUICtrlCreateButton("C", 288, 8, 33, 81, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $C1 Then Call("F1")
    If $nMsg = $D1 Then Call("F2")
    If $nMsg = $E1 Then Call("F3")
    If $nMsg = $F1 Then Call("F4")
    If $nMsg = $G1 Then Call("F5")
    If $nMsg = $A1 Then Call("F6")
    If $nMsg = $B1 Then Call("F7")
    If $nMsg = $C2 Then Call("F8")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func F1()
    Beep(264, 500)
EndFunc

Func F2()
    Beep(297, 500)
EndFunc

Func F3()
    Beep(330, 500)
EndFunc

Func F4()
    Beep(352, 500)
EndFunc

Func F5()
    Beep(396, 500)
EndFunc

Func F6()
    Beep(440, 500)
EndFunc

Func F7()
    Beep(495, 500)
EndFunc

Func F8()
    Beep(523.3, 500)
EndFunc

-Bob

Photoshop User and Noob AutoIt user.
Posted (edited)

Lol, I like this. Its fun!

Hotkeyset("{F1}","F1")
Hotkeyset("{F2}","F2")
Hotkeyset("{F3}","F3")
Hotkeyset("{F4}","F4")
Hotkeyset("{F5}","F5")
Hotkeyset("{F6}","F6")
Hotkeyset("{F7}","F7")
Hotkeyset("{F8}","F8")


#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Bobs Piano", 336, 106, 256, 155)
$C1 = GUICtrlCreateButton("C", 8, 8, 33, 81, 0)
$D1 = GUICtrlCreateButton("D", 48, 8, 33, 81, 0)
$E1 = GUICtrlCreateButton("E", 88, 8, 33, 81, 0)
$F1 = GUICtrlCreateButton("F", 128, 8, 33, 81, 0)
$G1 = GUICtrlCreateButton("G", 168, 8, 33, 81, 0)
$A1 = GUICtrlCreateButton("A", 208, 8, 33, 81, 0)
$B1 = GUICtrlCreateButton("B", 248, 8, 33, 81, 0)
$C2 = GUICtrlCreateButton("C", 288, 8, 33, 81, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $C1 Then Call("F1")
    If $nMsg = $D1 Then Call("F2")
    If $nMsg = $E1 Then Call("F3")
    If $nMsg = $F1 Then Call("F4")
    If $nMsg = $G1 Then Call("F5")
    If $nMsg = $A1 Then Call("F6")
    If $nMsg = $B1 Then Call("F7")
    If $nMsg = $C2 Then Call("F8")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func F1()
    If WinActive("Bobs Piano") Then
    Beep(264, 500)
    EndIf
EndFunc

Func F2()
    If WinActive("Bobs Piano") Then
    Beep(297, 500)
    EndIf
EndFunc

Func F3()
    If WinActive("Bobs Piano") Then
    Beep(330, 500)
    EndIf
EndFunc

Func F4()
    If WinActive("Bobs Piano") Then
    Beep(352, 500)
    EndIf
EndFunc

Func F5()
    If WinActive("Bobs Piano") Then
    Beep(396, 500)
    EndIf
EndFunc

Func F6()
    If WinActive("Bobs Piano") Then
    Beep(440, 500)
    EndIf
EndFunc

Func F7()
    If WinActive("Bobs Piano") Then
    Beep(495, 500)
    EndIf
EndFunc

Func F8()
    If WinActive("Bobs Piano") Then
    Beep(523.3, 500)
    EndIf
EndFunc

Edit: Just got slightly annoyed when it still played on other windows. Added If WinActive()

Edited by Secure_ICT
Posted

Hmmm.... Paulie made something very similar to this, but his was designed to programs a song into a script then play it. There have been other Piano GUI attempts but I think they've all run into the same problem... the sound just won't stop. I've tried everything there is to try to get the sound to stop playing when the key is let up, but I just can't seem to get the script to interrupt that beep command. Nice script, but if you search the forums it has been done.

- Dan [Website]

Posted (edited)

Nice, I thought about doing something like this when I made my Beep Piano stuff

but, There is an unecessary use of the "call" function

This:

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $C1 Then Call("F1")
    If $nMsg = $D1 Then Call("F2")
    If $nMsg = $E1 Then Call("F3")
    If $nMsg = $F1 Then Call("F4")
    If $nMsg = $G1 Then Call("F5")
    If $nMsg = $A1 Then Call("F6")
    If $nMsg = $B1 Then Call("F7")
    If $nMsg = $C2 Then Call("F8")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
oÝ÷ Ù(hºW[y«­¢+Ø)]¡¥±Ä(ÀÌØí¹5ÍôU%Ñ5Í ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ä ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸È ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ì ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ð ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ô ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ø ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ü ¤(%ÀÌØí¹5ÍôÀÌØíÈQ¡¸à ¤(MÝ¥Ñ ÀÌØí¹5Í(
ÍÀÌØíU%}Y9Q}
1=M(á¥Ð((¹MÝ¥Ñ )]¹
Edited by Paulie
Posted

Nice, I thought about doing something like this when I made my Beep Piano stuff

but, There is an unecessary use of the "call" function

This:

While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $C1 Then Call("F1")
    If $nMsg = $D1 Then Call("F2")
    If $nMsg = $E1 Then Call("F3")
    If $nMsg = $F1 Then Call("F4")
    If $nMsg = $G1 Then Call("F5")
    If $nMsg = $A1 Then Call("F6")
    If $nMsg = $B1 Then Call("F7")
    If $nMsg = $C2 Then Call("F8")
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
oÝ÷ Ù(hºW[y«­¢+Ø)]¡¥±Ä(ÀÌØí¹5ÍôU%Ñ5Í ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ä ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸È ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ì ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ð ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ô ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ø ¤(%ÀÌØí¹5ÍôÀÌØíÄQ¡¸Ü ¤(%ÀÌØí¹5ÍôÀÌØíÈQ¡¸à ¤(MÝ¥Ñ ÀÌØí¹5Í(
ÍÀÌØíU%}Y9Q}
1=M(á¥Ð((¹MÝ¥Ñ )]¹
I can't see that making a large difference TBH, just saves a few characters.

The other idea seemed useful...

But there is no way of making it last for however long you have it pushed down?

-Bob

Photoshop User and Noob AutoIt user.
Posted

I can't see that making a large difference TBH, just saves a few characters.

The other idea seemed useful...

But there is no way of making it last for however long you have it pushed down?

-Bob

the Call command has special purposes and properties, and should not be used when it's not needed.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted (edited)

inspired by helge this is untested

Hotkeyset("{F1}","Play")
Hotkeyset("{F2}","Play")
Hotkeyset("{F3}","Play")
Hotkeyset("{F4}","Play")
Hotkeyset("{F5}","Play")
Hotkeyset("{F6}","Play")
Hotkeyset("{F7}","Play")
Hotkeyset("{F8}","Play")
#include <GUIConstants.au3>
$Form1 = GUICreate("Bobs Piano", 336, 106, 256, 155)
$C1 = GUICtrlCreateButton("C", 8, 8, 33, 81, 0)
$D1 = GUICtrlCreateButton("D", 48, 8, 33, 81, 0)
$E1 = GUICtrlCreateButton("E", 88, 8, 33, 81, 0)
$F1 = GUICtrlCreateButton("F", 128, 8, 33, 81, 0)
$G1 = GUICtrlCreateButton("G", 168, 8, 33, 81, 0)
$A1 = GUICtrlCreateButton("A", 208, 8, 33, 81, 0)
$B1 = GUICtrlCreateButton("B", 248, 8, 33, 81, 0)
$C2 = GUICtrlCreateButton("C", 288, 8, 33, 81, 0)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $C1 Then Play("F1")
    If $nMsg = $D1 Then Play("F2")
    If $nMsg = $E1 Then Play("F3")
    If $nMsg = $F1 Then Play("F4")
    If $nMsg = $G1 Then Play("F5")
    If $nMsg = $A1 Then Play("F6")
    If $nMsg = $B1 Then Play("F7")
    If $nMsg = $C2 Then Play("F8")
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
WEnd
Func Play($hotkey ="")
    If $hotkey = "" Then
        $hotkey = @HotKeyPressed
    Else
        $hotkey = "{" & $hotkey & "}"
    EndIf
    Global $beep[8] = [264,297,330,352,396,440,495,523.3]
    Beep($beep[StringTrimLeft(StringTrimRight($hotkey,1),2)],500)
EndFunc
Edited by Thatsgreat2345
Posted

woops forgot to subtract 1 and declare $hotkey, i dont have a beep speaker so i cant test it

Hotkeyset("{F1}","Play")
Hotkeyset("{F2}","Play")
Hotkeyset("{F3}","Play")
Hotkeyset("{F4}","Play")
Hotkeyset("{F5}","Play")
Hotkeyset("{F6}","Play")
Hotkeyset("{F7}","Play")
Hotkeyset("{F8}","Play")
#include <GUIConstants.au3>
Global $hotkey
$Form1 = GUICreate("Bobs Piano", 336, 106, 256, 155)
$C1 = GUICtrlCreateButton("C", 8, 8, 33, 81, 0)
$D1 = GUICtrlCreateButton("D", 48, 8, 33, 81, 0)
$E1 = GUICtrlCreateButton("E", 88, 8, 33, 81, 0)
$F1 = GUICtrlCreateButton("F", 128, 8, 33, 81, 0)
$G1 = GUICtrlCreateButton("G", 168, 8, 33, 81, 0)
$A1 = GUICtrlCreateButton("A", 208, 8, 33, 81, 0)
$B1 = GUICtrlCreateButton("B", 248, 8, 33, 81, 0)
$C2 = GUICtrlCreateButton("C", 288, 8, 33, 81, 0)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    If $nMsg = $C1 Then Play("F1")
    If $nMsg = $D1 Then Play("F2")
    If $nMsg = $E1 Then Play("F3")
    If $nMsg = $F1 Then Play("F4")
    If $nMsg = $G1 Then Play("F5")
    If $nMsg = $A1 Then Play("F6")
    If $nMsg = $B1 Then Play("F7")
    If $nMsg = $C2 Then Play("F8")
    If $nMsg = $GUI_EVENT_CLOSE Then Exit
WEnd
Func Play($hotkey = "")
    If $hotkey = "" Then
        $hotkey = @HotKeyPressed
    Else
        $hotkey = "{" & $hotkey & "}"
    EndIf
    Global $beep[8] = [264,297,330,352,396,440,495,523.3]
    Beep($beep[StringTrimLeft(StringTrimRight($hotkey,1),2)-1],500)
    $hotkey = ""
EndFunc
Posted (edited)

Ya know, You are an ass. And an idiot. And a complete freaking waste of time, my time, to talk to. You have no respect for anyone, showing that you have little respect for yourself in the process. Either get your act together or go plague some other Forum. Go to AHK, they might appreciate your caliber of person. *click*

*Bah-Zing* :D

*Gives Kat a HUGE High-5* :P

Thanks too btw :)

That, deserves one of these:

@Thatsgreat

YHBT•YHL•HAND -- If you don't know what it means, google it, you might learn sumfin' :)

Edited by Paulie
Posted

Ya know, YOu are an ass. And an idiot. And a complete freaking waste of time, my time, to talk to. You have no respect for anyone, showing that you have little respect for yourself in the process. Either get your act together or go plague some other Forum. Go to AHK, they might appreciate your caliber of person. *click*

... it was a simple question i wasn't meaning to attack u or something , and i wasn't attacking paulie or anything i was merely stating that there was a faster way he could of performed his script, sorry for making it seem like i was implying something

Posted

... it was a simple question i wasn't meaning to attack u or something , and i wasn't attacking paulie or anything i was merely stating that there was a faster way he could of performed his script, sorry for making it seem like i was implying something

So which was it? a question or a statement? :P
Posted

Thatsgreat, I'm strongly advising you to tone it down a bit. Clearly you're getting on the nerves of a few of the regulars and I'm getting tired of your crap, too. You have a brain, use it. Try thinking before typing for once and see how that works out for you.

  • Moderators
Posted

Oh goody... A "Kat" Fight!!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...