FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Need help writing a 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: Tue Apr 12, 2005 12:25 am    Post subject: Need help writing a script.... Reply with quote

Hi - I wondered if it would be possible to write an applescript that could act as a sort of instant messenger program between mac and phone.

I first thought of this when I wanted to freak my girlfriend out on her ibook - wanted to send a pop up system message to the finder (eg. "Boo!"), and then I got thinking about giving a return value to send back to the phone?

Edit:
Ok so Ive done the first part of the script - just need help creating an input box on the mac which will return a message to the phone via clicker.
Heres what i got so far:
[b]try
tell application "SEC Helper"
enter text field mode title "TT Version 2.0" prompt "Type Ur Msg" value "" length 30
end tell
on error
beep
end try

on affirmative_textfield_response(result_text)
try
tell application "Finder"
display dialog "Matt's Mac says: " & result_text
end tell
on error
beep
end try
end affirmative_textfield_response

on negative_textfield_response()
try
tell application "SEC Helper"
show screen message "User cancelled"
end tell
on error
beep
end try
end negative_textfield_response [/b]

....But Id quite like to be able to specify the message displayed in the dialog box, and possibly remove the cancel button which would appear in the above script.

Any thoughts folks?

Also any good links for learning applescript from scratch? its been years since I wrote my last script (wanted my clamshell ibook to empty the trash on F12 - easy script I guess).

Cheers[b][/b]
Back to top
View user's profile Send private message
salling
Site Admin


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

PostPosted: Tue Apr 12, 2005 12:45 pm    Post subject: Reply with quote

Hello!

I see one problem with your script, and that is that it's blocking the device while the dialog is shown on the Mac. This may or may not be ok for your purposes.

You should be able to customize the dialog (on the Mac) by adding a "buttons" parameter. Check the Standard Additions scripting dictionary for all the optional parameters.

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Joe Mama
Junior Member


Joined: 24 Nov 2004
Posts: 24

PostPosted: Tue Apr 12, 2005 1:40 pm    Post subject: Re: Need help writing a script.... Reply with quote

[quote="Ronnieronson"]on affirmative_textfield_response(result_text)
try
tell application "Finder"
display dialog "Matt's Mac says: " & result_text
end tell
on error
beep
end try
end affirmative_textfield_response[/quote]

[code:1]set myVariableForTheResponse to text returned of (display dialog ("Matt's Mac says: " & result_text) default answer "default reply if any can go here or leave an empty pair of quotes for no default text" buttons {"Cancel","Send Reply"} default button "Send Reply" with icon 1)[/code:1]

To avoid the problem of it hanging your phone or minimizing this problem is to have the 'display dialog' command time out just add [code:1]giving up after 30[/code:1] where 30 is how many seconds until the dialog times out.

All of these little options can be found in the Standard Additions dictionary for the command "display dialog"
Back to top
View user's profile Send private message
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Tue Apr 12, 2005 11:47 pm    Post subject: Reply with quote

cheers for the help guys - not sure I understand it yet but a speedy response nonetheless.

I probably should have pointed out (incase you didnt realise- though you probably did!) the the phrase "matt's mac says:" should only appear on the pop up on the mac.

So far the script works sweet for sending messages to the mac, but Ideally Id like it to be able to eventually allow for a response to be sent back to the phone...please be patient with me - im a designer by trade- not a programmer, and its been a long long time since I got hardcore with applescript!

So what code do I need to add to post a message back to the phone? im guessing some kind of reply button & a text input field- after that im lost...
Back to top
View user's profile Send private message
Ronnieronson
Junior Member


Joined: 12 Apr 2005
Posts: 37

PostPosted: Wed Apr 13, 2005 6:50 pm    Post subject: YES!!!! Reply with quote

:D
Well - ive finally cracked it (although I did have to sift pieces of code from some of the other clicker scripts!).

Now I can initiate a message from my phone to the mac, which displays as a system dialog, and offers an opertunity to the user to respond.
The response is then passed back to the phone (albeit in the form of a question/confirmation dialog- was the only way I could figure out how to display it!).

Thanks for all your help guys!

Is there anywhere I can publish my script for other users if they wanted to use it?
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 13, 2005 7:28 pm    Post subject: Re: YES!!!! Reply with quote

You can export it from Clicker into a cgz file, which you can then attach to a post (in a new thread) in this forum.

Best.
--
Jonas

[quote="Ronnieronson"]:D
Well - ive finally cracked it (although I did have to sift pieces of code from some of the other clicker scripts!).

Now I can initiate a message from my phone to the mac, which displays as a system dialog, and offers an opertunity to the user to respond.
The response is then passed back to the phone (albeit in the form of a question/confirmation dialog- was the only way I could figure out how to display it!).

Thanks for all your help guys!

Is there anywhere I can publish my script for other users if they wanted to use it?[/quote]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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