FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Need help writing a script- Episode 2; Revenge of the Script

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac
View previous topic :: View next topic  
Author Message
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Wed Apr 27, 2005 5:06 pm    Post subject: Need help writing a script- Episode 2; Revenge of the Script Reply with quote

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
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Apr 27, 2005 5:15 pm    Post subject: Reply with quote

Should be easy, but what's "control window"?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Wed Apr 27, 2005 5:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Apr 27, 2005 5:59 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Wed Apr 27, 2005 6:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Apr 27, 2005 6:19 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Wed Apr 27, 2005 8:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Wed Apr 27, 2005 8:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Wed Apr 27, 2005 8:30 pm    Post subject: Reply with quote

EDIT: Nevermind Jonas - got it all sussed out now :D
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group