Friday, August 14, 2020

#1 2019-12-09 04:22:17 am

oudi
Member
Registered: 2019-12-03
Posts: 11

applescript for pro tools problem

HI everybody

FIRST
A big thank you for all the contributions....
Really nice....

i 'm in the begin of my apllescript adventure.
and thank of you i understand more and more.

BUT

i try to make a script in Pro tools app for select the menu by criteria in soundfiled recording.
it's ok
BUT

the end of the script is very very slow juste to do 3 key code action....
i don't understand.
maybe you can help me.
here is the script

Applescript:

activate application "Pro Tools"
tell application "System Events"
tell application process "Pro Tools"

set window_name to name of front window
-- key code for copy paste
key code 8 using {command down}
key code 41
key code 9 using {command down}
-- click pop up button for track P1
click pop up button 1 of group "P1 - Audio Track " of window window_name
-- type e for select expand channels and by criteria

-- PROBLEM THE SRCIPT VERY VERY LONG TIME TO DO THE NEXT STEP

key code 14
key code 124
key code 36
end tell



end tell

Thanks in advance.
best

ps : sorry for my beautifull PERFECT english

Last edited by oudi (2019-12-09 04:30:28 am)

Offline

 

#2 2019-12-09 10:42:36 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

oudi wrote:


the end of the script is very very slow juste to do 3 key code action....
i don't understand.


I don’t know what all these keycodes do, but I think it’s better to take them out of the blocks tell process "Pro Tools"  and send them directly to "System Events":

Applescript:


activate application "Pro Tools"

tell application "System Events"
   
   tell application process "Pro Tools" to set window_name to name of front window
   -- key code for copy paste
   keystroke "c" using command down -- Copy of Edit menu
   key code 41 -- ";" -- what this does???
   keystroke "v" using command down -- Paste of Edit menu
   
   tell application process "Pro Tools"
       -- click pop up button for track P1
       click pop up button 1 of group "P1 - Audio Track " of window window_name
       -- type e for select expand channels and by criteria
   end tell
   
   keystroke "e" --- ????
   key code 124 -- Right Arrow ---???
   keystroke return ----????
   
end tell

NOTE: I guess, you want use something like this shortcut, but I don't know what it does:

Applescript:

keystroke "e" & return using right

or, as this:

Applescript:


keystroke "e" using right
keystroke return

Last edited by KniazidisR (2019-12-09 11:32:10 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#3 2019-12-10 03:13:18 am

oudi
Member
Registered: 2019-12-03
Posts: 11

Re: applescript for pro tools problem

Hello
thank you for the answer.
i was not really understandable...sorry.
by the way Oliver M solve the problem in another forum.
it's a problem with pro tools and right click .
and the issue was Cliclick.
here the new script

Applescript:

property cliclickCLIPath : missing value

set cliclickCLIPath to "usr/local/bin/cliclick"

activate application "Pro Tools"
tell application "System Events"
   tell application process "Pro Tools"
       
       set window_name to name of front window
       -- key code for copy paste
       keystroke "c" using command down
       keystroke "m"
       keystroke "v" using command down

       -- click pop up button for track P1
       tell pop up button 1 of group "temoin - Audio Track " of window window_name        
           set {xPosition, yPosition} to position
           set {xSize, ySize} to size
           my cliClick("rc:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
           
           
       --to make selection in the rght click
           key code 14 -- selection letter E in the righ click for go to good selection
           key code 124 --right arrow to go to next step in right selection
           key code 36 -- enter
           
           
       end tell
   end tell
   
   
   
end tell

on cliClick(coordinate)
   do shell script quoted form of cliclickCLIPath & " -r " & coordinate
end cliClick

thank you again for your help.

a rapid question...

what 's the diference in use keystroke "c" and key code 8 ????

now i will try to "organize " my little script to be more efficient
i find that the beginnnig if very slow...

best
jf

Last edited by oudi (2019-12-10 03:20:14 am)

Offline

 

#4 2019-12-10 04:03:15 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

oudi wrote:

what 's the diference in use keystroke "c" and key code 8 ????


They does the same job, but for the keys which has letter-representation, keystrokes is more human readable.  For example, it is easy to keystroke "my dog" in some textfield and you see in the code what it does too. Special symbols you can't keystroke, so can't avoid using key code.

Some special symbols however has its AppleScript representations (once again, to be human readable), as AppleScript constants.
This:

Applescript:


key code 14 -- selection letter E in the righ click for go to good selection
key code 124 --right arrow to go to next step in right selection
key code 36 -- enter

is equivalent to this:

Applescript:


keystroke "e"
keystroke right
keystroke return

Last edited by KniazidisR (2019-12-10 04:37:38 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#5 2019-12-10 04:09:31 am

oudi
Member
Registered: 2019-12-03
Posts: 11

Re: applescript for pro tools problem

yes i have good understand ...
but i was just to be sur..

thank you

i'll be back for another questionS for sur.
best
jf

Offline

 

#6 2019-12-10 04:54:12 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

As I say above the keystrokes and key codes is the job for System Events and not for process. The process window only should be the frontmost. I have not "Pro Tools" on my Mac, but it is interesting for me if the following script works correct:

Applescript:


tell application "Pro Tools" to activate

tell application "System Events"
   -- key code for copy paste
   keystroke "c" using command down
   keystroke "m"
   keystroke "v" using command down
   tell application process "Pro Tools" to tell front window
       -- click pop up button for track P1
       tell pop up button 1 of group "temoin - Audio Track "
           set {{xPosition, yPosition}, {xSize, ySize}} to {position, size}
       end tell
   end tell
end tell

my cliClick("rc:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))

tell application "System Events"
   --to make selection in the rght click
   key code 14 -- selection letter E in the righ click for go to good selection
   key code 124 --right arrow to go to next step in right selection
   key code 36 -- enter
end tell


on cliClick(coordinate)
   do shell script quoted form of cliclickCLIPath & " -r " & coordinate
end cliClick


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#7 2019-12-10 03:18:35 pm

oudi
Member
Registered: 2019-12-03
Posts: 11

Re: applescript for pro tools problem

no the script don't work

error
the variable cliclickCLIPath is not defined

it works with

property cliclickCLIPath : missing value

set cliclickCLIPath to "usr/local/bin/cliclick"

Applescript:

property cliclickCLIPath : missing value

set cliclickCLIPath to "usr/local/bin/cliclick"
tell application "Pro Tools" to activate

tell application "System Events"
   -- key code for copy paste
   keystroke "c" using command down
   keystroke "m"
   keystroke "v" using command down
   tell application process "Pro Tools" to tell front window
       -- click pop up button for track P1
       tell pop up button 1 of group "temoin - Audio Track "
           set {{xPosition, yPosition}, {xSize, ySize}} to {position, size}
       end tell
   end tell
end tell

my cliClick("rc:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))

tell application "System Events"
   --to make selection in the rght click
   key code 14 -- selection letter E in the righ click for go to good selection
   key code 124 --right arrow to go to next step in right selection
   key code 36 -- enter
end tell


on cliClick(coordinate)
   do shell script quoted form of cliclickCLIPath & " -r " & coordinate
end cliClick

Offline

 

#8 2019-12-10 11:55:30 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

oudi wrote:

no the script don't work

error
the variable cliclickCLIPath is not defined

it works with

property cliclickCLIPath : missing value

set cliclickCLIPath to "usr/local/bin/cliclick"


I forgot to replace cliclickCLIPath with "usr/local/bin/cliclick". No need property and variable:

Applescript:

do shell script (quoted form of "usr/local/bin/cliclick") & " -r " & coordinate

The main thing, however, is that, as I expected, the keystrokes and key codes work just that way - outside of processes.

Last edited by KniazidisR (2019-12-10 11:59:29 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#9 2019-12-11 11:19:07 am

oudi
Member
Registered: 2019-12-03
Posts: 11

Re: applescript for pro tools problem

ok
i try to do a click with option with clciclick for another action.
but it 's don't work
i write
my cliClick("kd:alt" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))

??

best
jf

Offline

 

#10 2019-12-11 12:11:56 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4568

Re: applescript for pro tools problem

My understanding is that a space character was missing.
May you try :

my cliClick("kd:alt " & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 11 décembre 2019  19:10:38

Offline

 

#11 2019-12-13 11:52:14 am

oudi
Member
Registered: 2019-12-03
Posts: 11

Re: applescript for pro tools problem

hello
thank you for help but don't work
Unrecognized action shortcut “52,172”
i think there is another probelm in my script.
right click work  but not this.
i will find :-)

Offline

 

#12 2019-12-14 06:33:42 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

oudi wrote:

ok
i try to do a click with option with clciclick for another action.
but it 's don't work
i write
my cliClick("kd:alt" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))

??

best
jf


Why do you believe,that it doesn't work? This action is only pressing key "option" DOWN. But to do whole click action you should after some delay release the key sending event KEY UP:

Applescript:


my cliClick("kd:alt" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
delay 0.1
my cliClick("ku:alt" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#13 2019-12-14 06:56:46 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4568

Re: applescript for pro tools problem

@KniazidisR

Here,
my cliClick("kd:alt" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
issue :
error "Invalid key “alt60” given as argument to command “kd”.
The key name may only be one of:
  - alt
  - cmd
  - ctrl
  - fn
  - shift" number 1

my cliClick("kd:alt " & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
issue :
error "Unrecognized action shortcut “60,50”" number 1

my cliClick("kd:alt " & xPosition + (xSize div 2) & ", " & yPosition + (ySize div 2))
issue :
error "Unrecognized action shortcut “60,”" number 1

I will search to see if my cliclick file is up to date.

Edit. My version is "cliclick 4.0.1, 2018-04-10", it's up to date.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 14 décembre 2019  13:56:36

Last edited by Yvan Koenig (2019-12-14 07:11:13 am)

Offline

 

#14 2019-12-14 07:13:27 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

I read the CliClick usage guide and see that my script above is wrong. Most likely this is correct syntax:

Applescript:


my cliClick("kd:alt")
my cliClick("c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2))
my cliClick("ku:alt")

I have not Pro Tools to test.

Last edited by KniazidisR (2019-12-14 07:25:38 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#15 2019-12-14 08:02:14 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1265

Re: applescript for pro tools problem

I tested - it works fine. The following opens Extended Menu of my WiFi:

Applescript:


my cliClick("kd:alt")
my cliClick("c:844,10")
my cliClick("ku:alt")

on cliClick(coordinate)
   do shell script "usr/local/bin/cliclick " & coordinate
end cliClick


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#16 2019-12-14 08:31:10 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4568

Re: applescript for pro tools problem

@KniazidisR

What with :

Applescript:

my cliClick("kd:alt c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2)) & " ku:alt"

# Your modified handler (without (" -r ")
on cliClick(coordinate)
   do shell script quoted form of cliclickCLIPath & " " & coordinate
end cliClick

and with :

Applescript:

my cliClick("kd:alt c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2)) & " ku:alt"

# The original handler (with (" -r ")
on cliClick(coordinate)
   do shell script quoted form of cliclickCLIPath & " -r " & coordinate
end cliClick

Here both behave flawlessly but I don't know if they do their wanted duty.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 14 décembre 2019  15:30:18

Last edited by Yvan Koenig (2019-12-14 08:32:00 am)

Offline

 

#17 2019-12-15 08:40:45 am

oudi
Member
Registered: 2019-12-03
Posts: 11

Re: applescript for pro tools problem

hello
thank you for help.
the last version of Yvan looks work.....thx

Applescript:

my cliClick("kd:alt c:" & xPosition + (xSize div 2) & "," & yPosition + (ySize div 2)) & " ku:alt"

# The original handler (with (" -r ")
on cliClick(coordinate)
do shell script quoted form of cliclickCLIPath & " -r " & coordinate
end cliClick

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)