Sign in to follow this  
Followers 0
Skitty

Piano

12 posts in this topic

#1 ·  Posted (edited)

When I saw by user sandin, I was upset that I don't have an midi keyboard so I made a piano script I can click on instead.

I took code from sandins script to make this of course, specifically the part that creates the keys, although I did modify it slightly.

Download it using one of the html files below because I'm one of those

annoying people that like to keep track of their downloads.

Piano Time.html

Alternativly, download it for the Alpha release of AutoIt.

This script uses the new syntax changes implemented in the alpha autoit version.

Piano Time.html - For AutoIt (v3.3.9.5)

Edited by ApudAngelorum
1 person likes this

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Alternatively, here is a UDF version (Piano UDF.html) that you can just include and create notes.

Here is an example of how to use it, it should play something that sounds loosely like Beethovens Moonlight Sonata.

#include "Piano.au3"
Note($gs2,850)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)

Note($cs1)
Note($cs2)
Note($gs2,650)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)

Note($b0)
Note($b1)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)

Note($a0)
Note($a1)
Note($a2,500)
Note($cs3,500)
Note($e3,500)
Note($a2,500)
Note($cs3,500)
Note($e3,500)

Note($fs0)
Note($fs1)
Note($a2,500)
Note($d3,500)
Note($fs3,500)
Note($a2,500)
Note($d3,500)
Note($fs3,500)

Note($gs0)
Note($gs1)
Note($gs2,500)
Note($c3,500)
Note($fs3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)

Note($gs0)
Note($gs1)
Note($gs2,500)
Note($cs3,500)
Note($ds3,500)
Note($fs2,500)
Note($c3,500)
Note($ds3,500)

Note($cs0)
Note($gs1)
Note($cs2)
Note($e2,500)
Note($gs2,500)
Note($cs3,500)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)

Note($gs3)
Note($gs2,500)
Note($cs3,500)
Note($e3,500)

Note($gs3)
Note($gs2,230)

Note($c0)
Note($c1)
Note($gs2)
Note($gs1)
Note($gs2,500)
Note($cs3,500)
Note($fs3,500)
Note($gs2,500)
Note($cs3,500)
Note($fs3,500)
Note($gs2,500)
Note($cs3,500)
Note($fs3,500)

Note($cs0)
Note($cs1)
Note($gs2)
Note($gs3,500)
Note($cs3,500)
Note($e3,500)

Note($gs3)
Note($gs2,500)

Note($gs2)
Note($cs0)
Note($cs1)
Note($gs3,500)
Note($cs3,500)
Note($e3,500)

Note($fs0)
Note($fs1)
Note($a3)
Note($a2,500)
Note($cs2,500)
Note($fs3,500)

Note($b1)
Note($b2)
Note($gs2)
Note($gs3,250)
Note($gs6,400)
Note($gs5,250)
Note($b3,500)
Note($e3,500)

Note($b1)
Note($b2)
Note($a3)
Note($fs4,1300)

Note($e1)
Note($e2)
Note($gs2)
Note($e3,0,1)

Here are some other scripts to play some other random stuff

#include "Piano.au3"

Note($d2)
Note($a2)
Note($d3,250)

Note($a2)
Note($a1)
Note($e3,300)

Note($a2)
Note($f1)
Note($f3,800)

Note($a2)
Note($d2)
Note($d3,1500)


Note($a2)
Note($a3)
Note($e4,300)

Note($f2)
Note($f3)
Note($f4,800)

Note($d2)
Note($d1)
Note($f2,700)

Note($a3)
Note($f2)
Note($f1)
Note($a4,1500)


Note($d2)
Note($a2)
Note($d3,250)

Note($a2)
Note($a1)
Note($e3,300)

Note($f3)
Note($f1)
Note($f5,800)

Note($d2)
Note($d1)
Note($f2,1000)


Note($d2)
Note($a2)
Note($d3,250)

Note($a2)
Note($a1)
Note($e3,300)

Note($a2)
Note($f1)
Note($f3,800)

Note($a1)
Note($a2)
Note($a3)
Note($a4,800)

Note($c2)
Note($c3)
Note($c4)
Note($c5,800)

Note($d2)
Note($d3)
Note($d4)
Note($d5,1800)

Note($d0)
Note($d1)
Note($d2)
Note($d3,0,1)

#include "Piano.au3"

Note($d2,250)
Note($a2,250)
Note($f2,250)
Note($a2,250)
Note($d2,250)
Note($a2,250)
Note($f2,250)
Note($a2,250)
Note($d2,250)
Note($a2,250)
Note($f2,250)
Note($a2,250)

Note($a1,250)
Note($c3,250)
Note($a2,250)
Note($c3,250)
Note($a1,250)
Note($c3,250)
Note($a2,250)
Note($c3,250)
Note($a1,250)
Note($c3,250)
Note($a2,250)
Note($c3,250)

Note($f1,250)
Note($f2,250)
Note($a2,250)
Note($f2,250)
Note($f1,250)
Note($f2,250)
Note($a2,250)
Note($f2,250)
Note($f1,250)
Note($f2,250)
Note($a2,250)
Note($f2,250)

Note($d1)
Note($d2,250)
Note($d3,250)
Note($a2,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($a2,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($a2,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($a2,250)
Note($d3,250)

Note($d2,250)
Note($d5,250)
Note($d4,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($d5,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($d4,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($d6,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($a3,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($a3,250)
Note($d3,250)
Note($d2,250)
Note($d3,250)
Note($a3,250)
Note($d3,250)
Note($as0)
Note($d2)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)

Note($d1)
Note($d2)
Note($a2,250)
Note($d3,250)
Note($a3,250)
Note($d3,250)
Note($a2,250)
Note($d3,250)
Note($a3,250)
Note($d3,250)
Note($a2,250)
Note($d3,250)
Note($a3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($as2,250)
Note($d3,250)
Note($as3,250)
Note($d3,250)
Note($d1)
Note($d2,250)
Note($d3,250)
Note($f3,250)
Note($d3,250)
Note($d1)
Note($d2,250)
Note($d3,250)
Note($f3,250)
Note($d3,250)
Note($d1)
Note($d2,250)
Note($d3,250)
Note($f3,250)
Note($d3,250)

Note($d2,150)
Note($f4,150)
Note($c3,150)
Note($d3,2500)
Edited by ApudAngelorum

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

I haven't tried the alpha release yet, but I did look at your code. You are less likely to get a responce because less people are using the alpha release. I do like the GUI by sandin. It's one of the best I've seen on this forum. I will try running your script some time in the near future. ;)

Share this post


Link to post
Share on other sites

You are less likely to get a responce because less people are using the alpha release.

I figured that, so I made a version that was compatible with the current release (both scripts do the same thing but the version for the current release is a little bigger), which is the first download.

And yes, sandins piano is pretty cool, although I don't have an midi keyboard to test it.


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

RE: examples

wow!

I'm thinking: Random (within a given MAJ7th)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I finaly got a bit of time to look at this. It sounds good. The note samples are good quality. The only drawback is there being a slaight delay between clicking the key and hearing the note. (I'm not sure if you can do much about that) I like what you've done.

LOL I just tried the UDF version. There's something wrong with the Beethoven example.

Edited by czardas

Share this post


Link to post
Share on other sites

RE: examples

wow!

I'm thinking: Random (within a given MAJ7th)

I googled MAJ7th to see what it was and got a bunch of videos about teenagers playing their electric guitar, lol

I finaly got a bit of time to look at this. It sounds good. The note samples are good quality. The only drawback is there being a slaight delay between clicking the key and hearing the note. (I'm not sure if you can do much about that) I like what you've done.

LOL I just tried the UDF version. There's something wrong with the Beethoven example.

About the delay, yeah, I know.

I tried finding a way to have the sound play as soon as the key was hit and not released, but I didn't put much time into that and didn't get far either.

As for the Beethoven example, I'm not a professional so expect that


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

With some playing around, It became apparent that pure random selection of notes sounds like.....other than music.

So instead I took your third example, changed the phrases into functions that are selected at random.

Musical phrases played at random is called "jamming" (assuming the phrases go well together).

So....with any apologies required extended in advance, I present "APUDANGELORUMs' third" (example)

#include "Piano.au3"
Local $phrases[10] = [ _
"aa", _
"a2", _
"bb", _
"b2", _
"cc", _
"c2", _
"dd", _
"d2", _
"ee", _
"ff" _
]
While 1
Call($phrases[Random(0, UBound($phrases) - 1, 1)])    ; jchd     Posted 09 June 2011 - 09:33 AM
WEnd
Func aa()
Note($d0, 250);d2
Note($a2, 250)
Note($f2, 250)
Note($a2, 250)
Note($d2, 250)
Note($a2, 250)
Note($f2, 250)
Note($a2, 250)
Note($d2, 250)
Note($a2, 250)
Note($f2, 250)
Note($a2, 250)
EndFunc   ;==>aa
Func a2();inversion of aa
Note($a2, 250)
Note($d2, 250)
Note($a2, 250)
Note($f2, 250)
Note($a2, 250)
Note($d2, 250)
Note($a2, 250)
Note($f2, 250)
Note($a2, 250)
Note($d2, 250)
Note($a2, 250)
Note($f2, 250)
EndFunc   ;==>aa
Func bb()
Note($a1, 250);12
Note($c3, 250);11
Note($a2, 250);10
Note($c3, 250);9
Note($a1, 250);8
Note($c3, 250);7
Note($a2, 250);6
Note($c3, 250);5
Note($a1, 250);4
Note($c3, 250);3
Note($a2, 250);2
Note($c3, 250);1
EndFunc   ;==>bb
Func b2();reversal of bb
Note($c3, 250);1
Note($a2, 250);2
Note($c3, 250);3
Note($a1, 250);4
Note($c3, 250);5
Note($a2, 250);6
Note($c3, 250);7
Note($a1, 250);8
Note($c3, 250);9
Note($a2, 250);10
Note($c3, 250);11
Note($a1, 250);12
EndFunc   ;==>bb
Func cc()
Note($f1, 250);12
Note($f2, 250);11
Note($a2, 250);10
Note($f2, 250);9
Note($f1, 250);8
Note($f2, 250);7
Note($a2, 250);6
Note($f2, 250);5
Note($f1, 250);4
Note($f2, 250);3
Note($a2, 250);2
Note($f2, 250);1
EndFunc   ;==>cc
Func c2();reversal of cc with a twist
Note($f2, 250);1
Note($a2, 250);2
Note($f2, 250);3
Note($f1, 250);4
Note($f2, 250);5
Note($a2);6
Note($f2, 250);7
Note($f1, 500);8
Note($f2, 250);9
Note($a2, 250);10
Note($f2, 250);11
Note($f1, 250);12
EndFunc   ;==>cc
Func dd()
Note($d1)
Note($d2, 250)
Note($d3, 240)
Note($a2, 250)
Note($d3, 260)
Note($d2, 220)
Note($d3, 250)
Note($a2, 250)
Note($d3, 280)
Note($d2, 250)
Note($d3, 250)
Note($a2, 250)
Note($d3, 240)
Note($d2, 260)
Note($d3, 250)
Note($a2, 250)
Note($d3, 250)
EndFunc   ;==>dd
Func d2();dd cut in half & flopped only to discover it was symmetrical - so I added timing imperfections
;I think minor timing imperfections remove that "machine-made" sound
Sleep(1000)
Note($d2, 250)
Note($d3, 250)
Note($a2, 210)
Note($d3, 250)
Note($d2, 290)
Note($d3, 250)
Note($a2, 250)
Note($d3, 250)
Note($d1)
Note($d2, 250)
Note($d3, 220)
Note($a2, 250)
Note($d3, 300)
Note($d2, 250)
Note($d3, 250)
Note($a2, 200)
Note($d3, 350)
EndFunc   ;==>dd
Func ee();though not really that funk-ee, more along the lines of sweet
Note($d2, 250)
Note($d5, 230)
Note($d4, 260)
Note($d3, 250)
Note($d2, 250)
Note($d3, 230)
Note($d5, 250)
Note($d3, 260)
Note($d2, 250)
Note($d3, 250)
Note($d4, 250)
Note($d3, 220)
Note($d2, 270)
Note($d3, 250)
Note($d6, 250)
Sleep(400)
Note($d3, 250)
Note($d2, 250)
Note($d3, 250)
Note($a3, 230)
Note($d3, 250)
Note($d2, 260)
Note($d3, 250)
Note($a3, 250)
Note($d3, 240)
Note($d2, 260)
Note($d3, 250)
Note($a3, 250)
Note($d3, 250)
Note($as0)
Note($d2)
Note($as2, 250)
Note($d3, 250)
Note($as3, 250)
Note($d3, 250)
Note($as2, 250)
Note($d3, 250)
Note($as3, 250)
Note($d3, 250)
Note($as2, 250)
Note($d3, 250)
Note($as3, 250)
Note($d3, 250)
Note($as2, 250)
Note($d3, 250)
Note($as3, 250)
Note($d3, 250)
EndFunc   ;==>ee
Func ff()
Note($d1)
Note($d2)
Note($a2, 250)
Note($d3, 210)
Note($a3, 250)
Note($d3, 290)
Note($a2, 250)
Note($d3, 250)
Note($a3, 250)
Note($d3, 250)
Note($a2, 250)
Note($d3, 250)
Note($a3, 250)
Note($d3, 250)
Note($as2, 220)
Note($d3, 250)
Note($as3, 280)
Note($d3, 250)
Note($as2, 250)
Note($d3, 250)
Note($as3, 250)
Note($d3, 250)
Note($as2, 230)
Note($d3, 250)
Note($as3, 270)
Note($d3, 250)
Note($as2, 250)
Note($d3, 250)
Note($as3, 250)
Note($d3, 250)
Note($d1)
Note($d2, 250)
Note($d3, 250)
Note($f3, 250)
Note($d3, 250)
Note($d1)
Note($d2, 250)
Note($d3, 230)
Note($f3, 270)
Note($d3, 250)
Note($d1)
Note($d2, 250)
Note($d3, 250)
Note($f3, 250)
Note($d3, 250)
Note($d2, 350)
Note($f4, 295)
Note($c3, 310)
Note($d3, 2500)
Note($d2)
Note($f4)
Note($c3)
Note($d3, 1500)
EndFunc   ;==>ff

Share this post


Link to post
Share on other sites

ha, nice.

it's like a continuously variable CD or something, always playing something different, or at least the same tune but in different order.


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

I just tried version written for alpha and it's not working with dev version of AutoIt. There are two major problems.

First one is GUIRegisterMsg line. $WM_COMMAND is variable declared with "$", so in order to be certain that you want to reference exactly that variable you have to use "$". Otherwise you are referencing function named WM_COMMAND (that you happen to have defined). That means your GUIRegisterMsg fails.

Second problem is WM_COMMAND function definition. First param is "hwnd" which is not allowed considering it collides with built-in function name.

Corrected code would be:

AutoPiano.au3

...And yes, it would be nicer if sound would play on mouse down.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Note taken.

Also, here is an alternative version that will play when mouse is down.

#AutoIt3Wrapper_Run_AU3Check=n
#include <Sound.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <winapi.au3>
Global InitialVolume = 30
AutoItSetOption("GUIOnEventMode", 1)
AutoItSetOption("MustDeclareVars",0)
AutoItSetOption("GUIResizeMode",1)
SoundSetWaveVolume(InitialVolume)
PianoUI = GUICreate("AutoIt Piano Time", 995, 115, -1, -1, BitOR(WS_CAPTION, WS_SYSMENU), WS_EX_DLGMODALFRAME)
_DestroyIcon(PianoUI); give UI a nice sleek looking title bar
GUISetOnEvent(-3, "Terminate")
Global volume = GUICtrlCreateSlider(973, 0, 20, 114, 0x0002)
GUICtrlSetLimit(-1,100,0)
GUICtrlSetData(-1,100-InitialVolume)
GUICtrlSetOnEvent(-1,"SetVolume")
Global buttons[2][100]
MakeButtons(); make buttons...
Global a_0 = _SoundOpen(@ScriptDir&"notesa-1.wav.mp3")
Global d_0 = _SoundOpen(@ScriptDir&"notesb-1.wav.mp3")
Global as_1 = _SoundOpen(@ScriptDir&"notesas-1.wav.mp3")
_SoundManager(1);create global vars
GUISetState(@SW_SHOW)
_SoundManager(2);load sounds

Global Const MSLLHOOKSTRUCT = tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
;Register callback
hMousProc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")
hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", WH_MOUSE_LL, "ptr", DllCallbackGetPtr(hMousProc), "hwnd", hM_Module[0], "dword", 0)

Func _Mouse_Proc(nCode, wParam, lParam)
    Local info, mouseData, time, timeDiff
    If nCode < 0 Then
        ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", hM_Hook[0], _
                "int", nCode, "ptr", wParam, "ptr", lParam)
        Return ret[0]
    EndIf
    info = DllStructCreate(MSLLHOOKSTRUCT, lParam)
    mouseData = DllStructGetData(info, 3)
    time = DllStructGetData(info, 5)
    Switch wParam
  Case WM_LBUTTONDOWN
   Local Ctrl = GUIGetCursorInfo()
   HitNote(Ctrl[4])
    EndSwitch
    ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", hM_Hook[0], _
            "int", nCode, "ptr", wParam, "ptr", lParam)
    Return ret[0]
EndFunc   ;==>_Mouse_Proc

#cs - Melodies -
#region - some asian sounding melody -
  Note(d4,300)
  Note(f4,300)
  Note(g4,300)
  Note(a4,300)
  Note(g4,300)
  Note(f4,600)
  Note(c5,500)
  Note(d5,500)
  Note(a4,1000)
  Note(f4,500)
  Note(c4,500)
  Note(d4,2000)
#endregion - some asian sounding melody -
#region - some sound my ancient grandfather clock makes -
  Note(e2,400)
  Note(c2,400)
  Note(d2,400)
  Note(g1,1300)
  Note(g1,400)
  Note(d2,400)
  Note(e2,400)
  Note(c2,2000)
#endregion - some sound my ancient grandfather clock makes -
#region - xfiles theme -
  Note(a3,50)
  Note(c4,100)
  Note(e4,100)
  Note(f4,200)
  Note(e4,150)
  Note(c4,150)
  Note(f4,200)
  Note(e4,200)
  Note(c4,200)
  Note(f4,200)
  Note(e4,200)
  Note(c4,200)
  ;----------
  Note(a3,50)
  Note(c4,100)
  Note(e4,100)
  Note(f4,200)
  Note(e4,150)
  Note(c4,150)
  Note(f4,200)
  Note(e4,200)
  Note(c4,200)
  Note(f4,200)
  Note(e4,200)
  Note(c4,1000)
  ;----------
  Note(a3,350)
  Note(e4,320)
  Note(d4,350)
  Note(e4,300)
  Note(g4,380)
  Note(e4,1000)
  Note(a3,380)
  Note(e4,320)
  Note(d4,350)
  Note(e4,300)
  Note(a4,380)
  Note(e4,1000)
  Note(c5,200)
  Note(b4,280)
  Note(a4,280)
  Note(g4,280)
  Note(a4,350)
  Note(e4,1000)
  Note(a3,50)
  Note(c4,100)
  Note(e4,100)
  Note(f4,200)
  Note(e4,150)
  Note(c4,150)
  Note(f4,400)
  Note(e4,400)
  Note(c4,400)
  Note(f4,400)
  Note(e4,400)
  Note(c4,400)
#endregion - xfiles theme -
#ce - Melodies -
Sleep(10000000)
Func Note(i,x=0)
_SoundSeek(i, 0, 0, 0)
_SoundPlay(i,0)
Sleep(x)
Return
EndFunc
Func SetVolume()
SoundSetWaveVolume((100-GUICtrlRead(volume)))
EndFunc
Func _DestroyIcon(hWindow);thanks to guiness and yashied for this
Local Ret
If @AutoItX64 Then
  Ret = DllCall('user32.dll', 'ulong_ptr', 'GetClassLongPtrW', 'hWindow', hWindow, 'int', -14)
Else
  Ret = DllCall('user32.dll', 'ulong', 'GetClassLongW', 'hWindow', hWindow, 'int', -14)
EndIf
If (@error) Or (Not Ret[0]) Then
  Return SetError(1, 0, 0)
EndIf
DllCall("user32.dll", "bool", "DestroyIcon", "handle", Ret[0])
If @AutoItX64 Then
  Ret = DllCall('user32.dll', 'ulong_ptr', 'SetClassLongPtrW', 'hWindow', hWindow, 'int', -14, 'long_ptr', 0)
Else
  Ret = DllCall('user32.dll', 'ulong', 'SetClassLongW', 'hWindow', hWindow, 'int', -14, 'long', 0)
EndIf
If (@error) Or (Not Ret[0]) Then
  Return SetError(1, 0, 0)
EndIf
If @AutoItX64 Then
  Ret = DllCall('user32.dll', 'ulong_ptr', 'SetClassLongPtrW', 'hWindow', hWindow, 'int', -34, 'long_ptr', 0)
Else
  Ret = DllCall('user32.dll', 'ulong', 'SetClassLongW', 'hWindow', hWindow, 'int', -34, 'long', 0)
EndIf
If (@error) Or (Not Ret[0]) Then
  Return SetError(1, 0, 0)
EndIf
Return Ret[0]
EndFunc   ;==>_WinAPI_GetClassLongEx
Func _SoundManager(DoWhat)
    Local Letters = ['a','b','c','d','e','f','g'], Num = -1, Num2 = -1
  For x = 0 To 6
   For y = 0 To 6
    Switch DoWhat
     Case 1
      Assign(Letters[x]&y, 0, 2)
     Case 2
      Assign(Letters[x]&y, _SoundOpen(@ScriptDir&"notes"&Letters[x]&y&".wav.mp3"),2)
      If Not(x) Then _SoundPlay(Eval(Letters[x]&y),0)
      Num += 1
      GUICtrlSetState(Buttons[0][Num],64)
     Case 0
      _SoundClose(Eval(Letters[x]&y))
    EndSwitch
    Switch x
     Case 0,2,3,5,6
      Switch DoWhat
       Case 1
        Assign(Letters[x]&"s"&y, 0, 2)
       Case 2
        Assign(Letters[x]&"s"&y, _SoundOpen(@ScriptDir&"notes"&Letters[x]&"s"&y&".wav.mp3"),2)
        ;_SoundPlay(Eval(Letters[x]&y),0)
        Num2 += 1
        GUICtrlSetState(Buttons[1][Num2],64)
       Case 0
        _SoundClose(Eval(Letters[x]&y))
      EndSwitch
    EndSwitch
   Next
  Next
  If DoWhat = 2 Then
   GUICtrlSetState(Buttons[0][num+1],64)
   GUICtrlSetState(Buttons[0][num+2],64)
  EndIf
Return
EndFunc
Func MakeButtons(x_coord = 2, y_coord = 2, NumButt = 87)
Local x_upper = x_coord-8
Local gw = 16, gh = 70
Local zw = 20, zh = 110
Local ibuttons = 0, b_count = 0
For x = 0 To 1
  For i = 1 To NumButt
   b_count = (b_count<12) ? b_count+1 : 1
   Switch x
    Case 0
     Switch b_count
      Case 2,5,7,10,12
       x_upper += (b_count = 5 Or b_count = 10) ? ((gw+3)*2) : (gw+3)
       buttons[1][ibuttons] = GUICtrlCreateButton("", x_upper, y_coord, gw, gh, WS_CLIPSIBLINGS)
       GUICtrlSetBkColor(-1, 0x222222)
       ibuttons += 1
       GUICtrlSetState(-1, 128)
       GUICtrlSetCursor(-1, 0)
     EndSwitch
    Case 1
     Switch b_count
      Case 1,3,4,6,8,9,11
       buttons[0][ibuttons] = GUICtrlCreateButton("", x_coord, y_coord, zw, zh, WS_CLIPSIBLINGS)
       x_coord += zw-1
       ibuttons += 1
       GUICtrlSetState(-1, 128)
       GUICtrlSetCursor(-1, 0)
     EndSwitch
   EndSwitch
  Next
  b_count = 1
  ibuttons = 0
Next
Return
EndFunc
Func Terminate()
_SoundManager(0)
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", hM_Hook[0])
    DllCallbackFree(hMousProc)
Exit
EndFunc
Func HitNote(CTRL)
ConsoleWrite(CTRL&@CR)
   Switch CTRL
    Case Buttons[0][0]
     Note(a_0)
    Case Buttons[0][1]
     Note(d_0)
    Case Buttons[1][0]; that one oddly placed key to the left
     Note(as_1)
    Case Buttons[0][2]
     Note(c0)
    Case Buttons[0][3]
     Note(d0)
    Case Buttons[0][4]
     Note(e0)
    Case Buttons[0][5]
     Note(f0)
    Case Buttons[0][6]
     Note(g0)
    Case Buttons[0][7]
     Note(a0)
    Case Buttons[0][8]
     Note(b0)

    Case Buttons[0][9]
     Note(c1)
    Case Buttons[0][10]
     Note(d1)
    Case Buttons[0][11]
     Note(e1)
    Case Buttons[0][12]
     Note(f1)
    Case Buttons[0][13]
     Note(g1)
    Case Buttons[0][14]
     Note(a1)
    Case Buttons[0][15]
     Note(b1)

    Case Buttons[0][16]
     Note(c2)
    Case Buttons[0][17]
     Note(d2)
    Case Buttons[0][18]
     Note(e2)
    Case Buttons[0][19]
     Note(f2)
    Case Buttons[0][20]
     Note(g2)
    Case Buttons[0][21]
     Note(a2)
    Case Buttons[0][22]
     Note(b2)
    Case Buttons[0][23]
     Note(c3)
    Case Buttons[0][24]
     Note(d3)
    Case Buttons[0][25]
     Note(e3)
    Case Buttons[0][26]
     Note(f3)
    Case Buttons[0][27]
     Note(g3)
    Case Buttons[0][28]
     Note(a3)
    Case Buttons[0][29]
     Note(b3)
    Case Buttons[0][30]
     Note(c4)
    Case Buttons[0][31]
     Note(d4)
    Case Buttons[0][32]
     Note(e4)
    Case Buttons[0][33]
     Note(f4)
    Case Buttons[0][34]
     Note(g4)
    Case Buttons[0][35]
     Note(a4)
    Case Buttons[0][36]
     Note(b4)
    Case Buttons[0][37]
     Note(c5)
    Case Buttons[0][38]
     Note(d5)
    Case Buttons[0][39]
     Note(e5)
    Case Buttons[0][40]
     Note(f5)
    Case Buttons[0][41]
     Note(g5)
    Case Buttons[0][42]
     Note(a5)
    Case Buttons[0][43]
     Note(b5)
    Case Buttons[0][44]
     Note(c6)
    Case Buttons[0][45]
     Note(d6)
    Case Buttons[0][46]
     Note(e6)
    Case Buttons[0][47]
     Note(f6)
    Case Buttons[0][48]
     Note(g6)
    Case Buttons[0][49]
     Note(a6)
    Case Buttons[0][50]
     Note(b6)
    Case Buttons[1][1]
     Note(cs0)
    Case Buttons[1][2]
     Note(ds0)
    Case Buttons[1][3]
     Note(fs0)
    Case Buttons[1][4]
     Note(gs0)
    Case Buttons[1][5]
     Note(as0)
    Case Buttons[1][6]
     Note(cs1)
    Case Buttons[1][7]
     Note(ds1)
    Case Buttons[1][8]
     Note(fs1)
    Case Buttons[1][9]
     Note(gs1)
    Case Buttons[1][10]
     Note(as1)
    Case Buttons[1][11]
     Note(cs2)
    Case Buttons[1][12]
     Note(ds2)
    Case Buttons[1][13]
     Note(fs2)
    Case Buttons[1][14]
     Note(gs2)
    Case Buttons[1][15]
     Note(as2)
    Case Buttons[1][16]
     Note(cs3)
    Case Buttons[1][17]
     Note(ds3)
    Case Buttons[1][18]
     Note(fs3)
    Case Buttons[1][19]
     Note(gs3)
    Case Buttons[1][20]
     Note(as3)
    Case Buttons[1][21]
     Note(cs4)
    Case Buttons[1][22]
     Note(ds4)
    Case Buttons[1][23]
     Note(fs4)
    Case Buttons[1][24]
     Note(gs4)
    Case Buttons[1][25]
     Note(as4)
    Case Buttons[1][26]
     Note(cs5)
    Case Buttons[1][27]
     Note(ds5)
    Case Buttons[1][28]
     Note(fs5)
    Case Buttons[1][29]
     Note(gs5)
    Case Buttons[1][30]
     Note(as5)
    Case Buttons[1][31]
     Note(cs6)
    Case Buttons[1][32]
     Note(ds6)
    Case Buttons[1][33]
     Note(fs6)
    Case Buttons[1][34]
     Note(gs6)
    Case Buttons[1][35]
     Note(as6)
   EndSwitch
EndFunc   ;==>WM_COMMAND

I got the code for the mouse down detection

Edited by ApudAngelorum

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0