New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Desktop Switcher App Help!

Post Reply New Thread Subscribe

Thread Tools

Member Since: Apr 16, 2014
Posts: 1
cosmiccraze6 is on a distinguished road

cosmiccraze6 is offline
Hi All!
I have been creating a small status bar app that only runs in the status bar and allows you to switch between desktops (spaces)
My menu has buttons for space right and space left and I have connected them into the default AppDelegate.m and created an IBAction for them.
What piece of code allows me to either make theese buttons change the desktops on my mac, Or execute the control arrow keys key shortcut to change desktops?


//  AppDelegate.m

//  Window Switcher


//  Created by Dane Boulton on 16/04/2014.

//  Copyright (c) 2014 DaneBoultonCreations. All rights reserved.


#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window=_window;

-(void)awakeFromNib {

    statusItem = [[NSStatusBar systemStatusBar]statusItemWithLength:NSVariableStatusItemLength ];

    [statusItem setMenu:menu];

    [statusItem setTitle:@"Space Switch"];

    [statusItem setHighlightMode: YES];

    [statusItem setImage:[NSImage imageNamed:@"image"]];


- (IBAction)helpWindow:(id)sender {

    [NSApp activateIgnoringOtherApps:YES];

    [_window makeKeyAndOrderFront:nil];


- (IBAction)quit:(id)sender {

    [NSApp terminate:nil];


- (IBAction)goleft:(id)sender {


- (IBAction)goright:(id)sender {


What do I put under the IBAction go right and go left actions?
Thank you. If you need more information please let me know.
QUOTE Thanks
Mark FX

Mark FX's Avatar
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 180
Mark FX has a spectacular aura about

Mark FX is offline
If you google sending keystroke in Objective-C, you'll see various listings, of which most are on Stack Oveflow.

They all look fairly cpmplex solutions using CFEventRef's.
You could also achieve the same results using Applescript with the NSAppleScript class object, or creating an ApplescriptObjC class in your Xcode project, and calling it from your Objective-C code.

Regards Mark
QUOTE Thanks

Post Reply New Thread Subscribe

« working with file | Multi-line label with Scrolls »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
Best free/not free code scanner, app store? srspicer iOS and Apps 5 03-24-2014 07:09 PM
Looking for App Irishman OS X - Apps and Games 4 03-22-2014 10:30 AM
Apple Maps app bobtomay iOS and Apps 3 03-21-2014 07:16 AM
Calendar app for ios and windows desktop? Smitiz iOS and Apps 1 03-20-2014 08:46 AM

All times are GMT -4. The time now is 01:26 AM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?