473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

python and apple events ...

Hello, I am wondering if any one knows how I could bind my python app to
answer to a hotkey combination under mac os x. I know it is possible to do
so in obj-c but it seems to call a pure C function, and this makes me a bit
confused on how I would use it under pyobjc here is an example:

#import <Carbon/Carbon.h>

const UInt32 kLockUIElementHotKeyIdentifier = 'lUIk';
const UInt32 kLockUIElementHotKey * * * *= 109; //F10 will be the key to
hit, in combo with Cmd

AppShell * * * * * * *gAppShell = NULL;

EventHotKeyRef gMyHotKeyRef;
EventHotKeyID * *gMyHotKeyID;
EventHandlerUPP * *gAppHotKeyFunction;

pascal OSStatus LockUIElementHotKeyHandler(EventHandlerCallRef
nextHandler,EventRef theEvent, void *userData);

- (void)awakeFromNib
{
** *EventTypeSpec eventType;

** *gAppHotKeyFunction = NewEventHandlerUPP(LockUIElementHotKeyHandler);
** *eventType.eventClass = kEventClassKeyboard;
** *eventType.eventKind = kEventHotKeyPressed;

InstallApplicationEventHandler(gAppHotKeyFunction, 1,&eventType,NULL,NULL);

** *gMyHotKeyID.signature = kLockUIElementHotKeyIdentifier;
** *gMyHotKeyID.id = 1;

** *RegisterEventHotKey(kLockUIElementHotKey, cmdKey, gMyHotKeyID,
GetApplicationEventTarget(), 0, &gMyHotKeyRef);
}

pascal OSStatus LockUIElementHotKeyHandler(EventHandlerCallRef
nextHandler,EventRef theEvent, void *userData)
{
** *// We only register for one hotkey, so if we get here we know the
hotkey
combo was pressed; we can do whatever we want here

** *NSLog(@"Hello, World! HotKey was pressed!");

** *return noErr;
}
--- taken from a post on cocoa.mamasam.com

Thanks in advance for any help.
Stephane
Jul 18 '05 #1
0 999

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
17
by: David Hughes | last post by:
For example, in Python in a Nutshell, Alex Martelli shows how you can run a Windows (notepad.exe) or Unix-like (/bin/vim) text editor using os.spawnv(os.P_WAIT, editor, ) But how would you call...
1
by: MichaelW | last post by:
I've been Python (2.3.4) plus Tkinter happily under MacOX 10.3, having compiled them from scatch. (Tkinter is based on tcl/tk 8.4.1, which were compiled from source via Fink). I then moved my...
77
by: Ben Finney | last post by:
Howdy all, PEP 354: Enumerations in Python has been accepted as a draft PEP. The current version can be viewed online: <URL:http://www.python.org/peps/pep-0354.html> Here is the...
0
by: Brian Quinlan | last post by:
What's New? =========== The Vancouver Python Workshop is pleased to announce the addition of a third keynote speaker to this year's conference. Ian Cavén is the primary developer of the Lowry...
0
by: Brian Quinlan | last post by:
What's New? =========== The deadline for submitting a talk or tutorial for the Vancouver Python Workshop is fast approaching. Talks will be accepted until Friday June 16th. To submit a talk,...
0
by: Brian Quinlan | last post by:
What's New? =========== This is your last change to submit a talk for the Vancouver Python Workshop. Talks will be accepted until Friday June 16th. This is a great opportunity for you to...
5
by: The Night Blogger | last post by:
Is there a way to pull & push data into (Apple Mac OS X Calendar) Ical from Python ?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.