sandin Posted January 29, 2009 Share Posted January 29, 2009 I have this script: #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 416, 172) $Button1 = GUICtrlCreateButton("Button1", 24, 16, 185, 41) $Button2 = GUICtrlCreateButton("Button2", 72, 32, 217, 49) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSEoÝ÷ Ú+-êÞk²¶hrFî¶Ú'ÚÚy©pk+nÞnëm¢}m+"²Ø^²n¶*'!Ê.×(ë©Â+anëHÁ©íóÆî¶Ú'²k¬Æ¥ì¡ªÝì¬y²±Êâ¦Û(¶¬Éè¶Ø^më-²n¶*'jëh×6#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 416, 172) $Button1 = GUICtrlCreateButton("Button1", 24, 16, 185, 41) $form2 = GUICreate("", 217, 49, 72, 55, $WS_POPUP, $WS_EX_MDICHILD, $form1) WinSetTrans($form2, "", 255) GUISetState(@SW_SHOW, $form2) $Button2 = GUICtrlCreateButton("Button2", 0, 0, 217, 49) GUISetState(@SW_SHOW, $form1) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Spiff59 Posted January 29, 2009 Share Posted January 29, 2009 (edited) Hmm, I looked around and didnt see anyone who'd made a functional piano keyboard, but then I might have missed something somewhere... You would think someone would have had to have done that in the past (a few times). I did come across someone who'd simply drawn images of the keys in the gui, but it had no functionality, and suffers from your problem as well, handling stuff that's overlapped. It seemed to me that splitting your white keys into 3 stripes was the way to go and I came up with this: expandcollapse popup#include <GUIConstants.au3> #include <array.au3> HotKeySet("{ESC}","exiting") $mainGui = GUICreate("piano keyboard by spiff59",400,300) ; key type, left, title Dim $KeyTbl[15][3] = [[0,0,""],[0,40,"C"],[1,65,"C#"],[0,80,"D"],[1,105,"D#"],[0,120,"E"],[0,160,"F"],[1,185,"F#"], _ [0,200,"G"], [1,225,"G#"],[0,240,"A"],[1,265,"A#"],[0,280,"B"],[0,320,"C"], [0,0,""]] Dim $ImgFull[3] = [10,15,170]; top, width, height Dim $ImgHalf[3] = [110,15,70] Dim $ImgCntr[3] = [10,9,170] Dim $Key_Buttons[15][3] For $x = 1 to 13 If $KeyTbl[$x][0] = 0 Then ; White key $left = $KeyTbl[$x][1] If $KeyTbl[$x-1][0] = 0 Then; left stripe $Key_Buttons[$x][0] = GUICtrlCreateGraphic($left,$ImgFull[0],$ImgFull[1],$ImgFull[2]); left, top, width, height Else $Key_Buttons[$x][0] = GUICtrlCreateGraphic($left,$ImgHalf[0],$ImgHalf[1],$ImgHalf[2]) EndIf GUICtrlSetBkColor($Key_Buttons[$x][0],0xFFFFFF) $left += $ImgFull[1] $Key_Buttons[$x][1] = GUICtrlCreateGraphic($left,$ImgCntr[0],$ImgCntr[1],$ImgCntr[2]); center stripe GUICtrlSetBkColor($Key_Buttons[$x][1],0xFFFFFF) $left += $ImgCntr[1] If $KeyTbl[$x+1][0] = 0 Then; right stripe $Key_Buttons[$x][2] = GUICtrlCreateGraphic($left,$ImgFull[0],$ImgFull[1],$ImgFull[2]) Else $Key_Buttons[$x][2] = GUICtrlCreateGraphic($left,$ImgHalf[0],$ImgHalf[1],$ImgHalf[2]) EndIf GUICtrlSetBkColor($Key_Buttons[$x][2],0xFFFFFF) Else ; Black key $Key_Buttons[$x][0] = GUICtrlCreateGraphic($KeyTbl[$x][1],10,30,100) GUICtrlSetBkColor($Key_Buttons[$x][0],0) EndIf Next GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $Key_Buttons[1][0],$Key_Buttons[1][1],$Key_Buttons[1][2] Tooltip("KEY 1 - " & $KeyTbl[1][2]) Beep(264, 200) Case $Key_Buttons[2][0] Tooltip("KEY 2 - " & $KeyTbl[2][2]) Beep(280.5, 200) Case $Key_Buttons[3][0],$Key_Buttons[3][1],$Key_Buttons[3][2] Tooltip("KEY 3 - " & $KeyTbl[3][2]) Beep(297, 200) Case $Key_Buttons[4][0] Tooltip("KEY 4 - " & $KeyTbl[4][2]) Beep(313.5, 200) Case $Key_Buttons[5][0],$Key_Buttons[5][1],$Key_Buttons[5][2] Tooltip("KEY 5 - " & $KeyTbl[5][2]) Beep(330, 200) Case $Key_Buttons[6][0],$Key_Buttons[6][1],$Key_Buttons[6][2] Tooltip("KEY 6 - " & $KeyTbl[6][2]) Beep(352, 200) Case $Key_Buttons[7][0] Tooltip("KEY 7 - " & $KeyTbl[7][2]) Beep(368, 200) Case $Key_Buttons[8][0],$Key_Buttons[8][1],$Key_Buttons[8][2] Tooltip("KEY 8 - " & $KeyTbl[8][2]) Beep(396, 200) Case $Key_Buttons[9][0] Tooltip("KEY 9 - " & $KeyTbl[9][2]) Beep(418, 200) Case $Key_Buttons[10][0],$Key_Buttons[10][1],$Key_Buttons[10][2] Tooltip("KEY 10 - " & $KeyTbl[10][2]) Beep(440, 200) Case $Key_Buttons[11][0] Tooltip("KEY 11 - " & $KeyTbl[11][2]) Beep(467.5, 200) Case $Key_Buttons[12][0],$Key_Buttons[12][1],$Key_Buttons[12][2] Tooltip("KEY 12 - " & $KeyTbl[12][2]) Beep(495, 200) Case $Key_Buttons[13][0],$Key_Buttons[13][1],$Key_Buttons[13][2] Tooltip("KEY 13 - " & $KeyTbl[13][2]) Beep(523.3, 200) case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func Exiting() Exit EndFunc It's only for the first 13 keys, and just uses crude "beep"'s, but it's a keyboard concept that works and isn't too convoluted. Edited January 29, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
Spiff59 Posted January 29, 2009 Share Posted January 29, 2009 (edited) This version is a lot cleaner... It doesn't answer your precise question, but may be an alternate route to where you're going. Get's you a flexible keyboard in one screen worth of code. expandcollapse popup#include <GUIConstants.au3> #include <array.au3> Dim $NumKeys = 13 ; key type (white or black), title, frequency Dim $KeyTbl[$NumKeys+2][3] = [[0,"",0],[0,"C",264],[1,"C#",280.5],[0,"D",297],[1,"D#",313.5],[0,"E",330],[0,"F",352],[1,"F#",368], _ [0,"G",396], [1,"G#",418],[0,"A",440],[1,"A#",467.5],[0,"B",495],[0,"C",523.3], [0,"",0]] Dim $ImgFull[3] = [10,12,170]; top, width, height Dim $ImgHalf[3] = [115,12,65] Dim $ImgCntr[3] = [10,15,170] Dim $ImgBlck[3] = [10,24,105] Dim $Key_Buttons[$NumKeys+1][3], $Key_Index[($NumKeys+1)*3], $Key ;---------------------------------------------------------------------------------------------------------- $mainGui = GUICreate("piano keyboard by spiff59",400,300) $left = 38 For $x = 1 to $NumKeys If $KeyTbl[$x][0] = 0 Then; white key $Left += 2 If $KeyTbl[$x-1][0] = 0 Then; previous key was white $Key_Buttons[$x][0] = GUICtrlCreateGraphic($left,$ImgFull[0],$ImgFull[1],$ImgFull[2]); left full stripe Else $Key_Buttons[$x][0] = GUICtrlCreateGraphic($left,$ImgHalf[0],$ImgHalf[1],$ImgHalf[2]); left half stripe EndIf GUICtrlSetBkColor($Key_Buttons[$x][0],0xFFFFFF) $left += $ImgFull[1] $Key_Buttons[$x][1] = GUICtrlCreateGraphic($left,$ImgCntr[0],$ImgCntr[1],$ImgCntr[2]); center stripe GUICtrlSetBkColor($Key_Buttons[$x][1],0xFFFFFF) $left += $ImgCntr[1] If $KeyTbl[$x+1][0] = 0 Then; next key will be white $Key_Buttons[$x][2] = GUICtrlCreateGraphic($left,$ImgFull[0],$ImgFull[1],$ImgFull[2]); right full stripe Else $Key_Buttons[$x][2] = GUICtrlCreateGraphic($left,$ImgHalf[0],$ImgHalf[1],$ImgHalf[2]); right half stripe EndIf GUICtrlSetBkColor($Key_Buttons[$x][2],0xFFFFFF) $left += $ImgFull[1] For $y = 0 to 2 $Key_Index[$Key_Buttons[$x][$y]] = $x Next Else ; Black key $Key_Buttons[$x][0] = GUICtrlCreateGraphic($left - ($ImgBlck[1] / 2) + 1,$ImgBlck[0],$ImgBlck[1]+2,$ImgBlck[2]) GUICtrlSetBkColor($Key_Buttons[$x][0],0x000000) $Key_Index[$Key_Buttons[$x][0]] = $x EndIf Next GUISetState() ;------------------------------------------------------------------------------- While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf If $msg >= $Key_Buttons[1][0] And $msg <= $Key_Buttons[$NumKeys][2] Then $key = $Key_Index[$msg] Tooltip("KEY " & $Key & " - " & $KeyTbl[$Key][1]) Beep($KeyTbl[$Key][2], 200) EndIf WEnd Edited January 29, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
martin Posted January 29, 2009 Share Posted January 29, 2009 I have this script: #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 416, 172) $Button1 = GUICtrlCreateButton("Button1", 24, 16, 185, 41) $Button2 = GUICtrlCreateButton("Button2", 72, 32, 217, 49) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSEoÝ÷ Ú+-êÞk²¶hrFî¶Ú'ÚÚy©pk+nÞnëm¢}m+"²Ø^²n¶*'!Ê.×(ë©Â+anëHÁ©íóÆî¶Ú'²k¬Æ¥ì¡ªÝì¬y²±Êâ¦Û(¶¬Éè¶Ø^më-²n¶*'jëh×6#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 416, 172) $Button1 = GUICtrlCreateButton("Button1", 24, 16, 185, 41) $form2 = GUICreate("", 217, 49, 72, 55, $WS_POPUP, $WS_EX_MDICHILD, $form1) WinSetTrans($form2, "", 255) GUISetState(@SW_SHOW, $form2) $Button2 = GUICtrlCreateButton("Button2", 0, 0, 217, 49) GUISetState(@SW_SHOW, $form1) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE #include <GUIConstantsEx.au3> #include <windowsconstants.au3> $Form1 = GUICreate("Form1", 416, 172) $Button1 = GUICtrlCreateButton("Button1", 24, 16, 185, 41) $Button2 = GUICtrlCreateButton("Button2", 72, 32, 217, 49,$WS_CLIPSIBLINGS) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
sandin Posted January 29, 2009 Author Share Posted January 29, 2009 thank you for your help, the last script, martin's is exactly what I was looking for Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now