-
All replies
-
Helpful answers
-
Aug 1, 2013 11:03 AM in response to soundart11by xnav,Did you try?
tell application "System Events"
key down {key code 97, key code 98}
end tell
-
Aug 1, 2013 11:05 AM in response to xnavby soundart11,Thanks, but I still get the same result of 2 seperate key strokes.
-
Aug 1, 2013 1:51 PM in response to soundart11by Hiroto,Hello
You may try the script below.
I have tested RubyCocoa code but not the whole script, for I don't have Pro Tools or any application which accepts two F keys simultaneously.
Good luck,
H
tell application "Pro Tools" to activate do shell script "/usr/bin/ruby <<'EOF' require 'osx/cocoa' include OSX k1d = CGEventCreateKeyboardEvent(nil, 0x0061, true) # F6 keydown k1u = CGEventCreateKeyboardEvent(nil, 0x0061, false) # F6 keyup k2d = CGEventCreateKeyboardEvent(nil, 0x0062, true) # F7 keydown k2u = CGEventCreateKeyboardEvent(nil, 0x0062, false) # F7 keyup tap = KCGHIDEventTap CGEventPost(tap, k1d) CGEventPost(tap, k2d) CGEventPost(tap, k1u) CGEventPost(tap, k2u) EOF"
-
Aug 1, 2013 1:54 PM in response to Hirotoby soundart11,Thanks Hiroto, but once again I get the same result.
-
Aug 1, 2013 5:54 PM in response to soundart11by Hiroto,Then try inserting small delay in key down and key up events. Like this -
tell application "Pro Tools" to activate do shell script "/usr/bin/ruby <<'EOF' require 'osx/cocoa' include OSX k1d = CGEventCreateKeyboardEvent(nil, 0x0061, true) # F6 keydown k1u = CGEventCreateKeyboardEvent(nil, 0x0061, false) # F6 keyup k2d = CGEventCreateKeyboardEvent(nil, 0x0062, true) # F7 keydown k2u = CGEventCreateKeyboardEvent(nil, 0x0062, false) # F7 keyup tap = KCGHIDEventTap CGEventPost(tap, k1d) CGEventPost(tap, k2d) sleep 0.2 CGEventPost(tap, k1u) CGEventPost(tap, k2u) EOF"
-
Aug 1, 2013 7:57 PM in response to Hirotoby soundart11,Still the same result. I appreciate the effort though!!
-
Aug 2, 2013 6:07 AM in response to soundart11by Bernard Harte,I don't have ProTools either, but have you tried:
(after activating ProTools)
tell application "System Events"
key down (key code 97)
key down (key code 98)
delay 10 -- or do whatever needs to happen
key up (key code 98)
key up (key code 97)
end tell
-
Aug 2, 2013 9:11 AM in response to soundart11by Hiroto,★HelpfulHmm. You mean it acts as if F6 was pressed and released and then F7 was pressed and released even though evens are posted differently? Then I'd guess Pro Tools is doing something special when interpretting events sequence. I give up pursuing this route.
There's good news, though. According to some resources, there're other keyboard shortcuts for Smart Tool which are F7+F8 and command+7. So you may simply use System Events' key code command for command+7 as listetd below. The key code for 7 (on keyboard not on keypad) is 0x1A (26) on English keyboard. It may vary on different keyboard hardware layout for other languages.
cf.
http://www.protoolskeyboardshortcuts.com/pro-tools-10-keyboard-shortcuts/
http://www.protoolskeyboardshortcuts.com/pro-tools-11-keyboard-shortcuts/
(* Smart Tool shortcuts = F6+F7, F7+F8 or command+7 (on keyboard) *) tell application "Pro Tools" to activate tell application "System Events" key code 26 using command down -- 0x1a (26) => 7 on (English) keyboard, not on keypad end tell
Regards,
H
-