Jean-Christophe and Phil,
While you can eventually work out the ASObjC to detect wake up, Keyboard Maestro is much, much easier.
Using KM is like using a high-level programming language like Swift, vs using Assembly Language.
To start with, KM already has built-in triggers for both "At System Wake" and "At Login", and I can assign both of those to the same KM Macro. So that part, which is requiring a lot of Obj-C if you
use AppleScript, is already done in KM.
This let's me spend my time on building the Actions I want done after Wake.
My KM Macro uses a combination of native KM Actions, simple AppleScripts, and simple Shell Scripts.
KM lets you call script within a KM Action, and then process the results returned.
KM also has very powerful RegEx engine built-in which is very easy to use.
Here is an image of my KM Macro. You won't understand the details of all of the Actions, but the Action Names should give you a good idea of what it is doing.
Please let me know if you have any questions.
You can download my Wake and Sleep Macros from here:
Here's annotated image of my macro:
Jim Underwood
aka JMichaelTX
NOTE: This is a resend with the image removed, and provided via link.
Original msg was rejected by ASUL rule of being too large.
You should be able to do this through ASObjC without needing KM.
In regular Objective-C,
//register for an observer
NSNotificationCenter* center = [[NSWorkspace sharedWorkspace] notificationCenter];
NSDistributedNotificationCenter* distcenter =[NSDistributedNotificationCenter defaultCenter];
[center addObserver:observer selector:@selector(systemDidWake) name:NSWorkspaceDidWakeNotification object:nil];
//do something on wake
-(void) systemDidWake
{
NSLog(@“I just woke up!"
}
Unless someone else would like to do it first, I’ll have a play around and try and translate that into ASObjC later today.
Best
Phil
On 24 Mar 2017, at 14:27, Jean-Christophe Helary <email@hidden> wrote:
Jim, Chris,
I'm almost convinced, but all this reminds me of QuickSilver, which may be slightly different though. I'll check both.
Jean-Christophe
On Mar 24, 2017, at 16:08, Jim Underwood <email@hidden> wrote:
Jean-Christophe,
You might be amazed at how powerful and easy it is to use Keyboard Maestro.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden