Old 09-26-2012, 01:31 AM   #1
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default AHK-script: copy action list to clipboard

There are already two actions for getting action list ("SWS/S&M: Dump action list"), but no action to get all custom action names/ids/strings. This script gets also custom actions (to clipboard).

Example: get all custom actions from the main-section: type "custom" to the filter box->right click on the ahk-window and select "Get Action list"->select "Copy to clipboard"->paste to text editor.

Ahk-window:


excel:


Get AutoHotkey from: http://www.autohotkey.com/

Here is the code. Save as e.g "GetActionList.ahk".
Code:
#SingleInstance force

Gui, Add, ListView, r20 w700 h600, Cmd ID|Description||Custom ID

LV_ModifyCol(1, 50)
LV_ModifyCol(2, 300)
LV_ModifyCol(3, 200)
LV_ModifyCol(1, "Integer")
LV_ModifyCol(1, "Left")

; popup menu 
Menu, ContextMenu, Add, Get Action list, ContextGetList
Menu, ContextMenu, Add, Copy to clipboard, ContextCopyToClipB
Menu, ContextMenu, Add, Auto-size columns, ContextAutoSize
Gui, Show,, GetActionList
return

ContextGetList:
IfWinNotExist, Actions
{
    MsgBox, Open the Action list first
    return
}
ControlGet, ActionList, List,, SysListView321, Actions
ControlGet, ColCount, List, Count Col, SysListView321, Actions
if (ColCount <  5)
{
    MsgBox, Enable "Show action IDs" (right click on the Action list)
    return
}
LV_Delete()
Loop, Parse, ActionList, `n
{
    Loop, Parse, A_LoopField, %A_Tab%
    {
        if (A_index = 2)
            DescriptionCol := A_LoopField
        if (A_index = 4)
            CmdIDCol := A_LoopField
            IfInString, CmdIDCol, (
            {
                StringTrimLeft, CmdIDCol, CmdIDCol, 1
                StringTrimRight, CmdIDCol, CmdIDCol, 1
            }
        if (A_index = 5)
            CustomIDCol := A_LoopField
    }
    LV_Add("", CmdIDCol, DescriptionCol, CustomIDCol)
}
return

GuiContextMenu:
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
return

ContextAutoSize:
LV_ModifyCol()
return

ContextCopyToClipB:
clipboard =
ControlGet, AhkActionList, List,,SysListView321, GetActionList
clipboard = %AhkActionList%
return

GuiClose:
ExitApp
spk77 is offline   Reply With Quote
Old 10-24-2012, 03:01 AM   #2
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Hey,
I've been looking at anything I can find bringing ahk to work with Reaper.
I found http://forum.cockos.com/showthread.php?t=30789
And was interested.
I built genmce/keymce from ahk. I have been away from the coding for a bit...
Feel it is time to look at it again.
I am on the iPad right now will try out your script later today.
What other ahk and reaper or midi scripts have you created?
flipotto is offline   Reply With Quote
Old 10-24-2012, 07:50 AM   #3
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
Hey,
I've been looking at anything I can find bringing ahk to work with Reaper.
I found http://forum.cockos.com/showthread.php?t=30789
And was interested.
I built genmce/keymce from ahk. I have been away from the coding for a bit...
Feel it is time to look at it again.
I am on the iPad right now will try out your script later today.
What other ahk and reaper or midi scripts have you created?
Hi,
"Keyboard – Mackie Control Emulation" seems very interesting. I'm going to test it later. Here is a script which shows note and its position at mouse cursor. Works at least with undocked MIDI window. (This is a modified example from the AHK docs. I'm not really an experienced programmer.)

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force
;~ SetTitleMatchMode 2
CoordMode, Mouse, Screen
;~ SetBatchLines, -1

CustomColor = 000000  ; Can be any RGB color (it will be made transparent below).
Gui, +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, s16
Gui, Add, Text, vMyText cBlue, XXXXXXX`n ; XX serve to auto-size the window.

Menu, Tray, NoStandard ; remove standard Menu items
Menu, Tray, Add, Load note names, MenuHandler  ; Creates a new menu item.
Menu, Tray, Add, Quit, ExitHandler

; Make all pixels of this color transparent
WinSet, TransColor, %CustomColor%
SetTimer, UpdateOSD, 20
Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
return

UpdateOSD:
MouseGetPos, MouseX, MouseY,, MouseControl, 1
IfInString, MouseControl, MIDIWindow
{
	ControlGetText, Note, Edit4,, midiview
	ControlGetText, Position, Edit5,, midiview
	;~ ToolTip %Note%`n%Position%
	;~ StringTrimRight, Position, Position, 3  ; remove .100ths
	MouseX := MouseX + 20
	MouseY := MouseY + 20
	GuiControl,, MyText, %Note%`n%Position%
	Gui, Show, x%MouseX% y%MouseY% NoActivate  ; NoActivate avoids deactivating the currently active window.
}
else
	;~ ToolTip
	Gui, hide
return

MenuHandler:
FileSelectFile, SelectedFile, 3,, Open a file, Text Documents (*.txt)
if not ErrorLevel
{
	;~ MsgBox, %SelectedFile%
	FileRead, FileContents, %SelectedFile%
	;~ MsgBox, %FileContents%
	;~ Gui, 2:+Resize
	Gui, 2:Add, Edit, vMyEdit2, %FileContents%
	Gui, 2:Add, Button, vLoadButton gLoadButton, Load map into Reaper
	;~ GuiControl, 2:, MyEdit2, %FileContents%
	Gui, 2:Show
	;~ MsgBox, %FileContents%
}
return

GuiClose:
ExitApp

2GuiClose:
Gui, 2:Destroy
return

LoadButton:
WinGet, MIDIWinId, id, ahk_class REAPERmidieditorwnd	; get MIDIwindowID
SendMessage, 0x0111, 40409, 0,, ahk_id %MIDIWinId% ; Load note names from file
;~ Sleep, 500
IfWinExist, Load MIDI note names from file:
WinActivate, Load MIDI note names from file:
;~ WinWaitActive, Load MIDI note names from file:
ControlSetText, Edit1, %SelectedFile%, Load MIDI note names from file:	; %SelectedFile% contains full path and filename. Edit1 is filename box in "Load MIDI note names from file" -dialog.

return

ExitHandler:
ExitApp
(Mouse cursor isn't visible in the screenshot)

Last edited by spk77; 10-27-2012 at 02:03 PM.
spk77 is offline   Reply With Quote
Old 10-24-2012, 08:52 AM   #4
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Hey I like that mouse position note/indicator.
Works docked too! This is very useful!
I like how it picks up velocity/CC value on the lane too, nice!
Will it pick up custom drum labels? I don't have any yet, just curious.

I might like a crisper font, that one on my screen is kind of smudgy.I forgot how to change the font and style... I'll have to look up how to do that.
No matter what I try it doesn't seem to get better.

I'm not really a programmer either, i just duplicated a few things and had tons of help on what I was obsessed with.

So how to use that list of SKAN's in my first reply?

Last edited by flipotto; 10-24-2012 at 11:09 AM.
flipotto is offline   Reply With Quote
Old 10-24-2012, 11:15 AM   #5
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
Will it pick up custom drum labels? I don't have any yet, just curious.
I tried to get text from MIDIPianoWindow with ControlGetText, but it didn't work. I think it is possible if note names are first loaded to a variable.

(part of GMdrums.txt)
35 B0 Acoustic Bass Drum
36 C1 Bass Drum 1
37 C#1 Side Stick
38 D1 Acoustic Snare
39 D#1 Hand Clap
40 E 1Electric Snare
41 F1 Low Floor Tom
42 F#1 Closed Hi-Hat
43 G1 High Floor Tom

(I don't know how to do it exactly but something like this might work):

1. get notenumber from control (Edit4 shows note name and number)
2. do some string splitting
3. if notenumber is e.g. 35 -> text to show = B0 Acoustic Bass Drum
spk77 is offline   Reply With Quote
Old 10-24-2012, 11:40 AM   #6
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
So how to use that list of SKAN's in my first reply?
You can use Sendmessage command like this (I don't know how SKAN got that list):

Code:
Gui, +AlwaysOnTop +ToolWindow
Gui, Add, Text, x10 y10 vTrackText, Track
Gui, Add, Button, vbutton1 gPrevTrack, Prev
Gui, Add, Button, vbutton2 gNextTrack, Next
Gui, Add, Text, w100 h50 vInfotext cBlue
Gui, Add, Text, x100 y10, Open all track MIDI
Gui, Add, Button, x100 y29 vbutton3 gOpenInEditor, Open
Gui, Show, w200

SetTimer, UpdateInfo, 200
return

PrevTrack:
SendMessage,0x0111,40286,0,,ahk_class REAPERwnd ; Go to previous track
SendMessage,0x0111,40421,0,,ahk_class REAPERwnd ; Select all items in track
Return

NextTrack:
SendMessage,0x0111,40285,0,,ahk_class REAPERwnd ; Go to next track
SendMessage,0x0111,40421,0,,ahk_class REAPERwnd ; Select all items in track
Return

OpenInEditor:
SendMessage,0x0111,40134,0,,ahk_class REAPERwnd ; Open all track MIDI (last focused/clear first)
return

UpdateInfo:
ControlGetText, info, Static1, ahk_class REAPERwnd
GuiControl,, Infotext, %info%
return

GuiClose:
ExitApp
If you want to execute action in the main window use:
SendMessage,0x0111,40286,0,,ahk_class REAPERwnd ; ActionID 40286 is Go to previous track

and in MIDI window:
SendMessage,0x0111,40719,0,,ahk_class REAPERmidieditorwnd ; ActionID 40719 is Cursor: advance 1/4

Last edited by spk77; 10-24-2012 at 12:02 PM.
spk77 is offline   Reply With Quote
Old 10-24-2012, 01:12 PM   #7
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Quote:
Originally Posted by spk77 View Post
I tried to get text from MIDIPianoWindow with ControlGetText, but it didn't work. I think it is possible if note names are first loaded to a variable.

(part of GMdrums.txt)
35 B0 Acoustic Bass Drum
36 C1 Bass Drum 1
37 C#1 Side Stick
38 D1 Acoustic Snare
39 D#1 Hand Clap
40 E 1Electric Snare
41 F1 Low Floor Tom
42 F#1 Closed Hi-Hat
43 G1 High Floor Tom

(I don't know how to do it exactly but something like this might work):

1. get notenumber from control (Edit4 shows note name and number)
2. do some string splitting
3. if notenumber is e.g. 35 -> text to show = B0 Acoustic Bass Drum
I have an idea and it is from yours.
I don't think a string split will be needed...
just set varibles based on note number.
Since you are already picking that up - should be able to just

could be loaded based on a menu setting
if GM drums = 0
{
36 = 36
; other variables that are drum note numbers
}
else
{
36 = snare
}
I need a day or two to get back up to speed with ahk, it's been over a year since I looked at it. My syntax is all messed up, but it will come back quickly.

This tool is already very useful - what you've done.
I will used every time I need midi piano roll.

---
I get how the messages are being sent from SKAN -
what I don't get is how to incorporate his list into a menu that is usable from a script.
I pm'd him over at ahk forum.
I will post here if I get something from him.
flipotto is offline   Reply With Quote
Old 10-24-2012, 02:42 PM   #8
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
I get how the messages are being sent from SKAN -
what I don't get is how to incorporate his list into a menu that is usable from a script.
I pm'd him over at ahk forum.
I will post here if I get something from him.
Ok, please post if you get an answer.
spk77 is offline   Reply With Quote
Old 10-24-2012, 07:26 PM   #9
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

No answer yet.
back to the note display.
Where should the list of note number to drum name conversion come from?
1. Where someone has imported a drum set, like {GM standard note # to drum name/type} or also be user definable .ini file that would include gm drum mapping as well as a couple of user definable sections in a .ini file.
I say this because some vst's use non-standard drum mapping and some drum triggers also use non-standard mapping.
- If you happen to be triggering from some midi drum hardware.

Does it even matter...

For my own personal uses - I will need either a note translator to convert notes from my Roland handsonic (because I will tap them in on the pads) to GM - then edit as necessary...(mouse) or have separate drum map in Reaper.
Not sure which of those is easier/better. I also have another drum trigger devices so the need for multiple maps is apparent for my use.

Not that anyone else would need these features. Start with the GM drum map, as you suggest and get that txt on the display. Where would the text come from? an .ini file or some list in .ahk or can reaper itself transmit that info to the mouse position for ahk to pick up?

Which leads me to where are you getting the note names var?
Is there a custom message coming across your script from the mouse location?

Code:
ControlGetText, Note, Edit4,, midiview

ControlGetText, Position, Edit5,, midiview
Where did you learn what the value of Edit4 and Edit5 where?

I only had a few mins to look at your script today while working.
I will look again.

Last edited by flipotto; 10-24-2012 at 07:34 PM.
flipotto is offline   Reply With Quote
Old 10-25-2012, 02:05 AM   #10
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

I think it easiest (for now) to open the same drum map file in Reaper and in ahk (with FileSelectFile or something). There are a lot of drum map files in Reaper stash. There seems to be empty/commenting lines in keymap files, so they have to be parsed out.

Quote:
Originally Posted by flipotto View Post
Which leads me to where are you getting the note names var?
Is there a custom message coming across your script from the mouse location?

Code:
ControlGetText, Note, Edit4,, midiview

ControlGetText, Position, Edit5,, midiview
Where did you learn what the value of Edit4 and Edit5 where?

I only had a few mins to look at your script today while working.
I will look again.
I'm using AutoItWindowInfo to get the control names. Note number comes from Edit4 (if we use string split before digits).



Now I have to go to work (and put winter tyres on, it's almost winter here).
spk77 is offline   Reply With Quote
Old 10-25-2012, 07:22 AM   #11
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Hey -
I don't have AutoIt installed on this machine, window spy does not seem to pick up that same information.
Also - now the docked piano roll does not show correctly anymore... not sure what changed, I did not edit anything... weird.

I was looking at the gm drum map (from stash) here's a snip.

35 B0 Acoustic Bass Drum
36 C1 Bass Drum 1
37 C#1 Side Stick
38 D1 Acoustic Snare
39 D#1 Hand Clap
40 E 1Electric Snare

A couple of questions come to mind...
1. Does edit4 get the text "Acoustic Bass Drum" for note 35?
I know the text is displayed on the key of the piano, but is that info sent to the display for edit4 in reaper (even though that display is too small for that much text...
I'm not articulating this very well...
2. Is there a standard place to put a drum map in reaper, since others will have to load it, both into reaper and into this script?
2b. Are there custom actions based on drum or piano notes for midi? I'll look from your generated list and the list of actions... doesn't look like it.

3. Where I am heading is will this be useful to someone else?
4. If they have to browse for the file to load and edit variable definitions... I want it to be useful and easy to manage for others. If not, I'll just hack to customize for myself and get something working that only you or I will understand. Yes others will as well but most will not.

Here is a test and proof of concept.

Done based on GM map from stash

Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force
;~ SetTitleMatchMode 2
CoordMode, Mouse, Screen
;~ SetBatchLines, -1

CustomColor = 000000  ; Can be any RGB color (it will be made transparent below).
Gui, +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, s16 , ;courier new bold
Gui, Add, Text, vMyText cBlue, XXXXXXXXXXXXXXXX`n ; XX serve to auto-size the window.

; Make all pixels of this color transparent
WinSet, TransColor, %CustomColor%
SetTimer, UpdateOSD, 20
Gosub, UpdateOSD  ; Make the first update immediate rather than waiting for the timer.
return

UpdateOSD:
MouseGetPos, MouseX, MouseY,, MouseControl, 1
IfInString, MouseControl, MIDIWindow
{
	ControlGetText, Note, Edit4,, midiview
	ControlGetText, Position, Edit5,, midiview
	
	; =============== test for note #35; =============== 
	if note contains 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81
		{	
			if note contains 35
				{
					note = AcousticBassDrum
				}	
			if note contains 36
				{
					note = BassDrum
				}	
			if note contains 37
				{
					note = SideStick
				}	
			if note contains 38
				{
					note = AcousticSnare
				}	
			if note contains 39
				{
					note = HandClap
				}	
			if note contains 40
				{
					note = ElectricSnare
				}	
			if note contains 41
				{
					note = LowFloorTom
				}	
			if note contains 42
				{
					note = ClosedHat
				}	
			if note contains 43
				{
					note = HiFloorTom
				}	
			if note contains 44
				{
					note = PedalHat
				}	
			if note contains 45
				{
					note = LowTom
				}	
			if note contains 46
				{
					note = OpenHat
				}	
			if note contains 47
				{
					note = LowMidTom
				}	
			if note contains 48
				{
					note = HiMidTom
				}	
			if note contains 49
				{
					note = Crash
				}	
			if note contains 50
				{
					note = HiTom
				}	
			if note contains 51
				{
					note = Ride
				}	
			if note contains 52
				{
					note = ChinaCym
				}	
			if note contains 53
				{
					note = RideBell
				}	
			if note contains 54
				{
					note = Tamb
				}	
			if note contains 55
				{
					note = Splash
				}	
			if note contains 56
				{
					note = CowBell
				}	
			if note contains 57
				{
					note = Crash2
				}	
			if note contains 58
				{
					note = VibraSlap
				}	
			if note contains 59
				{
					note = Ride2
				}	
			if note contains 60
				{
					note = HiBong
				}	
			if note contains 61
				{
					note = LowBongo
				}	
			if note contains 62
				{
					note = MuteHiConga
				}	
			if note contains 63
				{
					note = OpenHiConga
				}	
			if note contains 64
				{
					note = LowConga
				}	
			if note contains 65
				{
					note = HiTimbale
				}	
			if note contains 66
				{
					note = LowTimbale
				}	
			if note contains 67
				{
					note = HiAgogo
				}	
			if note contains 68
				{
					note = LowAgogo
				}	
			if note contains 69
				{
					note = Cabasa
				}	
			if note contains 70
				{
					note = Maracas
				}	
			if note contains 71
				{
					note = ShortWhistle
				}	
			if note contains 72
				{
					note = LongWhistle
				}	
			if note contains 73
				{
					note = ShortGuiro
				}	
			if note contains 74
				{
					note = LongGuiro
				}	
			if note contains 75
				{
					note = Claves
				}	
			if note contains 76
				{
					note = HiWoodBlock
				}	
			if note contains 77
				{
					note = LowWoodBlock
				}	
			if note contains 78
				{
					note = MuteCuica
				}	
			if note contains 79
				{
					note = OpenCuica
				}	
			if note contains 80
				{
					note = MuteTriangle
				}	
			if note contains 81
				{
					note = OpenTriangle
				}	
			;end of test for drum notes
	}

	;~ ToolTip %Note%`n%Position%
	;~ StringTrimRight, Position, Position, 3  ; remove .100ths
	MouseX := MouseX + 20
	MouseY := MouseY + 20
	GuiControl,, MyText, %Note%`n%Position%

	Gui, Show, w300 x%MouseX% y%MouseY% NoActivate  ; NoActivate avoids deactivating the currently active window.
}
else
	;~ ToolTip
	Gui, hide
return

GuiClose:
ExitApp

Last edited by flipotto; 10-25-2012 at 10:17 AM.
flipotto is offline   Reply With Quote
Old 10-25-2012, 10:57 AM   #12
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
Hey -
I don't have AutoIt installed on this machine, window spy does not seem to pick up that same information.
Also - now the docked piano roll does not show correctly anymore... not sure what changed, I did not edit anything... weird.
Damn, it seems that control names are not constant in docked window.

Quote:
Originally Posted by flipotto View Post
A couple of questions come to mind...
1. Does edit4 get the text "Acoustic Bass Drum" for note 35?
I know the text is displayed on the key of the piano, but is that info sent to the display for edit4 in reaper (even though that display is too small for that much text...
I'm not articulating this very well...
2. Is there a standard place to put a drum map in reaper, since others will have to load it, both into reaper and into this script?
2b. Are there custom actions based on drum or piano notes for midi? I'll look from your generated list and the list of actions... doesn't look like it.
3. Where I am heading is will this be useful to someone else?
4. If they have to browse for the file to load and edit variable definitions... I want it to be useful and easy to manage for others. If not, I'll just hack to customize for myself and get something working that only you or I will understand. Yes others will as well but most will not.
1. No. That's why it is necessary to load a map into script also, but it may be possible to load it into reaper from the script. (there's an action "Load note names from file")
2. I'm not sure but there's a KeyMap folder in Reaper folder.
2b. There are some but SWS actions are in the MAIN section.
3.4. Yeah, it should be easy to manage (with GUI)

This is what I thought:
1. load a map into script (load it into reaper with button in GUI, I'll test if it is possible)
2. parse every line and put text into var (NoteNumber35 = B0 Acoustic Bass Drum, NoteNumber36 = C1 Bass Drum 1 etc.)
3. get note number from Edit4 (with string split)
4. pass note number as parameter into function which then shows corresponding text (parameter = 35 then text to show is B0 Acoustic Bass Drum

Sorry, I don't know if that make any sense. It's very hard to explain in english.

spk77 is offline   Reply With Quote
Old 10-25-2012, 11:11 AM   #13
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
Here is a test and proof of concept.

Done based on GM map from stash
Hey, nice. It's working fine here.
spk77 is offline   Reply With Quote
Old 10-25-2012, 11:24 AM   #14
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Hey,
I did find if I use f7,f8 or f9 to change my screenset, i find that the mouse tip shows properly even with docked toolbar.
flipotto is offline   Reply With Quote
Old 10-25-2012, 12:16 PM   #15
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by flipotto View Post
Hey,
I did find if I use f7,f8 or f9 to change my screenset, i find that the mouse tip shows properly even with docked toolbar.
Great. I guess it's time for me to buy a new computer (7-8 years old), even those if -statements adds lag. May be also because of this bigger GUI: Gui, Add, Text, vMyText cBlue, XXXXXXXXXXXXXXXX`n.
spk77 is offline   Reply With Quote
Old 10-25-2012, 12:50 PM   #16
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

You are experiencing increased lag?
You can increase the settimer I bumped all the way to 200 and it was still usable, however - I like 50 or 60.

There is probably a much better way than if, then.
Just an easy solution.
I see what you mean tho - my screen refresh is slowing down. Can we detect the mouse position only after we know that the correct window is active?
flipotto is offline   Reply With Quote
Old 10-25-2012, 01:52 PM   #17
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

I increased the settimer to 50ms, it helped a lot. Reaper window or midi window has to be active to get data from Edit4 (Edit4 refreshes only then). "MouseGetPos, MouseX, MouseY,, MouseControl, 1" and "IfInString, MouseControl, MIDIWindow" checks if control name under the mouse cursor contains "midiview". "MouseX" and "MouseY" contains screen coordinates all the time.
spk77 is offline   Reply With Quote
Old 10-27-2012, 11:24 AM   #18
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Ok here is another more usable.
I put in a few things.
1. Detect reaper - so program won't do anything if reaper is not detected, except look for reaper every 8 seconds.
2. If reaper is an active window then proceed with updateosd
3. Add tray menu icon to set for GM drums, on this program.
I want to add your load gm map if tray menu set to gmdrums (call action to load the map as you showed before.

Code:
/* 
	This script - written by SPK77 shows notes on Mouse tip as well as position of mouse cursor on midi piano roll.
	Flipotto added GM drum name display (only works with GM drum map from reaper stash) 
	Words after ; are comments.
*/

; =============== Nothing to edit here move along ; =============== 
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#SingleInstance, Force

Menu, tray, add, GMDrums            ; Set General Midi drums show names add to tray icon

SetTitleMatchMode 2
CoordMode, Mouse, Screen
; =============== gui settings to make bacground trans and the color/size of font for display ; =============== 
CustomColor = 000000  ; Can be any RGB color (it will be made transparent below).
Gui, +LastFound +AlwaysOnTop -Caption +ToolWindow  ; +ToolWindow avoids a taskbar button and an alt-tab menu item.
Gui, Color, %CustomColor%
Gui, Font, s16 , ;courier new bold
Gui, Add, Text, vMyText cBlue, XXXXXXXXXXXXXXXX`n ; XX serve to auto-size the window.
; Make all pixels of this color transparent
WinSet, TransColor, %CustomColor%

; =============== test to see if REAPER is open every 5 seconds
SetTimer, ReaperDetect, 5000 ; run subroutine below 5000 = 5second interval
GmDrums =  ; Set to blank
AutoExit = ; set to blank, if you wish to autoexit when reaper closes set to 1

return ; end autoexec section - this is what runs when you load 

; =============== subroutine to test if Reaper is open ; =============== 
ReaperDetect:
IfWinExist, REAPER ; Is REAPER open? if yes then run subroutine to detect mouse postion
	{
		SetTimer, UpdateOSD, 50
		SetTimer, ReaperDetect, 8000 ; see if reaper is open every 8 seconds
	}
IfWinNotExist, REAPER ; IF reaper is not open, then pause the updateOSD - pause get mouse postion
	{
		SetTimer, UpdateOSD, Off ; stop Update osd
		SetTimer, ReaperDetect, 6000 ;wait 10s check for reaper again.
		IfEqual, AutoExit,1 ; IF set to Autoexit then close this prog
			{
				gosub, GuiClose
			}
		IfEqual, AutoExit, 0 
			{
				; do nothing
			}	
		else ; if not set to autoexit then show message box to ask if would like to remain on	
			{
				MsgBox,4 ,Exit Note Show, Exit Note/Show? 
					IfMsgBox Yes
						gosub, guiclose 
					Else
						{
							AutoExit = 0 ; will be remembered while program runs then var will reset
						}
			}
	}	
return ; end of reaper active detection

; =============== Subroutine to get mouse postion, test if it's in the MIDIWindow, check for drum names_display 
UpdateOSD:
	MouseGetPos, MouseX, MouseY,, MouseControl, 1
	IfInString, MouseControl, MIDIWindow
		{
			ControlGetText, Note, Edit4,, midiview
			ControlGetText, Position, Edit5,, midiview
			
			IfEqual, GmDrums,1 ; show drum names if GmDrum = 1
				{
			;MsgBox,,In GmDrums convert,%GmDrum%, 1
			; =============== test for note #35; =============== 
				if note contains 35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81
					{	
					if note contains 35
						{
							note = AcousticBassDrum
						}	
					if note contains 36
						{
							note = BassDrum
						}	
					if note contains 37
						{
							note = SideStick
						}	
					if note contains 38
						{
							note = AcousticSnare
						}	
					if note contains 39
						{
							note = HandClap
						}	
					if note contains 40
						{
							note = ElectricSnare
						}	
					if note contains 41
						{
							note = LowFloorTom
						}	
					if note contains 42
						{
							note = ClosedHat
						}	
					if note contains 43
						{
							note = HiFloorTom
						}	
					if note contains 44
						{
							note = PedalHat
						}	
					if note contains 45
						{
							note = LowTom
						}	
					if note contains 46
						{
							note = OpenHat
						}	
					if note contains 47
						{
							note = LowMidTom
						}	
					if note contains 48
						{
							note = HiMidTom
						}	
					if note contains 49
						{
							note = Crash
						}	
					if note contains 50
						{
							note = HiTom
						}	
					if note contains 51
						{
							note = Ride
						}	
					if note contains 52
						{
							note = ChinaCym
						}	
					if note contains 53
						{
							note = RideBell
						}	
					if note contains 54
						{
							note = Tamb
						}	
					if note contains 55
						{
							note = Splash
						}	
					if note contains 56
						{
							note = CowBell
						}	
					if note contains 57
						{
							note = Crash2
						}	
					if note contains 58
						{
							note = VibraSlap
						}	
					if note contains 59
						{
							note = Ride2
						}	
					if note contains 60
						{
							note = HiBongo
						}	
					if note contains 61
						{
							note = LowBongo
						}	
					if note contains 62
						{
							note = MuteHiConga
						}	
					if note contains 63
						{
							note = OpenHiConga
						}	
					if note contains 64
						{
							note = LowConga
						}	
					if note contains 65
						{
							note = HiTimbale
						}	
					if note contains 66
						{
							note = LowTimbale
						}	
					if note contains 67
						{
							note = HiAgogo
						}	
					if note contains 68
						{
							note = LowAgogo
						}	
					if note contains 69
						{
							note = Cabasa
						}	
					if note contains 70
						{
							note = Maracas
						}	
					if note contains 71
						{
							note = ShortWhistle
						}	
					if note contains 72
						{
							note = LongWhistle
						}	
					if note contains 73
						{
							note = ShortGuiro
						}	
					if note contains 74
						{
							note = LongGuiro
						}	
					if note contains 75
						{
							note = Claves
						}	
					if note contains 76
						{
							note = HiWoodBlock
						}	
					if note contains 77
						{
							note = LowWoodBlock
						}	
					if note contains 78
						{
							note = MuteCuica
						}	
					if note contains 79
						{
							note = OpenCuica
						}	
					if note contains 80
						{
							note = MuteTriangle
						}	
					if note contains 81
						{
							note = OpenTriangle
						}	
					} ;end of test for drum notes from list
				else ;if not in the list above for GM drum notes then 
					{
						; do nothing
					}
			}	
			else ; end of GM drum show
				{
					;MsgBox, ,update OSD Gmdrum off, %GmDrum%, 1
				}

	;~ ToolTip %Note%`n%Position%
		;~ StringTrimRight, Position, Position, 3  ; remove .100ths
			MouseX := MouseX + 1
			MouseY := MouseY + 1
			GuiControl,, MyText, %Note%`n%Position%

			Gui, Show, w300 x%MouseX% y%MouseY% NoActivate  ; NoActivate avoids deactivating the currently active window.
		;}
		}
	else
		;~ ToolTip
		{
			Gui, hide
		}
return
GMDrums: ; set var to value to show the Drum names or not
	{
		MsgBox,4 ,GMdrums, Show GM Drum Names? 
		IfMsgBox Yes
			GmDrums = 1
		Else
			GmDrums = 0	
		;sleep, 500
		;MsgBox, ,,%GmDrums%, 2 ; only for testing purposes
	}
return

GuiClose:
ExitApp
Needs a clean up for sure.
flipotto is offline   Reply With Quote
Old 10-27-2012, 02:02 PM   #19
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Post #3 edited (green parts). Now it loads a map (user have to select it) into reaper but there's an odd delay before filename gets into "load note name" -dialog.
spk77 is offline   Reply With Quote
Old 10-27-2012, 02:16 PM   #20
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Quote:
Originally Posted by spk77 View Post
Post #3 edited (green parts). Now it loads a map (user have to select it) into reaper but there's an odd delay before filename gets into "load note name" -dialog.
I added your code, not sure why yet, but I can't get the notepostion gui button load map into reaper to work.
I see the listing of GM drums and I press the button but it does not do anything. I'm added a few msgbox's to see where things aren't working.
Well I put a msgbox at the end of loadbutton
Code:
LoadButton:
WinGet, MIDIWinId, id, ahk_class REAPERmidieditorwnd	; get MIDIwindowID
SendMessage, 0x0111, 40409, 0,, ahk_id %MIDIWinId% ; Load note names from file
;~ Sleep, 500
IfWinExist, Load MIDI note names from file:
WinActivate, Load MIDI note names from file:
;~ WinWaitActive, Load MIDI note names from file:
ControlSetText, Edit1, %SelectedFile%, Load MIDI note names from file:	; %SelectedFile% contains full path and filename. Edit1 is filename box in "Load MIDI note names from file" -dialog.
MsgBox reaper button
return
The msgbox loads but the piano roll does not change from no text to GM drums... hmmm...

Last edited by flipotto; 10-27-2012 at 02:21 PM.
flipotto is offline   Reply With Quote
Old 10-27-2012, 02:20 PM   #21
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

It takes few seconds for me after the Load map button is pressed. Oh, and midiwindow has to be undocked. I forgot to add that it doesn't press Open -button automatically.

Last edited by spk77; 10-27-2012 at 02:28 PM.
spk77 is offline   Reply With Quote
Old 10-27-2012, 02:27 PM   #22
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Works if undocked.
flipotto is offline   Reply With Quote
Old 10-27-2012, 03:06 PM   #23
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

It's much faster if "SendMessage, 0x0111, 40409, 0,, ahk_id %MIDIWinId%" is replaced with "PostMessage, 0x0111, 40409, 0,, ahk_id %MIDIWinId%".
Code:
LoadButton:
WinGet, MIDIWinId, id, ahk_class REAPERmidieditorwnd	; get MIDIwindowID
WinActivate, ahk_id %MIDIWinId%
PostMessage, 0x0111, 40409, 0,, ahk_id %MIDIWinId% ; Load note names from file
Sleep, 1000 ; delay before ControlSetText (more reliable)
ControlSetText, Edit1, %SelectedFile%, Load MIDI note names from file:	; %SelectedFile% contains full path and filename. Edit1 is filename box in "Load MIDI note names from file" -dialog.
return

Last edited by spk77; 10-27-2012 at 03:17 PM.
spk77 is offline   Reply With Quote
Old 10-27-2012, 03:20 PM   #24
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Pity it isn't working with docked window. I'll try it when I get home
I'm in Virginia , you?
flipotto is offline   Reply With Quote
Old 10-27-2012, 03:26 PM   #25
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

I'm from Finland. Yeah, it's time to go to sleep.
spk77 is offline   Reply With Quote
Old 10-30-2012, 06:11 AM   #26
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Hey is there an undock midi editor command?
And a dock the midi editor command?
That way I can call the load from file and put it back docked?

Maybe it's not worth it anyway...
I see your doing python also - good for you.

Last edited by flipotto; 10-30-2012 at 06:25 AM.
flipotto is offline   Reply With Quote
Old 10-30-2012, 08:03 AM   #27
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Couldn't find any MIDI-window related but there is "Dock/undock currently focused window". Maybe it's possible to use ControlFocus http://www.autohotkey.com/docs/comma...ntrolFocus.htm to set MIDI-window (or control) focused and then use Dock/undock -action.
spk77 is offline   Reply With Quote
Old 01-24-2019, 08:00 AM   #28
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
Default

Does anyone know how to trigger custom actions from AutoHotkey using Postmessage?
TonE is offline   Reply With Quote
Old 06-18-2019, 03:56 AM   #29
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Location: VA
Posts: 885
Default

Quote:
Originally Posted by spk77 View Post
There are already two actions for getting action list ("SWS/S&M: Dump action list"), but no action to get all custom action names/ids/strings. This script gets also custom actions (to clipboard).

Example: get all custom actions from the main-section: type "custom" to the filter box->right click on the ahk-window and select "Get Action list"->select "Copy to clipboard"->paste to text editor.

Ahk-window:


excel:


Get AutoHotkey from: http://www.autohotkey.com/

Here is the code. Save as e.g "GetActionList.ahk".
Code:
#SingleInstance force

Gui, Add, ListView, r20 w700 h600, Cmd ID|Description||Custom ID

LV_ModifyCol(1, 50)
LV_ModifyCol(2, 300)
LV_ModifyCol(3, 200)
LV_ModifyCol(1, "Integer")
LV_ModifyCol(1, "Left")

; popup menu 
Menu, ContextMenu, Add, Get Action list, ContextGetList
Menu, ContextMenu, Add, Copy to clipboard, ContextCopyToClipB
Menu, ContextMenu, Add, Auto-size columns, ContextAutoSize
Gui, Show,, GetActionList
return

ContextGetList:
IfWinNotExist, Actions
{
    MsgBox, Open the Action list first
    return
}
ControlGet, ActionList, List,, SysListView321, Actions
ControlGet, ColCount, List, Count Col, SysListView321, Actions
if (ColCount <  5)
{
    MsgBox, Enable "Show action IDs" (right click on the Action list)
    return
}
LV_Delete()
Loop, Parse, ActionList, `n
{
    Loop, Parse, A_LoopField, %A_Tab%
    {
        if (A_index = 2)
            DescriptionCol := A_LoopField
        if (A_index = 4)
            CmdIDCol := A_LoopField
            IfInString, CmdIDCol, (
            {
                StringTrimLeft, CmdIDCol, CmdIDCol, 1
                StringTrimRight, CmdIDCol, CmdIDCol, 1
            }
        if (A_index = 5)
            CustomIDCol := A_LoopField
    }
    LV_Add("", CmdIDCol, DescriptionCol, CustomIDCol)
}
return

GuiContextMenu:
Menu, ContextMenu, Show, %A_GuiX%, %A_GuiY%
return

ContextAutoSize:
LV_ModifyCol()
return

ContextCopyToClipB:
clipboard =
ControlGet, AhkActionList, List,,SysListView321, GetActionList
clipboard = %AhkActionList%
return

GuiClose:
ExitApp
Does this still work, I just tried it and it does NOT seem to work anymore?
flipotto is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.