GUI: piano keyboard

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
rommmcek
Posts: 1473
Joined: 15 Aug 2014, 15:18

Re: GUI: piano keyboard

20 May 2018, 04:34

Hi! What's new?

v1.3.3.1R1 - just to show, MouseGetPos gives (nearly) enough info to switch off the note when exiting VK (glissando). Yeah nearly, since it's to slow for quick mouse movements. (had problems calculating the size, hence partially hard coded - adjust if needed)

v1.3.3.1R2 - alternative using underlying transparent Gui. Not very elegant but works, except if exiting and staying on TitleBar.

v1.3.3.1R3 - seems to be the best, using restricted mouse movements. (Again problems with the Gui size as at R1)

- in MouseMove(wP, lP, msg, hwnd) I used Sleep, 0 where you commented Sleep, 1 which is to long (~15ms). If "something happens" script will sleep just the time amount needed (even under ~15ms) otherwise not at all.
- applied WM_Move to track positon & size
- enabled SysMenu (I really missed it)
- added feature (not perfect), while pressing Ctrl-down when performing glissando, two notes are playing simultaneously (see real midi glissando sequence attachment, pressing two to four notes at the same time)

Hope, scripts work and you'll find some ideas interesting!

bye!
Attachments
Scripts 1.3.3.1R1-R3.zip
(36.07 KiB) Downloaded 98 times
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: GUI: piano keyboard

20 May 2018, 07:22

Thanks for taking this further. For the moment I took a break from coding, real life requires some attention as well as other tasks such as backup, home videos conversion and so on.

That Sleep you mentioned was meant to avoid accidental "touch" of an adjacent key while hovering to a far key after a button-up (I probably said that before). Unfortunately it killed glissando's visual feedback and was also unreliable since cursor moving speed is variable. Setting sleep time to zero doesn't help in any way with that particular task so I find it unnecessary.

I do have a newer debug version here, been working on it before the break, where window position and size tracking is somehow simplified. Still too little improvement to warrant publishing it.

Dunno why you'd want SysMenu for the keyboard, one may accidentally trigger it while playing, which would be quite a drag. I wanted it to be distraction-free. But if you really need it then at least make it optional.

About the package:
- R1 seems to work closest to normal.
- R2 hangs badly, doesn't even show the keys, switching focus between windows is very hard, keyboard seems to always lose focus in favor of something else; completely unusable.
- R3 is a pain to work with main window, it always moves cursor to the keyboard window when trying to select an item from some dropdown list, move a slider or any kind of interaction with other controls. It does confine the cursor to the keys rectangle when left button down, so at least that part works correctly.
- Can't get the glissando script produce anything but an endless low note, more like a humming sound; could be the virtual MIDI driver/application (CoolSoft VirtualMIDISynth 2.3.2.0, 2.4.2.0 won't work correctly in XP) that interferes, but good thing it has a 'panic' option in the tray menu that kills all notes on all channels, otherwise the MIDI would humm indefinitely.

That's all for now.
Part of my AHK work can be found here.
User avatar
rommmcek
Posts: 1473
Joined: 15 Aug 2014, 15:18

Re: GUI: piano keyboard

07 Jul 2018, 17:56

Found out (I hope), why Klavier Player 2010_U_Grease_Glissando_sequence.ahk didn't work on x32 Ahk (Thanks jeeswg for hint)
R2 - was found completely unusable and I think it was not very elegant! Now is a bit better.
R3 - was not difficult to improve. (Bi-glissando is integrated - when pressing Ctrl - far from being perfekt, though)

Q: Why is Klavier Hero good? A: For playing music! Q: How? A: See below if you know touch typing!

This is refrain:
1. qwerty:
r y r w y t
q e r t e q t r
2. qwertz:
r z r w z t
q e r t e q t r
3. awerty:
r y r w y t
a e r t e a t r

Run nelly-dilemma_feat_kelly_lsz.ahk, remember the rhythm, run Klavier Hero and type the text above in the rhythm!
Attachments
Files.zip
(36.1 KiB) Downloaded 75 times
User avatar
rommmcek
Posts: 1473
Joined: 15 Aug 2014, 15:18

Re: GUI: piano keyboard

24 Aug 2018, 20:24

Hi!

Code: Select all

	if !HKL := DllCall("user32\LoadKeyboardLayout" AW     ; This DllCall() seems to be the culprit
		, "Str", KLID
		, "UIntP", 0x80 ; KLF_NOTELLSHELL             ; Type UInt seems to be wrong, UIntP or UInt* look better
		, "Ptr")
		HKL := currHKL
P.s.: This might look like I became an DllCall Type expert, but no way, that Type I learned from Drugwash's Klavier Hero version.
Attachments
LayoutList.ahk
(5.4 KiB) Downloaded 79 times
User avatar
rommmcek
Posts: 1473
Joined: 15 Aug 2014, 15:18

Re: GUI: piano keyboard

25 Aug 2018, 18:00

That UIntP was rubbish!, it just disables DllCall.
Now I'm running the Hero w/o If statement.
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: GUI: piano keyboard

31 Aug 2018, 06:55

A pure number can't get assigned a "UIntP" type. Obviously the call would fail in that case.
If you don't get the call to return a valid HKL it may be due to an invalid KLID (should be a string of type XXXXYYYY, such as 04090409) or the AW variable isn't declared (do you call updates() at the beginning of the script or declare AW := A_IsUnicode ? "W" : "A" ?)
Part of my AHK work can be found here.
User avatar
rommmcek
Posts: 1473
Joined: 15 Aug 2014, 15:18

Re: GUI: piano keyboard

04 Sep 2018, 05:21

- The only problem I have with Hero is the old one: It corrupts my OS when using "Show hints on keys" & "Show preview when switching layouts".
- Disabling the DllCall for LoadKeyboardLayout seemingly cured the problem. (later I noticed it only mitigates it)
- Logical next step was disabling DllCall for UnloadKeyboardLayout and it looks promising.
- I didn't noticed any functionality loss, but I think there was some memory leakage.
- after ca. 10000 (ten thousand) loads & reloads, the load time was constant under 0.5 sec.
- after the test "memory in use" in Task Manager was ca. 1G increased.
- then with enabled both DllCall-s, the load time was 1.2 sec, which is equal to fresh restarted OS.
Test: These are the last three lines of autoexecute section of the Hero:

Code: Select all

MsgBox,,, % A_TickCount - dbgT, 1
reload
return
running it for ca. 6 hours.
Attachments
LayoutList.ahk
(5.4 KiB) Downloaded 81 times
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: GUI: piano keyboard

06 Sep 2018, 00:42

Unfortunately I'm completely disconnected with this script (and AHK generally), and I forgot everything I've done with it. :(
Additionally I've removed all keyboard layouts except for RO because some applications started acting weirdly, and I don't plan on reinstalling any in the near future.
I'm afraid you're on your own with this one. Sorry.
Part of my AHK work can be found here.
User avatar
rommmcek
Posts: 1473
Joined: 15 Aug 2014, 15:18

Re: GUI: piano keyboard

09 Sep 2018, 14:04

No need to be sorry! I'm happy with unconventional "bug fix" I made and even if memory leakage is real (have no knowledge to confirm that), I think for normal usage its neglectable.
Thanks for your valuable contribution!

bye!
stephaniesu01
Posts: 1
Joined: 25 Jun 2019, 22:37

Re: GUI: piano keyboard

26 Jun 2019, 00:20

This is inspiring! By the way, I just want to share my article I hope you check it out. This is something for people who want to start learning the piano or somehow learn the keyboards layout.
Heres the link: Let me know what you think.https musicadvisor.com /top-10-piano-chords/ Broken Link for safety

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: dipahk and 247 guests