# Midi to outgoing keypress translators apple script

**URL:** <https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336>\
**Category:** Bome Products\
**Tags:** applescript\
**Created:** [July 16, 2023, 11:37am UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336 "2023-07-16T11:37:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![str8.7enz](https://forum.bome.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@str8.7enz](https://forum.bome.com/u/str8.7enz)\
**Post date:** [July 16, 2023, 11:37am UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/1 "2023-07-16T11:37:52Z")

</div>

…would anyone have a example apple script, in which i could send a outgoing keypress to a running application…  
at present, my BM translators require focus of the application in order for it to execute the necessary action.  
If anyone has an example apple script… this would be greatly appreciated  
cheeRs

---

<div class="post-metadata">

**Author:** ![SteveC](https://forum.bome.com/user_avatar/forum.bome.com/stevec/32/8250_2.png) [@SteveC](https://forum.bome.com/u/SteveC)\
**Post date:** [July 16, 2023, 1:56pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/2 "2023-07-16T13:56:59Z")

</div>

Here is an example script that might help. For me, I usually just use the Bome outgoing action to set focus to the desired application. I’m not a heavy AppleScript user. I wrote this script a few years ago just as a test.

```auto
tell application "Terminal"
	activate
	my execCmd("ls")
end tell

on execCmd(cmd)
	tell application "System Events"
		tell application process "Terminal"
			set frontmost to true
			keystroke cmd
			keystroke return
		end tell
	end tell
end execCmd

```

Steve Caldwell  
Bome Customer Care

* * *
_Also available for paid consulting services: bome@sniz.biz_

---

<div class="post-metadata">

**Author:** ![str8.7enz](https://forum.bome.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@str8.7enz](https://forum.bome.com/u/str8.7enz)\
**Post date:** [July 16, 2023, 3:53pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/3 "2023-07-16T15:53:19Z")

</div>

Awesome!! I will give this a go  
thanks again SteveC  
cheeRs

---

<div class="post-metadata">

**Author:** ![str8.7enz](https://forum.bome.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@str8.7enz](https://forum.bome.com/u/str8.7enz)\
**Post date:** [July 16, 2023, 8:09pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/4 "2023-07-16T20:09:19Z")

</div>

hi Steve… i tried the above script but without success, however i did make a shortened version

i used this short version & then use a second translator to send off the keystroke

tell application ‘System Events’  
tell application ‘VirtualDJ.app’  
activate  
end tell  
end tell

and a Keystroke translator to activate the necessary midi to keystroke command via outgoing keystroke action…  
so basically two mappings  
1 application focus  
2 keystroke

is there a way in Bomes to apply this application focus translator across all translators within a given preset…  
it would be a right pain in the rear… to map out every single translator??  
is this possible

as it stands at the moment… i would always press a single midi button to grab focus first… but ideally i’d prefer that the assigned midi button i press activates both application focus & the corresponding keystroke… without the need for making a translator for every single mapping i have done thus far… :-s

---

<div class="post-metadata">

**Author:** ![SteveC](https://forum.bome.com/user_avatar/forum.bome.com/stevec/32/8250_2.png) [@SteveC](https://forum.bome.com/u/SteveC)\
**Post date:** [July 16, 2023, 11:31pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/5 "2023-07-16T23:31:37Z")

</div>

Yes, please see the attached example.  
The first translator will provide focus to textedit application on any note-on MIDI CH1  
The subsequent translators will send a given keystroke with a 10 ms delay depending on the incoming note message sent.

[Focus-Keystroke-Example.bmtp](https://forum.bome.com/uploads/short-url/k0ppRoVBUKlHNQHTYtwpQMqglQG.bmtp) (1.2 KB)

Steve Caldwell  
Bome Customer Care

* * *
_Also available for paid consulting services: bome@sniz.biz_

---

<div class="post-metadata">

**Author:** ![str8.7enz](https://forum.bome.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@str8.7enz](https://forum.bome.com/u/str8.7enz)\
**Post date:** [July 17, 2023, 12:16am UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/6 "2023-07-17T00:16:54Z")

</div>

i see!!..  
it did not occur to me to try that \*smiles  
thanks again!!

---

<div class="post-metadata">

**Author:** ![str8.7enz](https://forum.bome.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@str8.7enz](https://forum.bome.com/u/str8.7enz)\
**Post date:** [September 9, 2023, 9:00pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/7 "2023-09-09T21:00:48Z")

</div>

Hi steve,  
could i please get your assistance again

when using the example you provided… i changed the note value to a CC to activate(focus) a application upon pressing a midi button to keypress  
raw midi B0 pp 7f ‘activate application’

could you please help me to define the rule set needed to keep the CC number range to be within 1 to 8…  
so that the translator within my presets… is isolated to just that CC number range

---

<div class="post-metadata">

**Author:** ![SteveC](https://forum.bome.com/user_avatar/forum.bome.com/stevec/32/8250_2.png) [@SteveC](https://forum.bome.com/u/SteveC)\
**Post date:** [September 9, 2023, 9:58pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/8 "2023-09-09T21:58:03Z")

</div>

Here you go. Changed the translators from Note to CC with value of 7F  
Added rules to the first translator to limit it.

```auto
if pp<1 then exit rules, skip Outgoing Action
if pp>8 then exit rules, skip Outgoing Action

```

Here is the update project file.  
[Focus-Keystroke–CC-Example.bmtp](https://forum.bome.com/uploads/short-url/5l3nZVDW3Fp7hoWWfd049B9Q5KE.bmtp) (1.3 KB)

Steve Caldwell  
Bome Customer Care

* * *
_Also available for paid consulting services: bome@sniz.biz_

---

<div class="post-metadata">

**Author:** ![str8.7enz](https://forum.bome.com/letter_avatar_proxy/v4/letter/s/e99b99/32.png) [@str8.7enz](https://forum.bome.com/u/str8.7enz)\
**Post date:** [September 9, 2023, 10:17pm UTC](https://forum.bome.com/t/midi-to-outgoing-keypress-translators-apple-script/5336/9 "2023-09-09T22:17:50Z")

</div>

thank you Steve!!
