Results 1 to 2 of 2

Thread: Desktop Switcher App Help!

  1. #1

    Member Since
    Apr 16, 2014
    Question Desktop Switcher App Help!
    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.

  2. #2

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    West Sussex, UK
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. App Suggestion: Time tracking Desktop app
    By newmanm in forum macOS - Apps and Games
    Replies: 2
    Last Post: 08-09-2012, 04:31 PM
  2. Replies: 8
    Last Post: 04-30-2010, 12:11 PM
  3. Looking for an App switcher
    By DarpaChief in forum macOS - Apps and Games
    Replies: 7
    Last Post: 12-11-2008, 07:09 AM
  4. Cube Desktop Switcher for Single User
    By DrQuincy in forum Running Windows (or anything else) on your Mac
    Replies: 3
    Last Post: 11-13-2006, 06:17 AM
  5. Switcher? Best App for MS Apps
    By dupressdsu in forum Switcher Hangout
    Replies: 16
    Last Post: 07-12-2006, 01:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts