Le 9 sept. 2014 à 10:50, Jean-Luc Arnaud a écrit:
> tell application "MyApp"
> activate
> tell application "System Events" to key code 53
> end tell
>
> How could I code this, using either Xojo or MBS commands?
There are two things to take into account: the AppleEvent itself and the fact
that AppleScript would auto-launch an app that is inside a “tell application”
statement (in other words, you have to launch System Events prior to sending it
an AppleEvent.
Here's some code, but it's not perfect (it's just how I wrote it for my needs,
but you should take care of the notes):
dim f As FolderItem
f=LaunchServicesFindApplicationForInfoMBS("","com.apple.systemevents","")
if f<>nil then
f.Launch
DelayMBS 3 //Here's the weak part: instead of waiting arbitrarily 3 seconds,
we should loop until System Events is in the list of running processes (on a
slow computer, it may take more than 3 seconds).
end if
dim ae As AppleEvent
ae=new AppleEvent("prcs","kcod","com.apple.systemevents")
ae.IntegerParam("----")=53
call ae.Send
Please tell me if the above works, as I used it to sleep my Mac; I have
rewritten it for your need of sending a key code (but don't actually know
whether it works).
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info