Desktop Switcher App Help!

Joined
Apr 16, 2014
Messages
1
Reaction score
0
Points
1
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?

Code:
//


//  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 {

    []
}

@end

What do I put under the IBAction go right and go left actions?
Thank you. If you need more information please let me know.
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
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
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top