View previous topic :: View next topic |
Author |
Message |
Ronnieronson Junior Member
Joined: 12 Apr 2005 Posts: 37
|
Posted: Wed Apr 27, 2005 5:06 pm Post subject: Need help writing a script- Episode 2; Revenge of the Script |
|
|
Hey everyone - fancy helping me write a simple script?
I need to key map the following functions to joystic control.
play in control window 1 (obviously would be a click)
next track control window 1 (would be a right)
previous track control window 1 (would be a left).
My appologies for my laziness here... |
|
Back to top |
|
 |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Wed Apr 27, 2005 5:15 pm Post subject: |
|
|
Should be easy, but what's "control window"? |
|
Back to top |
|
 |
Ronnieronson Junior Member
Joined: 12 Apr 2005 Posts: 37
|
Posted: Wed Apr 27, 2005 5:47 pm Post subject: |
|
|
aha! well, its a very very simple script to control audion.
I know theres not many people use it anymore, but Id choose it over itunes any day!
All it will do is play/pause the music, and skip forward and backwards through the tracks.
no fancy playlist display or browsing - just set off the playlist you want (I have 5 playlists according to genre), and then control the playback through clicker.
....or at least thats the idea.
edit: sorry got carried away: control window is the controller dialog in audion. |
|
Back to top |
|
 |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Wed Apr 27, 2005 5:59 pm Post subject: |
|
|
Alright. I don't know if Audion is scriptable, but this will direct left/right/up/down keypressed to Audion:
[code:1]
tell application "SEC Helper"
enter keypad mode text "Audion" key depressed "key_was_depressed"
end tell
on key_was_depressed(keyCode)
-- make sure it receives keystrokes
tell app "Audion" to activate
if keyCode is "<" then
-- left
tell application "SEC Helper" to simulate keyboard virtual keycode 123
else if keyCode is ">" then
-- right
tell application "SEC Helper" to simulate keyboard virtual keycode 124
else if keyCode is "^" then
-- up
tell application "SEC Helper" to simulate keyboard virtual keycode 126
else if keyCode is "v" then
-- down
tell application "SEC Helper" to simulate keyboard virtual keycode 125
else if keyCode is "s" then
-- center
else
end key_was_depressed
[/code:1]
Clicking will be harder. Much better if you can find a keystroke that does what you want.
For further inspiration, I suggest you have a look at the AlchemyTV DVR script that's included in Clicker 2.2.1.
Best.
--
Jonas |
|
Back to top |
|
 |
Ronnieronson Junior Member
Joined: 12 Apr 2005 Posts: 37
|
Posted: Wed Apr 27, 2005 6:13 pm Post subject: |
|
|
Ty Jonas - actually ive been working from the sample keypad script.
[code:1]property repeatTimes : 1
property keymap_info : {{key_code:"s", key_title:"Play/Pause", key_description:"Plays or Pauses Audion"}, {key_code:"<", key_title:"Rewind", key_description:"Skips to the previous track"}, {key_code:">", key_title:"Forward", key_description:"skips to the next track"}}
try
tell application "SEC Helper"
--- Add the boolean argument "pen deltas" to make Clicker report pen/stylus movements, taps, and drags (new in 2.1)
--- You may check the property in the "current terminal" object to find out if the current terminal
--- supports pen event reporting
enter keypad mode text "Simple Audion Controller" & return & "Press # for help" keypad idle "keypad_is_idle" key depressed "key_was_depressed" key repeated "key_is_repeating" key released "key_was_released"
end tell
on error
beep
end try
on key_was_depressed(keyCode)
try
set repeatTimes to 1
tell application "SEC Helper"
if keyCode is "#" then
show keypad help keymap keymap_info title "Sample Help"
end if
end tell
on error
beep
end try
--- Make keypad stay up (return false to make it go away after an item has
--- been selected.
return true
end key_was_depressed
[/code:1]
....plus the scripted items i found by running record and pressing the audion controls in script editor;
[code:1]
tell application "Audion 3"
activate
play in control window 1
stop control window 1
next track control window 1
previous track control window 1
end tell
[/code:1]
Although you have to bear in mind that the audion controls have obviously not been set up yet so that second script cant do anything useful yet....workin on it though.
Which brings me onto another thing - Ive written a keyboard emulation script, which passes any text entered back to the finder to enter into any text entry field that has already been selected - any thoughts on how I can incorperate this into the standard mouse control script?;
[code:1]
property the_text : ""
try
tell application "SEC Helper"
enter text field mode title "" prompt "Press The Key" value "" length 10
return = true
end tell
on error
beep
end try
on affirmative_textfield_response(a_char)
set the_text to a_char
repeat with a_char in the_text
tell application "System Events"
keystroke a_char
end tell
end repeat
end affirmative_textfield_response
[/code:1] |
|
Back to top |
|
 |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Wed Apr 27, 2005 6:19 pm Post subject: |
|
|
It sure looks like Audion is (at least somewhat) scriptable. I'd stay away from UI scripting, if I could.
Best.
--
Jonas |
|
Back to top |
|
 |
Ronnieronson Junior Member
Joined: 12 Apr 2005 Posts: 37
|
Posted: Wed Apr 27, 2005 8:10 pm Post subject: |
|
|
Well, I got the Audion script working fine (as you might have noticed).
Been trying to work out how to implement my "virtual keyboard" to the mouse control script.
So far Ive remapped "0" to bring up the text entry dialog
[code:1]
--etc etc etc...
else if keyCode is "#" or keyCode is ":help" then
my showHelp()
end if
if keyCode is "0" then
tell application "SEC Helper"
enter text field mode title "" prompt "Keyboard Control" value "" length 10
return = true
end tell
end repeat
end tell
end if
end tell
[/code:1]
....however I cant work out where im supposed to cram in the all essential [code:1]on affirmative_textfield_response(a_char)
set the_text to a_char
repeat with a_char in the_text
tell application "System Events"
keystroke a_char
end tell
end repeat
end affirmative_textfield_response[/code:1] part...
any thoughts on this one Jonas? |
|
Back to top |
|
 |
salling Site Admin
Joined: 27 Jul 2004 Posts: 7498 Location: Stockholm, Sweden
|
Posted: Wed Apr 27, 2005 8:16 pm Post subject: |
|
|
As I'm not familiar with Audion (must have been several years since it was on my computer, I don't really know what it looks like). Here's some general advice, however, based on what you've said:
1. Inspect Audion's AppleScript dictionary (open it from Script Editor). It will tell you what commands, classes, and properties are available to play with.
2. If you really want to (or need to) attempt UI scripting on a grand level, you should use "System Events" (will work on 10.3 or later) to do it. It lets you mess with more things what you can do with Clicker's built in functions. Check this link for more information:
http://www.apple.com/applescript/uiscripting/
Best.
--
Jonas |
|
Back to top |
|
 |
Ronnieronson Junior Member
Joined: 12 Apr 2005 Posts: 37
|
Posted: Wed Apr 27, 2005 8:30 pm Post subject: |
|
|
EDIT: Nevermind Jonas - got it all sussed out now :D |
|
Back to top |
|
 |
|