Thanks Arnaud,
I have "Applescript in a nutshell", by no means a nutshell - 500 pages.
I'll go though what you recommend and refer to "Applescript in a nutshell" as
needed.
Thanks again.
Lennox.
Arnaud Nicolet <[EMAIL PROTECTED]> wrote: Hi Lennox,
I can't recommend you any book, sorry.
In my case, I first learned AppleScript (that was my first
"programming" experience). Then, when I started using Realbasic, I
discovered that AppleEvents seemed to do the same actions than
AppleScripts. So I've used both RB and AppleScript at the same time.
That replaces books.
If you still have Classic, you may download an "aete" template for
ResEdit (so, download also ResEdit, so useful!). Then, open the
Finder into ResEdit and take a look at the "aete" resource (with the
template downloaded, else you'll only see raw bytes of data). I
prefer ResEdit to any other app to see such resources. Then, you
understand.
In short, AppleEvent is just a message composed of fields:
dim ae As AppleEvent
dim f As FolderItem
f=DocumentsFolder
'First, set up the wanted message. This consists of an AppleEvent
class (a 4 characters code used for grouping events in a clean way),
an AppleEvent type (inside an AppleEvent class, the specific message/
action to perform) and the MacCreator of the application the message
is meant to be sent to:
ae=newAppleEvent("misc","mvis","MACS") 'Send the "Reveal" (mvis)
command, found in the "Miscellaneous" class (misc) to the Finder (mac
creator "MACS"). You can figure such commands using ResEdit (for
Classic).
'Now that the message is created, we fill the parameters:
ae.FolderItemParam("----")=f 'Main parameter (----) is, as defined in
the "Reveal" command, the folder/file to reveal.
'And now, we send the message:
if ae.send then 'If false, the application (the Finder in our case)
is not running and the message was not delivered at all.
MsgBox "Message sent."
else
MsgBox "Finder not running."
end if
Try with yourself, if you want. Just open some AppleScript scripts
and find their corresponding values in "aete" resources or "rsrc" files.
Hope this helps (even if it can be considered confusing).
Le 19 févr. 07 à 22:59 Soir, Lennox Jacob a écrit:
> Thanks Arnaud,
> Works great now.
> Where can I learn about apple events? Any recommended books?
> Thanks again.
> Lennox.
>
> Arnaud Nicolet wrote: That means, as you probably
> figured out, the System Events is not
> running ;-)
>
> You may try to insert that code:
>
> dim f As FolderItem
>
> f=SystemFolder.child("Library").child("CoreServices").child
> ("System Events.app")
> if f<>nil and f.exists then
> f.launch
> end if
>
> Le 19 févr. 07 à 21:48 Soir, Lennox Jacob a écrit:
>
>> Thanks Arnaud,
>> I used it but I keep getting the error message, ("System Events is
>> not running. I don't know if that can happen.").
>> I tried it with S (Save) instead of ; or : and still got the
>> error message, any suggestions?
>> Lennox.
>>
>>
>> Arnaud Nicolet wrote: Ok, so you are about to use
>> my second suggestion. And, in fact,
>> that's great: you're apparently making an OS X-only thing (I said
>> "great" because simulating a keyboard shortcut is different on every
>> platform; it will save explanations (and I also don't know for
>> Win32)).
>>
>> Ok, I just tried that:
>>
>> dim ae As AppleEvent
>>
>> ae=NewAppleEvent("prcs","kprs","sevs") 'Send a Keystroke event to
>> System Events
>> ae.StringParam("----")=":" 'The key to send
>> ae.MacTypeParam("faal")="Kcmd" 'Use Command key
>> if not ae.Send then
>> MsgBox "System Events is not running. I don't know if that can
>> happen."
>> end if
>>
>> Well, in my tests, I used Command-S in a timer and switched to
>> TextEdit. When the timer executed, a Save dialog appeared in
>> TextEdit, that's it! Now, it should also work with ":".
>>
>> Hope this helps
>>
>> Le 19 févr. 07 à 13:27 Soir, Lennox Jacob a écrit:
>>
>>> Thanks Arnaud,
>>> I do not own the menu item.
>>> I just added CocoaSpellChecker and it is invoked via a menu item
>>> which I do not own. The menuitem has two sub menuitem invoked via
>>> Command-: and Command-;
>>> I would like to invoke these two sub mernu items via seperate
>>> pushbuttons.
>>> Kindly advise.
>>> Lennox.
>>>
>>> Arnaud Nicolet wrote: You have 2 ways of
>>> achieving that.
>>>
>>> If you own the menu item, then you may move the code from the menu
>>> handler to a new method. Then, instead of invoking Command and colon
>>> in your code, you simply call the new method (you also call the new
>>> method from the menu handler so that the menu item does not break).
>>>
>>> If you don't own the menu item or simply want to invoke a keyboard
>>> shortcut, then you'll have to use a technique not built-in RB.
>>> For instance, in MacOS X, you can invoke the "System Events"
>>> application. It's an application made especially for AppleScript,
>>> but, as you know, you can use AppleScript or Apple Events from RB.
>>>
>>> Which one are you trying?
>>>
>>> Le 19 févr. 07 à 04:18 Matin, Lennox Jacob a écrit:
>>>
>>>> Hello,
>>>> I would like to code a pushbutton to effect a menuitem Command and
>>>> colon, how can I do that?
>>>> Thanks.
>>>> Lennox
>>>
>>> _______________________________________________
>>> Unsubscribe or switch delivery mode:
>>>
>>>
>>> Search the archives:
>>>
>>>
>>>
>>>
>>> ---------------------------------
>>> Need Mail bonding?
>>> Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
>>> _______________________________________________
>>> Unsubscribe or switch delivery mode:
>>>
>>>
>>> Search the archives:
>>>
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>>
>>
>> Search the archives:
>>
>>
>>
>>
>> ---------------------------------
>> Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>>
>>
>> Search the archives:
>>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
>
>
> Search the archives:
>
>
>
>
> ---------------------------------
> Need Mail bonding?
> Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
> _______________________________________________
> Unsubscribe or switch delivery mode:
>
>
> Search the archives:
>
_______________________________________________
Unsubscribe or switch delivery mode:
Search the archives:
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your question
on Yahoo! Answers.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>