ccuty  1.0
 All Classes Namespaces Files Functions Enumerations Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ccuty::MacDesktop Class Reference

Class for managing the MacOSX desktop. More...

Public Types

enum  MouseButton
 Mouse buttons.
 
enum  Modifiers
 Key modifiers.
 
enum  KeyType
 Key event types.
 

Public Member Functions

int system (const std::string &command)
 calls the C system() function.
 
int system (const std::string &command, std::string &result)
 calls the C popen() function and returns the result.
 
void activateApp (const std::string &appName)
 activates an application.
 
bool getFrontAppPath (std::string &str)
 returns the path of the front-most application.
 
bool getFrontAppName (std::string &str)
 returns the name of the front-most application.
 
bool getFrontAppLocName (std::string &str)
 returns the localized name of the front-most application.
 
void open (const std::string &path)
 opens a file or an URL. More...
 
void openUrl (const std::string &url)
 opens an URL using the default web browser. More...
 
void openFile (const std::string &path)
 opens a file. More...
 
void openApp (const std::string &path)
 opens an application. More...
 
void openApp (const std::string &path, const std::string &arg)
 opens an application with an argument.
 
void hideApp (const std::string &path)
 hides an application.
 
void tellApp (const std::string &path, const std::string &command, bool inBackground=true)
 sends an AppleScript command to an application.
 
void tellApp (const std::string &path, const std::string &command, std::string &result)
 sends an AppleScript command to an application and return the result.
 
void wakeScreen ()
 reactivates the screen if it's off.
 
void changeVolume (int value, bool displayNotification=false)
 increasees or decrease current volume depending on value sign (exple: -10 or +10).
 
void setVolume (unsigned int value, bool displayNotification=false)
 sets the volume (value must be between 0 and 100).
 
void muteVolume ()
 aternately mute/unmutes the volume.
 
void beep (int seconds)
 beeps the speaker.
 
void say (const std::string &message)
 says this message.
 
void playPause ()
 aternately play/pause iTunes.
 
bool playAlbum (const std::string &album, const std::string &artist)
 Plays one or several albums. More...
 
bool playPlaylist (const std::string &playlist, const std::string &track="")
 Plays tracks in a playlist. More...
 
bool getCurrentTrack (std::string &album, std::string &artist, std::string &track, bool isPlaying=true)
 returns what is currently played or selected in iTunes. More...
 
void showHideDock ()
 aternately show/hides the Dock.
 
void sendKeyStroke (const std::string &keystroke)
 generates a keyStroke, possibly with modifiers. More...
 

Static Public Member Functions

static void getMainScreenSize (size_t &width, size_t &height)
 returns the width and height of the main screen.
 
static void hideMouse (bool state)
 hide/unhides the mouse cursor. More...
 
static void getMouse (double &x, double &y)
 gets mouse location (in screen coordinates).
 
static void pressMouse (double x, double y, unsigned int mouseButton)
 generates a mouse down (button is one of MacDesktop::MouseButton).
 
static void releaseMouse (double x, double y, unsigned int mouseButton)
 generates a mouse up (button is one of MacDesktop::MouseButton.
 
static void dragMouse (double x, double y, unsigned int mouseButton)
 drags the mouse to this location (button is one of MacDesktop::MouseButton).
 
static void moveMouse (double x, double y)
 moves the mouse to this location.
 
static void sendKeycode (uint32_t keycode, uint8_t modifiers=0, uint8_t keytype=KeyType)
 generates a keyCode, possibly with modifiers. More...
 
static void sendLeftKey ()
 generates a LEFT key down/key up.
 
static void sendRightKey ()
 generates a RIGHT key down/key up.
 
static void sendUpKey ()
 generates a UP key down/key up.
 
static void sendDownKey ()
 generates a DOWN key down/key up.
 
static void sendTabKey ()
 generates a TAB key down/key up.
 
static void sendBacktabKey ()
 generates a BACKTAB key down/key up.
 
static void sendSpaceKey ()
 generates a SPACE key down/key up.
 
static void sendReturnKey ()
 generates an RETURN key down/key up.
 
static void sendDeleteKey ()
 generates an DELETE key down/key up.
 
static void sendEscapeKey ()
 generates an ESCAPE key down/key up.
 

Detailed Description

Class for managing the MacOSX desktop.

Member Function Documentation

void ccuty::MacDesktop::open ( const std::string &  path)

opens a file or an URL.

path must be the pathname of the file. applications are executed. URLs must start with a valid prefix (http:, https:, file:)

void ccuty::MacDesktop::openUrl ( const std::string &  url)

opens an URL using the default web browser.

the prefix (http:, https:, file:) may be missing.

void ccuty::MacDesktop::openFile ( const std::string &  path)

opens a file.

path must be the pathname of the file. Apple and Unix scripts are opened in editor.

void ccuty::MacDesktop::openApp ( const std::string &  path)

opens an application.

path can be the name or the pathname of the application. Apple and Unix scripts are executed as applications.

bool ccuty::MacDesktop::playAlbum ( const std::string &  album,
const std::string &  artist 
)

Plays one or several albums.

Either album or artist may be empty, resp. meaning: play any album from this artist or any album with this name

bool ccuty::MacDesktop::playPlaylist ( const std::string &  playlist,
const std::string &  track = "" 
)

Plays tracks in a playlist.

Plays all tracks if track is empty.

bool ccuty::MacDesktop::getCurrentTrack ( std::string &  album,
std::string &  artist,
std::string &  track,
bool  isPlaying = true 
)

returns what is currently played or selected in iTunes.

returns what is being played if isPlaying is true and what is currently seclected if isPlaying is false.

void ccuty::MacDesktop::hideMouse ( bool  state)
static

hide/unhides the mouse cursor.

hides the mouse if the argument is true, unhide otherwise.

Note
this action only takes effect on the application that calls this function, its does no hide the cursor if another applications is selected.
void ccuty::MacDesktop::sendKeyStroke ( const std::string &  keystroke)

generates a keyStroke, possibly with modifiers.

keystroke must start by an AppleScript keystroke possibily followed by modifiers. modifiers is 0 or an ORred combination of MacDesktop::Alt, Control, Command, Shift. modifiers should be 0 if modifiers are already present in keystroke

keystroke examples:

  • "tab"
  • "\"toto"" - ""q" using command down
  • "\"f" using {control down, command down}"
void ccuty::MacDesktop::sendKeycode ( uint32_t  keycode,
uint8_t  modifiers = 0,
uint8_t  keytype = KeyType 
)
static

generates a keyCode, possibly with modifiers.

keycode is a virtual key code. modifiers is 0 or an ORred combination of MacDesktop::Alt, Control, Command, Shift. keytype should either be MacDesktop::KeyDown, KeyUp or KeyType (the default)

Note
Key codes are not localized but correspond to key locations on a standard US keyboard.

The documentation for this class was generated from the following files: