It is currently Thu Jun 20, 2013 3:41 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: AppleScript wrapper
PostPosted: Sat Jan 16, 2010 8:04 am 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1109
Location: Netherlands
I'm trying to learn a bit about Objective-C / Cocoa.
As an experiment I wrapped NSAppleScript in a very simple way.

It's only one command
Code:
COCOA_AppleScript("beep 3")
Debug COCOA_AppleScript("tell application " + Chr(34) + "Finder" + Chr(34) + " to get the name of every item in the desktop")

I tried to create the userlib both OSX x86 and ppc (ASCII and Unicode) and included both in the zip archive but since I don't have a ppc based system I wasn't able to test it.
Link to userlib : http://www.waterlijn.info/pb/libPBCocoa.zip


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Mon May 02, 2011 12:56 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 531
Location: sweden
I am really trying to make this work, I have the userlibs in my purebasic userlibs directory as default - but I am getting "is not a function".... Any suggestions?
With Applescript we could solve several of the issues I've posted here like; open webpage in safari to print, use webcam, scan etc.


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Mon May 02, 2011 1:06 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 531
Location: sweden
should probably mention i am using PB 4.60 b2...


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Mon May 02, 2011 1:55 pm 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1109
Location: Netherlands
Are you sure you put the libs in the right directory ?
It works fine when I try it in PB 4.60 b2 .


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Mon May 02, 2011 4:58 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 531
Location: sweden
What is the right directory? I have all the libs included in purebasic in applications/purebasic/beta460/purelibraries including this one, should it be in any other directory? (i just tried saving my sourcefile in same directory but it doesnt change)
Do i need to do any kind of includebinary, includefile or anything?


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Mon May 02, 2011 5:25 pm 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1109
Location: Netherlands
Inside the purelibraries directory is a subdirectory userlibraries .
Inside that subdirectory is where you have to put it.
You don't have to include anything. It should work.
You could try the 'Restart Compiler' option but normally that shouldn't be required.


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Mon May 02, 2011 5:40 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 531
Location: sweden
Wow :D :D :D
Thanks a lot.
Its working great. I will try to smash together some Applescript solutions to things and post it over the comming days!


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Fri May 06, 2011 11:22 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 531
Location: sweden
I now use the wrapper for several things. Its awsome and open up a new world of functions, including webcam - recording - photos etc etc. I will post some examples.

I see a difference, I dont know why.

For example I have the following line:
COCOA_AppleScript("tell application "+Chr(34)+"Safari"+Chr(34)+Chr(13)+Chr(10)+"make new document at end of documents"+Chr(13)+Chr(10)+"set url of document 1 to "+Chr(34)+url.s+Chr(34)+Chr(13)+Chr(10)+"end tell")

Works fine.
Compile
Still works.
Move program to USB stick - doesnt work any more
Move program to another computer - doesnt work.

Is there any file I need to keep along with my program?


Top
 Profile  
 
 Post subject: Re: AppleScript wrapper
PostPosted: Fri May 06, 2011 12:28 pm 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1109
Location: Netherlands
I see no reason why it shouldn't work from a usb stick.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye